Skip to content
Open
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
11 changes: 1 addition & 10 deletions simvue/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import logging
import multiprocessing.synchronize
import sys
import threading
import os
import shutil
Expand Down Expand Up @@ -208,8 +207,6 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None:
...
```

Note `completion_trigger` is not supported on Windows operating systems.

Parameters
----------
identifier : str
Expand All @@ -230,19 +227,13 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None:
completion_callback : typing.Callable | None, optional
callback to run when process terminates
completion_trigger : threading.Event | None, optional
this trigger event is set when the processes completes (not supported on Windows)
this trigger event is set when the processes completes
"""
pos_args = list(args)

if not self._runner.name:
raise RuntimeError("Cannot add process, expected Run instance to have name")

if sys.platform == "win32" and completion_trigger:
logger.warning(
"Completion trigger for 'add_process' may fail on Windows "
"due to function pickling restrictions"
)

# To check the executable provided by the user exists combine with environment
# PATH variable if exists, if not provided use the current environment
_session_path: str | None = (os.environ.copy() | (env or {})).get("PATH", None)
Expand Down
11 changes: 1 addition & 10 deletions simvue/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import time
import types
import functools
import platform
import typing
import uuid
import numpy
Expand Down Expand Up @@ -876,8 +875,6 @@ def add_process(
def callback_function(status_code: int, std_out: str, std_err: str) -> None: ...
```

Note `completion_callback` is not supported on Windows operating systems.

Alternatively you can use `completion_trigger` to create a multiprocessing event which will be set
when the process has completed.

Expand All @@ -897,7 +894,7 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: ...
the input file to run, note this only work if the input file is not an option, if this is the case
you should provide it as such and perform the upload manually, by default None
completion_callback : typing.Callable | None, optional
callback to run when process terminates (not supported on Windows)
callback to run when process terminates
completion_trigger : threading.Event | None, optional
this trigger event is set when the processes completes
env : dict[str, str], optional
Expand Down Expand Up @@ -941,12 +938,6 @@ def callback_function(status_code: int, std_out: str, std_err: str) -> None: ...
+ "use an instance of 'threading.Event' instead."
)

if platform.system() == "Windows" and completion_trigger:
raise RuntimeError(
"Use of 'completion_trigger' on Windows based operating systems is unsupported "
"due to function pickling restrictions for multiprocessing"
)

if isinstance(executable, pathlib.Path) and not executable.is_file():
raise FileNotFoundError(f"Executable '{executable}' is not a valid file")

Expand Down
4 changes: 1 addition & 3 deletions tests/functional/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ def completion_callback(*_, trigger=trigger, **__):


@pytest.mark.executor
@pytest.mark.unix
def test_executor_multiprocess(request: pytest.FixtureRequest) -> None:
triggers: dict[int, multiprocessing.synchronize.Event] = {}
triggers: dict[int, threading.Event] = {}
callbacks: dict[int, typing.Callable] = {}
events: dict[int, bool] = {}
folder_id = f"{uuid.uuid4()}".split("-")[0]
Expand Down Expand Up @@ -180,7 +179,6 @@ def completion_callback(*_, success: dict[str, bool]=success, **__):
folder.delete(recursive=True, delete_runs=True)

@pytest.mark.executor
@pytest.mark.unix
def test_completion_trigger_set(request: pytest.FixtureRequest) -> None:
trigger = threading.Event()
folder_id = f"{uuid.uuid4()}".split("-")[0]
Expand Down
Loading