Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test that runs with a given exec_config #56

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/jobflow_remote/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ def arithmetic(
return op(a, b)

return None


@job
def check_env_var() -> str:
import os

return os.environ.get("TESTING_ENV_VAR", "unset")
1 change: 1 addition & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def write_tmp_settings(
connect_kwargs={"allow_agent": False, "look_for_keys": False},
),
},
exec_config={"test": {"export": {"TESTING_ENV_VAR": random_project_name}}},
runner=dict(
delay_checkout=1,
delay_check_run_status=1,
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/test_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,32 @@ def test_expected_failure(worker, job_controller):

assert job_controller.count_jobs(state=JobState.FAILED) == 2
assert job_controller.count_flows(state=FlowState.FAILED) == 1


@pytest.mark.parametrize(
"worker",
["test_local_worker", "test_remote_worker"],
)
def test_exec_config(worker, job_controller, random_project_name):
"""Tests that an environment variable set in the exec config
is available to the job.

"""

from jobflow_remote import submit_flow
from jobflow_remote.jobs.runner import Runner
from jobflow_remote.testing import check_env_var

job = check_env_var()
submit_flow(job, worker=worker, exec_config="test")

assert job_controller.count_jobs({}) == 1
assert len(job_controller.get_jobs({})) == 1
assert job_controller.count_flows({}) == 1

runner = Runner()
runner.run(ticks=5)

job = job_controller.get_jobs({})[0]
output = job_controller.jobstore.get_output(uuid=job["uuid"])
assert output == random_project_name
Loading