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

Switch to using local_experimental as a default runner #2094

Closed
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* Improve error handling in `_zip_folder_to_file_and_remove` (\#2057).
* Improve error handling in `FractalSlurmSSHExecutor` `handshake` method (\#2083).
* Use the "spawn" start method for the multiprocessing context, for the `ProcessPoolExecutor`-based runner (\#2084).
* Use `local_experimental` as default runner (\#2094).
* SSH internals:
* Add `FractalSSH.remote_exists` method (\#2008).
* Drop `FractalSSH.{_get,_put}` wrappers of `SFTPClient` methods (\#2077).
Expand Down
14 changes: 4 additions & 10 deletions fractal_server/app/runner/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@


_backends = {}
_backends["local"] = local_process_workflow
_backends["local_experimental"] = local_process_workflow
_backends["slurm"] = slurm_process_workflow


Expand Down Expand Up @@ -128,18 +128,12 @@ async def submit_workflow(

settings = Inject(get_settings)
FRACTAL_RUNNER_BACKEND = settings.FRACTAL_RUNNER_BACKEND
if FRACTAL_RUNNER_BACKEND == "local":
if FRACTAL_RUNNER_BACKEND == "local_experimental":
process_workflow = local_process_workflow
elif FRACTAL_RUNNER_BACKEND == "slurm":
process_workflow = slurm_process_workflow
else:

if FRACTAL_RUNNER_BACKEND == "local_experimental":
log_msg = (
f"{FRACTAL_RUNNER_BACKEND=} is not available for v1 jobs."
)
else:
log_msg = f"Invalid {FRACTAL_RUNNER_BACKEND=}"
log_msg = f"Invalid {FRACTAL_RUNNER_BACKEND=}"

fail_job(
job=job,
Expand Down Expand Up @@ -204,7 +198,7 @@ async def submit_workflow(
os.umask(original_umask)

# Define and create WORKFLOW_DIR_REMOTE
if FRACTAL_RUNNER_BACKEND == "local":
if FRACTAL_RUNNER_BACKEND == "local_experimental":
WORKFLOW_DIR_REMOTE = WORKFLOW_DIR_LOCAL
elif FRACTAL_RUNNER_BACKEND == "slurm":
WORKFLOW_DIR_REMOTE = (
Expand Down
2 changes: 1 addition & 1 deletion fractal_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def make_FRACTAL_RUNNER_WORKING_BASE_DIR_absolute(cls, v):
"local_experimental",
"slurm",
"slurm_ssh",
] = "local"
] = "local_experimental"
"""
Select which runner backend to use.
"""
Expand Down
11 changes: 0 additions & 11 deletions tests/no_version/test_unit_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_settings_injection(override_settings):
FRACTAL_TASKS_DIR="/tmp",
POSTGRES_DB="test",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
),
False,
),
Expand All @@ -40,7 +39,6 @@ def test_settings_injection(override_settings):
dict(
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="test",
),
True,
Expand All @@ -50,7 +48,6 @@ def test_settings_injection(override_settings):
dict(
JWT_SECRET_KEY="secret",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="test",
),
True,
Expand All @@ -62,7 +59,6 @@ def test_settings_injection(override_settings):
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
),
True,
),
Expand All @@ -72,7 +68,6 @@ def test_settings_injection(override_settings):
FRACTAL_TASKS_DIR="/tmp",
POSTGRES_DB="fractal",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
),
False,
),
Expand All @@ -82,7 +77,6 @@ def test_settings_injection(override_settings):
dict(
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="test",
),
True,
Expand All @@ -91,7 +85,6 @@ def test_settings_injection(override_settings):
dict(
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="test",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
),
Expand Down Expand Up @@ -192,7 +185,6 @@ def test_settings_check_wrong_python():
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="db-name",
FRACTAL_TASKS_PYTHON_3_12=None,
FRACTAL_TASKS_PYTHON_DEFAULT_VERSION="3.12",
Expand Down Expand Up @@ -269,7 +261,6 @@ def test_collect_oauth_clients(monkeypatch):
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="db-name",
)
debug(settings.OAUTH_CLIENTS_CONFIG)
Expand All @@ -282,7 +273,6 @@ def test_collect_oauth_clients(monkeypatch):
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="db-name",
)
debug(settings.OAUTH_CLIENTS_CONFIG)
Expand All @@ -302,7 +292,6 @@ def test_collect_oauth_clients(monkeypatch):
JWT_SECRET_KEY="secret",
FRACTAL_TASKS_DIR="/tmp",
FRACTAL_RUNNER_WORKING_BASE_DIR="/tmp",
FRACTAL_RUNNER_BACKEND="local",
POSTGRES_DB="db-name",
)
debug(settings.OAUTH_CLIENTS_CONFIG)
Expand Down
4 changes: 2 additions & 2 deletions tests/no_version/test_unit_user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ async def test_validate_user_settings(db):
user=user_without_settings, backend="slurm_ssh", db=db
)

