Skip to content

Commit 32f8641

Browse files
committed
test for flux
1 parent 0e3d33c commit 32f8641

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

.github/workflows/testflux.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Flux
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Start Docker container
18+
run: |
19+
docker run -d --name flux -v `pwd`:/pydra fluxrm/flux-sched:focal-v0.28.0 flux start
20+
sleep 5 # Give the container some time to start
21+
22+
- name: Run necessary changes in container
23+
run: |
24+
# Install Python 3 (if not already installed)
25+
docker exec flux apt-get update
26+
docker exec flux apt-get install -y python3
27+
28+
# Add Python to PATH
29+
docker exec flux echo 'export PATH="/home/fluxuser/.local/bin:$PATH"' >> ~/.bashrc
30+
31+
# Create an alias for 'python' (pointing to 'python3')
32+
docker exec flux echo 'alias python=python3' >> ~/.bashrc
33+
34+
# Source the updated .bashrc to apply changes
35+
docker exec flux source ~/.bashrc
36+
37+
- name: Run pytest
38+
run: |
39+
docker exec flux bash -c "pytest --psij=flux --color=yes -vs -n auto --psij=slurm --cov pydra --cov-config /pydra/.coveragerc --cov-report xml:/pydra/cov.xml --doctest-modules /pydra/pydra/"
40+
41+
- name: Upload to codecov
42+
run: |
43+
docker exec flux bash -c "codecov --root /pydra -f /pydra/cov.xml -F unittests"
44+
45+
- name: Stop and remove Docker container
46+
run: docker stop flux && docker rm flux

pydra/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def pytest_addoption(parser):
1111
"--psij",
1212
action="store",
1313
help="run with psij subtype plugin",
14-
choices=["local", "slurm"],
14+
choices=["local", "slurm", "flux"],
1515
)
1616

1717

pydra/engine/workers.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def __init__(self, subtype, **kwargs):
913913
self.psij = psij
914914

915915
# Check if the provided subtype is valid
916-
valid_subtypes = ["local", "slurm"]
916+
valid_subtypes = ["local", "slurm", "flux"]
917917
if subtype not in valid_subtypes:
918918
raise ValueError(
919919
f"Invalid 'subtype' provided. Available options: {', '.join(valid_subtypes)}"
@@ -992,7 +992,7 @@ async def exec_psij(self, runnable, rerun=False):
992992
with open(file_path, "wb") as file:
993993
pickle.dump(runnable._run, file)
994994
func_path = absolute_path / "run_pickled.py"
995-
spec = self.make_spec("python", [func_path, file_path])
995+
spec = self.make_spec("python", [str(func_path), str(file_path)])
996996
else: # it could be tuple that includes pickle files with tasks and inputs
997997
cache_dir = runnable[-1].cache_dir
998998
file_path_1 = cache_dir / "taskmain.pkl"
@@ -1006,28 +1006,28 @@ async def exec_psij(self, runnable, rerun=False):
10061006
spec = self.make_spec(
10071007
"python",
10081008
[
1009-
func_path,
1010-
file_path_1,
1011-
file_path_2,
1009+
str(func_path),
1010+
str(file_path_1),
1011+
str(file_path_2),
10121012
],
10131013
)
10141014

10151015
if rerun:
10161016
spec.arguments.append("--rerun")
10171017

10181018
spec.stdout_path = cache_dir / "demo.stdout"
1019-
spec.stderr_path = cache_dir / "demo.stderr"
1019+
# spec.stderr_path = cache_dir / "demo.stderr"
10201020

10211021
job = self.make_job(spec, None)
10221022
jex.submit(job)
10231023
job.wait()
10241024

1025-
if spec.stderr_path.stat().st_size > 0:
1026-
with open(spec.stderr_path, "r") as stderr_file:
1027-
stderr_contents = stderr_file.read()
1028-
raise Exception(
1029-
f"stderr_path '{spec.stderr_path}' is not empty. Contents:\n{stderr_contents}"
1030-
)
1025+
# if spec.stderr_path.stat().st_size > 0:
1026+
# with open(spec.stderr_path, "r") as stderr_file:
1027+
# stderr_contents = stderr_file.read()
1028+
# raise Exception(
1029+
# f"stderr_path '{spec.stderr_path}' is not empty. Contents:\n{stderr_contents}"
1030+
# )
10311031

10321032
return
10331033

@@ -1044,6 +1044,6 @@ def close(self):
10441044
"sge": SGEWorker,
10451045
**{
10461046
"psij-" + subtype: lambda subtype=subtype: PsijWorker(subtype=subtype)
1047-
for subtype in ["local", "slurm"]
1047+
for subtype in ["local", "slurm", "flux"]
10481048
},
10491049
}

0 commit comments

Comments
 (0)