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

JobQueue reimplemented in Python #6579

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
21a8e82
Proof of concept for python-statemachine.
berland Nov 7, 2023
7a715dd
Fix ensemble_experiment for LSF driver
berland Nov 16, 2023
590ddc2
Move QueueableRealization and RealizationState into its own file
xjules Nov 16, 2023
846ed43
Blacken and purge dead code
berland Nov 16, 2023
3d93b90
wip
xjules Nov 16, 2023
81354d9
Make realization_state as local import
xjules Nov 16, 2023
9a0d60c
Enable MAX_RUNNING option
xjules Nov 16, 2023
d6cd30b
Implement MAX_RUNTIME support
berland Nov 16, 2023
91e645e
Add python-statemachine to dependencies
xjules Nov 17, 2023
b87e33c
Remove job_queue C-version
berland Nov 16, 2023
8abad6a
Fix incorrect join
JHolba Nov 19, 2023
1a7dd9e
Rename _ variable
JHolba Nov 17, 2023
9098ddd
Fixed some small linter/type issues
JHolba Nov 17, 2023
c3fd6aa
Fix three first test_job_queue tests
berland Nov 20, 2023
f9811a9
Fix simulation_context
xjules Nov 17, 2023
76b8f4e
Rem getNum* functions while poking queue directly
xjules Nov 20, 2023
34c0825
Fix max_running counting
xjules Nov 20, 2023
49c791e
Rename real_state -> realization_state
xjules Nov 20, 2023
9162de6
Ruff --fix test_job_queue
xjules Nov 20, 2023
46f0ea8
Remove JobStatus
xjules Nov 21, 2023
e9f0149
Add support for SUBMIT_SLEEP
berland Nov 20, 2023
8e94c28
Add tests for max_runtime and max_submit
berland Nov 21, 2023
01d351f
Fix some typing
JHolba Nov 21, 2023
83db7f0
Expose job_queue as property in simulation_context
xjules Nov 21, 2023
6669602
Typing src/ert/job_queue
berland Nov 21, 2023
9a5c5e9
Fix simulator tests by using the correct queue API
xjules Nov 21, 2023
b4f2714
Rename internal functions and attributes on state change
berland Nov 21, 2023
0e1756e
Run done_callback from queue (blocking the queue asyncio loop)
berland Nov 22, 2023
f1a23a0
Make the ensemble evaluator tests work
berland Nov 22, 2023
f13f36e
Avoid job_runner killing ERT in local queue
berland Nov 23, 2023
a767ad9
Make run_done_callback async
berland Nov 23, 2023
67346fb
Import ert.realization_state as RealizationStorageState and fix Reali…
xjules Nov 23, 2023
0896a3a
Move away non-ported tests in job_queue
berland Nov 24, 2023
12e8ca1
Make test code more robust
berland Nov 23, 2023
82ccc29
Report stderr from realization the same way as c-code did
berland Nov 23, 2023
93c134d
Fix regression from async forward_model
berland Nov 23, 2023
faeb566
Yet another async regression to fix
berland Nov 24, 2023
f0f6297
Simplify in config_dict_generator
berland Nov 24, 2023
26d1f94
Fix bug with submit_sleep and empty string value
berland Nov 24, 2023
034830c
Fix RealizationState vs RealizationStorageState imports and usage
xjules Nov 24, 2023
e36cf78
Remove unused forward_mock
xjules Nov 24, 2023
8af6697
Use the correct stop_long_running_realizations function
xjules Nov 24, 2023
3416a71
Type: ignore when calling queue.execute
xjules Nov 24, 2023
3ed58b5
Add types-lxml as type dependency
xjules Nov 24, 2023
9013827
Disable tests that do not currently work
JHolba Nov 24, 2023
e0c871b
Fix bugs uncovered in simulation context
berland Nov 24, 2023
7565ab1
Add exception handling python lsf driver
jonathan-eq Nov 22, 2023
3d12038
Fix some typing
berland Nov 27, 2023
eed4b09
Remove tests for the C version of JobQueue
JHolba Nov 24, 2023
c784970
Reactivate now-working tests
berland Nov 24, 2023
6b72074
Refactor logging from EXIT file and solve mypy
berland Nov 24, 2023
ad5bb9d
Reactivate tests
berland Nov 28, 2023
a87339f
Move lsf test to lsf test file
berland Nov 28, 2023
ff3a55b
Rename JobQueue to Scheduler and move job_queue module to scheduler m…
xjules Nov 28, 2023
1ffd987
Fix the correct xml form for stderr in file_reporter
xjules Nov 28, 2023
52be803
Remove stderr prefix from error message
xjules Nov 28, 2023
c58f882
Black test_queue_config
xjules Nov 28, 2023
7ca2177
Rename mocking queue functions with scheduler
xjules Nov 28, 2023
bf77835
Fix test_simulation_context
berland Nov 29, 2023
a69d92b
Activate tests in test_batch_sim
berland Nov 29, 2023
070e8d5
Implement run_exit_callback in disguise.
berland Nov 28, 2023
ae1c110
Simplify JobQueue Driver options
pinkwah Nov 27, 2023
1d3d3d4
Remove irrelevant queue_config tests
berland Nov 29, 2023
83e15a6
Remove test_driver, superfluous
berland Nov 29, 2023
f49e93f
Move tests/unit_tests/job_queue to tests/unit_tests/scheduler
berland Nov 29, 2023
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
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,8 @@ ignore_missing_imports = True
[mypy-ruamel]
ignore_missing_imports = True