# User with empty settings: backend="local"
# User with empty settings: backend="local_experimental"
await validate_user_settings(
user=user_with_invalid_settings, backend="local", db=db
user=user_with_invalid_settings, backend="local_experimental", db=db
)
# User with empty settings: backend="slurm_ssh"
with pytest.raises(
Expand Down
32 changes: 8 additions & 24 deletions tests/v1/01_unit/test_unit_submit_workflow_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import time
from pathlib import Path

import pytest
from devtools import debug

from fractal_server.app.db import get_sync_db
Expand Down Expand Up @@ -136,10 +135,7 @@ def patched_get_timestamp():
)
await db.refresh(job)

if settings.FRACTAL_RUNNER_BACKEND != "local_experimental":
assert "already exists" in job.log
else:
assert "is not available for v1 jobs" in job.log
assert "already exists" in job.log


async def test_fail_submit_workflows_wrong_IDs(
Expand Down Expand Up @@ -188,10 +184,7 @@ async def test_fail_submit_workflows_wrong_IDs(
)
await db.refresh(job)
assert job.status == JobStatusTypeV1.FAILED
if settings.FRACTAL_RUNNER_BACKEND != "local_experimental":
assert job.log == "Cannot fetch workflow 1234 from database\n"
else:
assert "is not available for v1 jobs" in job.log
assert job.log == "Cannot fetch workflow 1234 from database\n"

await submit_workflow(
workflow_id=workflow.id,
Expand All @@ -202,16 +195,12 @@ async def test_fail_submit_workflows_wrong_IDs(
await db.refresh(job)
debug(job)
assert job.status == JobStatusTypeV1.FAILED
if settings.FRACTAL_RUNNER_BACKEND != "local_experimental":
assert job.log == (
"Cannot fetch input_dataset 1111 from database\n"
"Cannot fetch output_dataset 2222 from database\n"
)
else:
assert "is not available for v1 jobs" in job.log
assert job.log == (
"Cannot fetch input_dataset 1111 from database\n"
"Cannot fetch output_dataset 2222 from database\n"
)


@pytest.mark.parametrize("invalid_backend", ("local_experimental", "foo"))
async def test_fail_submit_workflows_wrong_backend(
MockCurrentUser,
project_factory,
Expand All @@ -222,11 +211,9 @@ async def test_fail_submit_workflows_wrong_backend(
task_factory,
tmp_path,
db,
invalid_backend,
override_settings_factory,
):
override_settings_factory(FRACTAL_RUNNER_BACKEND=invalid_backend)

override_settings_factory(FRACTAL_RUNNER_BACKEND="INVALID")
async with MockCurrentUser() as user:

project = await project_factory(user)
Expand All @@ -252,7 +239,4 @@ async def test_fail_submit_workflows_wrong_backend(
job_id=job.id,
)
await db.refresh(job)
if invalid_backend == "local_experimental":
assert "is not available for v1 jobs" in job.log
else:
assert "Invalid FRACTAL_RUNNER_BACKEND" in job.log
assert "Invalid FRACTAL_RUNNER_BACKEND" in job.log
20 changes: 9 additions & 11 deletions tests/v1/04_api/test_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,15 @@ async def test_stop_job(
f"{PREFIX}/job/{job.id}/stop/",
)

if backend == "slurm":
assert res.status_code == 202
shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()
res = await registered_superuser_client.get(
f"{PREFIX}/job/{job.id + 42}/stop/",
)
assert res.status_code == 404
else:
assert res.status_code == 422
assert res.status_code == 202

shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()
res = await registered_superuser_client.get(
f"{PREFIX}/job/{job.id + 42}/stop/",
)
assert res.status_code == 404
ychiucco marked this conversation as resolved.
Show resolved Hide resolved


async def test_download_job_logs(
Expand Down
13 changes: 5 additions & 8 deletions tests/v1/04_api/test_job_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ async def test_stop_job(
res = await client.get(
f"api/v1/project/{project.id}/job/{job.id}/stop/"
)
if backend == "slurm":
assert res.status_code == 202

shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()
else:
assert res.status_code == 422

assert res.status_code == 202
shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()


async def test_job_list(
Expand Down
2 changes: 1 addition & 1 deletion tests/v1/05_backend/test_backend_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def test_runner(

# Create working folder(s)
subfolder_names = []
if backend == "local":
if backend == "local_experimental":
workflow_dir_local = tmp777_path / "server" # OK 777 here
workflow_dir_remote = workflow_dir_local
umask = os.umask(0)
Expand Down
19 changes: 8 additions & 11 deletions tests/v2/03_api/admin/test_admin_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,14 @@ async def test_stop_job(
f"{PREFIX}/job/{job.id}/stop/",
)

if backend == "slurm":
assert res.status_code == 202
shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()
res = await registered_superuser_client.get(
f"{PREFIX}/job/{job.id + 42}/stop/",
)
assert res.status_code == 404
else:
assert res.status_code == 422
assert res.status_code == 202
shutdown_file = tmp_path / SHUTDOWN_FILENAME
debug(shutdown_file)
assert shutdown_file.exists()
res = await registered_superuser_client.get(
f"{PREFIX}/job/{job.id + 42}/stop/",
)
assert res.status_code == 404
ychiucco marked this conversation as resolved.
Show resolved Hide resolved


async def test_download_job_logs(
Expand Down
8 changes: 6 additions & 2 deletions tests/v2/03_api/admin/test_admin_taskgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ def get(self, *args, **kwargs):
return None


@pytest.mark.parametrize("FRACTAL_RUNNER_BACKEND", ["local", "slurm_ssh"])
@pytest.mark.parametrize(
"FRACTAL_RUNNER_BACKEND", ["local_experimental", "slurm_ssh"]
)
async def test_admin_deactivate_task_group_api(
app,
client,
Expand Down Expand Up @@ -443,7 +445,9 @@ async def test_admin_deactivate_task_group_api(
assert "does not exist" in res.log


@pytest.mark.parametrize("FRACTAL_RUNNER_BACKEND", ["local", "slurm_ssh"])
@pytest.mark.parametrize(
"FRACTAL_RUNNER_BACKEND", ["local_experimental", "slurm_ssh"]
)
async def test_reactivate_task_group_api(
app,
client,
Expand Down
12 changes: 9 additions & 3 deletions tests/v2/03_api/test_api_task_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def get(self, *args, **kwargs):
return None


@pytest.mark.parametrize("FRACTAL_RUNNER_BACKEND", ["local", "slurm_ssh"])
@pytest.mark.parametrize(
"FRACTAL_RUNNER_BACKEND", ["local_experimental", "slurm_ssh"]
)
async def test_deactivate_task_group_api(
app,
client,
Expand Down Expand Up @@ -131,7 +133,9 @@ async def test_deactivate_task_group_api(
assert "does not exist" in res.json()["log"]


@pytest.mark.parametrize("FRACTAL_RUNNER_BACKEND", ["local", "slurm_ssh"])
@pytest.mark.parametrize(
"FRACTAL_RUNNER_BACKEND", ["local_experimental", "slurm_ssh"]
)
async def test_reactivate_task_group_api(
app,
client,
Expand Down Expand Up @@ -247,7 +251,9 @@ async def test_reactivate_task_group_api(
assert res.json()["status"] == "failed"


@pytest.mark.parametrize("FRACTAL_RUNNER_BACKEND", ["local", "slurm_ssh"])
@pytest.mark.parametrize(
"FRACTAL_RUNNER_BACKEND", ["local_experimental", "slurm_ssh"]
)
async def test_lifecycle(
client,
MockCurrentUser,
Expand Down