[mypy-statemachine]
ignore_missing_imports = True

[mypy-ert.callbacks]
ignore_errors = True
16 changes: 10 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,23 @@ dependencies=[
"typing_extensions",
"jinja2",
"lark",
"lxml",
"matplotlib",
"numpy<2",
"PyQt5",
"packaging",
"pandas",
"pluggy>=1.3.0",
"psutil",
"pydantic >= 1.10.8, < 2",
"PyQt5",
"python-dateutil",
"python-statemachine",
"pyyaml",
"qtpy",
"requests",
"resfo",
"scipy >= 1.10.1",
"python-statemachine",
"uvicorn >= 0.17.0",
"websockets",
"httpx",
Expand Down Expand Up @@ -131,6 +134,7 @@ types = [
"types-decorator",
"types-docutils",
"types-tqdm",
"types-lxml",
]

[tool.setuptools]
Expand Down Expand Up @@ -161,7 +165,7 @@ write_to = "src/ert/shared/version.py"
src = ["src"]
select = [
"W", # pycodestyle
"I", # isort
"I", # isort
"B", # flake-8-bugbear
"SIM", # flake-8-simplify
"F", # pyflakes
Expand All @@ -170,15 +174,15 @@ select = [
line-length = 88
ignore = ["PLW2901", # redefined-loop-name
"PLR2004", # magic-value-comparison
"PLR0915", # too-many-statements
"PLR0912", # too-many-branches
"PLR5501", # collapsible-else-if
"PLR0915", # too-many-statements
"PLR0912", # too-many-branches
"PLR5501", # collapsible-else-if
"PLR0911", # too-many-return-statements
]

[tool.ruff.extend-per-file-ignores]
"tests/*" = [
"F401", # unused-import,
"F401", # unused-import,
"PLW0603" # global-statement
]

Expand Down
3 changes: 2 additions & 1 deletion src/_ert_job_runner/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def ensure_file_handles_closed():
f"Most likely you are missing and should add "
f"'#!/usr/bin/env python' to the top of the file: "
)
stderr.write(msg)
if stderr is not None:
stderr.write(msg)
ensure_file_handles_closed()
yield Exited(self, e.errno).with_error(msg)
return
Expand Down
19 changes: 13 additions & 6 deletions src/_ert_job_runner/reporting/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ def _add_log_line(self, job):
time_str = time.strftime(TIME_FORMAT, time.localtime())
f.write(f"{time_str} Calling: {job.job_data['executable']} {args}\n")

# This file will be read by the job_queue_node_fscanf_EXIT() function
# in job_queue.c. Be very careful with changes in output format.
def _dump_error_file(self, job, error_msg):
with append(ERROR_file) as file:
file.write("<error>\n")
Expand All @@ -176,13 +174,22 @@ def _dump_error_file(self, job, error_msg):
if stderr:
stderr_file = os.path.join(os.getcwd(), job.std_err)
else:
stderr = f"<Not written by:{job.name()}>\n"
stderr = f"Not written by:{job.name()}"
else:
stderr = f"<stderr: Could not find file:{job.std_err}>\n"
stderr = f"Could not find file:{job.std_err}"
else:
stderr = "<stderr: Not redirected>\n"
stderr = "Not redirected"

# Escape XML characters
stderr = (
stderr.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace('"', "&quot;")
.replace("'", "&apos;")
)

file.write(f" <stderr>\n{stderr}</stderr>\n")
file.write(f" <stderr>{stderr}</stderr>\n")
if stderr_file:
file.write(f" <stderr_file>{stderr_file}</stderr_file>\n")

Expand Down
2 changes: 1 addition & 1 deletion src/clib/cmake/libres-config-version.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(PACKAGE_VERSION_MINOR @ERT_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @ERT_VERSION_MICRO@)

set(libres_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
set(libres_LIBRARIES -lenkf -lsched -lrms -lconfig -lanalysis -ljob_queue)
set(libres_LIBRARIES -lenkf -lsched -lrms -lconfig -lanalysis)
link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ )
include_directories( @CMAKE_INSTALL_PREFIX@/include )

Expand Down
2 changes: 1 addition & 1 deletion src/clib/cmake/libres-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(libres_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
set(libres_LIBRARIES -lenkf -lsched -lrms -lconfig -lanalysis -ljob_queue)
set(libres_LIBRARIES -lenkf -lsched -lrms -lconfig -lanalysis)

link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ )
include_directories( @CMAKE_INSTALL_PREFIX@/include )
Expand Down
16 changes: 0 additions & 16 deletions src/clib/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ pybind11_add_module(
SHARED
python/init.cpp
python/logging.cpp
job_queue/job_list.cpp
job_queue/job_node.cpp
job_queue/job_queue.cpp
job_queue/local_driver.cpp
job_queue/lsf_driver.cpp
job_queue/queue_driver.cpp
job_queue/slurm_driver.cpp
job_queue/torque_driver.cpp
job_queue/spawn.cpp
enkf/enkf_obs.cpp
enkf/read_summary.cpp
enkf/row_scaling.cpp)
Expand All @@ -28,13 +19,6 @@ target_include_directories(_clib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
set_target_properties(_clib PROPERTIES CXX_VISIBILITY_PRESET "default")
install(TARGETS _clib LIBRARY DESTINATION src/ert)

# This extra deploy is only for ctest to be able to locate the script, this file
# is otherwise deployed through setup.py.
file(
COPY "${CMAKE_CURRENT_SOURCE_DIR}/../../ert/job_queue/qstat_proxy.sh"
DESTINATION "${CMAKE_BINARY_DIR}/tests"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)

# -----------------------------------------------------------------
# Target: 'libert.so' for use in tests
# -----------------------------------------------------------------
Expand Down
14 changes: 0 additions & 14 deletions src/clib/lib/include/ert/job_queue/job_list.hpp

This file was deleted.

64 changes: 0 additions & 64 deletions src/clib/lib/include/ert/job_queue/job_node.hpp

This file was deleted.

12 changes: 0 additions & 12 deletions src/clib/lib/include/ert/job_queue/job_queue.hpp

This file was deleted.

126 changes: 0 additions & 126 deletions src/clib/lib/include/ert/job_queue/job_status.hpp

This file was deleted.

Loading