runem 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {runem-0.1.2 → runem-0.2.0}/HISTORY.md +27 -0
- {runem-0.1.2 → runem-0.2.0}/PKG-INFO +1 -1
- runem-0.2.0/runem/VERSION +1 -0
- runem-0.2.0/runem/job_runner_simple_command.py +46 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/PKG-INFO +1 -1
- runem-0.2.0/tests/test_job_runner_simple_command.py +99 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_runem.py +2 -2
- runem-0.1.2/runem/VERSION +0 -1
- runem-0.1.2/runem/job_runner_simple_command.py +0 -32
- runem-0.1.2/tests/test_job_runner_simple_command.py +0 -39
- {runem-0.1.2 → runem-0.2.0}/Containerfile +0 -0
- {runem-0.1.2 → runem-0.2.0}/LICENSE +0 -0
- {runem-0.1.2 → runem-0.2.0}/MANIFEST.in +0 -0
- {runem-0.1.2 → runem-0.2.0}/README.md +0 -0
- {runem-0.1.2 → runem-0.2.0}/requirements-test.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/requirements.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/__init__.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/__main__.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/base.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/blocking_print.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/cli/initialise_options.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/cli.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/command_line.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/config.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/config_metadata.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/config_parse.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/files.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/hook_manager.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/informative_dict.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/job.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/job_execute.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/job_filter.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/job_wrapper.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/job_wrapper_python.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/log.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/py.typed +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/report.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/run_command.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/runem.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/runem_version.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/__init__.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/common.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/errors.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/filters.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/hooks.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/options.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/runem_config.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/types/types_jobs.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem/utils.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/SOURCES.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/dependency_links.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/entry_points.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/requires.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/runem.egg-info/top_level.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/setup.cfg +0 -0
- {runem-0.1.2 → runem-0.2.0}/setup.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/__init__.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/cli/test_initialise_options.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/conftest.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/data/help_output.3.10.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/data/help_output.3.11.txt +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/intentional_test_error.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/sanitise_reports_footer.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_base.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_blocking_print.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_cli.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_config.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_config_parse.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_files.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_hook_manager.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_informative_dict.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_job.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_job_execute.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_job_filter.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_job_wrapper.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_job_wrapper_python.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_report.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_run_command.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_types/__init__.py +0 -0
- {runem-0.1.2 → runem-0.2.0}/tests/test_types/test_public_api.py +0 -0
@@ -4,6 +4,33 @@ Changelog
|
|
4
4
|
|
5
5
|
(unreleased)
|
6
6
|
------------
|
7
|
+
- Merge pull request #63 from
|
8
|
+
lursight/dependabot/github_actions/actions/cache-4. [Frank Harrison]
|
9
|
+
|
10
|
+
chore(deps): bump actions/cache from 3 to 4
|
11
|
+
- Chore(deps): bump actions/cache from 3 to 4. [dependabot[bot]]
|
12
|
+
|
13
|
+
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
|
14
|
+
- [Release notes](https://github.com/actions/cache/releases)
|
15
|
+
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
|
16
|
+
- [Commits](https://github.com/actions/cache/compare/v3...v4)
|
17
|
+
|
18
|
+
---
|
19
|
+
updated-dependencies:
|
20
|
+
- dependency-name: actions/cache
|
21
|
+
dependency-type: direct:production
|
22
|
+
update-type: version-update:semver-major
|
23
|
+
...
|
24
|
+
- Feat(simple-files): adds ability to pass file-lists to simple-
|
25
|
+
commands. [Frank Harrison]
|
26
|
+
- Feat(simple-files): strongly types the simple job executor. [Frank
|
27
|
+
Harrison]
|
28
|
+
- Feat(simple-files): fixes docstring. [Frank Harrison]
|
29
|
+
|
30
|
+
|
31
|
+
0.1.2 (2024-11-18)
|
32
|
+
------------------
|
33
|
+
- Release: version 0.1.2 🚀 [Frank Harrison]
|
7
34
|
- Chore(actions): simplifies code paths for actions. [Frank Harrison]
|
8
35
|
- Chore(contrib): removes the Makefile commands that have been removed.
|
9
36
|
[Frank Harrison]
|
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import shlex
|
2
|
+
import typing
|
3
|
+
|
4
|
+
from typing_extensions import Unpack
|
5
|
+
|
6
|
+
from runem.run_command import run_command
|
7
|
+
from runem.types.common import FilePathList
|
8
|
+
from runem.types.runem_config import JobConfig
|
9
|
+
from runem.types.types_jobs import AllKwargs
|
10
|
+
|
11
|
+
|
12
|
+
def validate_simple_command(command_string: str) -> typing.List[str]:
|
13
|
+
"""Use shlex to handle parsing of the command string, a non-trivial problem."""
|
14
|
+
split_command: typing.List[str] = shlex.split(command_string)
|
15
|
+
return split_command
|
16
|
+
|
17
|
+
|
18
|
+
def job_runner_simple_command(
|
19
|
+
**kwargs: Unpack[AllKwargs],
|
20
|
+
) -> None:
|
21
|
+
"""Parses the command and tries to run it via the system.
|
22
|
+
|
23
|
+
Commands inherit the environment.
|
24
|
+
"""
|
25
|
+
# assume we have the job.command entry, allowing KeyError to propagate up
|
26
|
+
job_config: JobConfig = kwargs["job"]
|
27
|
+
command_string: str = job_config["command"]
|
28
|
+
|
29
|
+
command_string_files: str = command_string
|
30
|
+
if "{file_list}" in command_string:
|
31
|
+
file_list: FilePathList = kwargs["file_list"]
|
32
|
+
file_list_with_quotes: typing.List[str] = [
|
33
|
+
f'"{str(file_path)}"' for file_path in file_list
|
34
|
+
]
|
35
|
+
command_string_files = command_string.replace(
|
36
|
+
"{file_list}", " ".join(file_list_with_quotes)
|
37
|
+
)
|
38
|
+
|
39
|
+
# use shlex to handle parsing of the command string, a non-trivial problem.
|
40
|
+
cmd = validate_simple_command(command_string_files)
|
41
|
+
|
42
|
+
# preserve quotes for consistent handling of strings and avoid the "word
|
43
|
+
# splitting" problem for unix-like shells.
|
44
|
+
cmd_with_quotes = [f'"{token}"' if " " in token else token for token in cmd]
|
45
|
+
|
46
|
+
run_command(cmd=cmd_with_quotes, **kwargs)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import io
|
2
|
+
import typing
|
3
|
+
from contextlib import redirect_stdout
|
4
|
+
from pathlib import Path
|
5
|
+
from unittest.mock import Mock, patch
|
6
|
+
|
7
|
+
from runem.config_metadata import ConfigMetadata
|
8
|
+
from runem.job import Job
|
9
|
+
from runem.job_runner_simple_command import job_runner_simple_command
|
10
|
+
from runem.types.runem_config import JobConfig
|
11
|
+
from tests.test_runem import gen_dummy_config_metadata
|
12
|
+
|
13
|
+
|
14
|
+
@patch(
|
15
|
+
"runem.job_runner_simple_command.run_command",
|
16
|
+
# return_value=None,
|
17
|
+
)
|
18
|
+
def test_job_runner_simple_command(mock_run_command: Mock) -> None:
|
19
|
+
"""Tests the basics of job_runner_simple_command."""
|
20
|
+
job_config: JobConfig = {
|
21
|
+
"command": "echo 'testing job_runner_simple_command'",
|
22
|
+
}
|
23
|
+
config_metadata: ConfigMetadata = gen_dummy_config_metadata()
|
24
|
+
with io.StringIO() as buf, redirect_stdout(buf):
|
25
|
+
ret: None = job_runner_simple_command( # type: ignore[func-returns-value]
|
26
|
+
options=config_metadata.options, # type: ignore
|
27
|
+
file_list=[],
|
28
|
+
procs=config_metadata.args.procs,
|
29
|
+
root_path=Path("."),
|
30
|
+
verbose=True, # config_metadata.args.verbose,
|
31
|
+
# unpack useful data points from the job_config
|
32
|
+
label=Job.get_job_name(job_config),
|
33
|
+
job=job_config,
|
34
|
+
)
|
35
|
+
run_command_stdout = buf.getvalue()
|
36
|
+
|
37
|
+
assert ret is None
|
38
|
+
assert run_command_stdout.split("\n") == [""]
|
39
|
+
mock_run_command.assert_called_once_with(
|
40
|
+
cmd=["echo", '"testing job_runner_simple_command"'],
|
41
|
+
file_list=[],
|
42
|
+
job={"command": "echo 'testing job_runner_simple_command'"},
|
43
|
+
label="echo 'testing job_runner_simple_command'",
|
44
|
+
options={},
|
45
|
+
procs=1,
|
46
|
+
root_path=Path("."),
|
47
|
+
verbose=True,
|
48
|
+
)
|
49
|
+
|
50
|
+
|
51
|
+
@patch(
|
52
|
+
"runem.job_runner_simple_command.run_command",
|
53
|
+
# return_value=None,
|
54
|
+
)
|
55
|
+
def test_job_runner_simple_command_with_file_list(mock_run_command: Mock) -> None:
|
56
|
+
"""Tests the basics of job_runner_simple_command."""
|
57
|
+
test_cmd_string: str = (
|
58
|
+
'echo "some option before files" {file_list} "some option after files"'
|
59
|
+
)
|
60
|
+
job_config: JobConfig = {
|
61
|
+
"command": test_cmd_string,
|
62
|
+
}
|
63
|
+
config_metadata: ConfigMetadata = gen_dummy_config_metadata()
|
64
|
+
file_list: typing.List[typing.Union[str, Path]] = [
|
65
|
+
Path("file1"),
|
66
|
+
"file2",
|
67
|
+
"file with spaces",
|
68
|
+
]
|
69
|
+
with io.StringIO() as buf, redirect_stdout(buf):
|
70
|
+
ret: None = job_runner_simple_command( # type: ignore[func-returns-value]
|
71
|
+
file_list=file_list, # type: ignore[arg-type] # intentional type mismatch
|
72
|
+
job=job_config,
|
73
|
+
label=Job.get_job_name(job_config),
|
74
|
+
options=config_metadata.options, # type: ignore
|
75
|
+
procs=config_metadata.args.procs,
|
76
|
+
root_path=Path("."),
|
77
|
+
verbose=True, # config_metadata.args.verbose,
|
78
|
+
)
|
79
|
+
run_command_stdout = buf.getvalue()
|
80
|
+
|
81
|
+
assert ret is None
|
82
|
+
assert run_command_stdout.split("\n") == [""]
|
83
|
+
mock_run_command.assert_called_once_with(
|
84
|
+
cmd=[
|
85
|
+
"echo",
|
86
|
+
'"some option before files"',
|
87
|
+
"file1",
|
88
|
+
"file2",
|
89
|
+
'"file with spaces"',
|
90
|
+
'"some option after files"',
|
91
|
+
],
|
92
|
+
file_list=file_list,
|
93
|
+
job=job_config,
|
94
|
+
label=test_cmd_string,
|
95
|
+
options={},
|
96
|
+
procs=1,
|
97
|
+
root_path=Path("."),
|
98
|
+
verbose=True,
|
99
|
+
)
|
@@ -1780,7 +1780,7 @@ def test_progress_updater_with_false(show_spinner: bool) -> None:
|
|
1780
1780
|
)
|
1781
1781
|
|
1782
1782
|
|
1783
|
-
def
|
1783
|
+
def gen_dummy_config_metadata() -> ConfigMetadata:
|
1784
1784
|
config_metadata: ConfigMetadata = ConfigMetadata(
|
1785
1785
|
cfg_filepath=pathlib.Path(__file__),
|
1786
1786
|
phases=("dummy phase 1",),
|
@@ -1809,7 +1809,7 @@ def _dummy_config_metadata() -> ConfigMetadata:
|
|
1809
1809
|
|
1810
1810
|
|
1811
1811
|
DUMMY_MAIN_RETURN: MainReturnType = (
|
1812
|
-
|
1812
|
+
gen_dummy_config_metadata(), # ConfigMetadata,
|
1813
1813
|
{}, # job_run_metadatas,
|
1814
1814
|
IntentionalTestError(),
|
1815
1815
|
)
|
runem-0.1.2/runem/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import shlex
|
2
|
-
import typing
|
3
|
-
|
4
|
-
from runem.run_command import run_command
|
5
|
-
from runem.types.runem_config import JobConfig
|
6
|
-
|
7
|
-
|
8
|
-
def validate_simple_command(command_string: str) -> typing.List[str]:
|
9
|
-
# use shlex to handle parsing of the command string, a non-trivial problem.
|
10
|
-
split_command: typing.List[str] = shlex.split(command_string)
|
11
|
-
return split_command
|
12
|
-
|
13
|
-
|
14
|
-
def job_runner_simple_command(
|
15
|
-
**kwargs: typing.Any,
|
16
|
-
) -> None:
|
17
|
-
"""Parses the command and tries to run it via the system.
|
18
|
-
|
19
|
-
Commands inherit the environment.
|
20
|
-
"""
|
21
|
-
# assume we have the job.command entry, allowing KeyError to propagate up
|
22
|
-
job_config: JobConfig = kwargs["job"]
|
23
|
-
command_string: str = job_config["command"]
|
24
|
-
|
25
|
-
# use shlex to handle parsing of the command string, a non-trivial problem.
|
26
|
-
result = validate_simple_command(command_string)
|
27
|
-
|
28
|
-
# preserve quotes for consistent handling of strings and avoid the "word
|
29
|
-
# splitting" problem for unix-like shells.
|
30
|
-
result_with_quotes = [f'"{token}"' if " " in token else token for token in result]
|
31
|
-
|
32
|
-
run_command(cmd=result_with_quotes, **kwargs)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import io
|
2
|
-
from contextlib import redirect_stdout
|
3
|
-
from unittest.mock import Mock, patch
|
4
|
-
|
5
|
-
from runem.job import Job
|
6
|
-
from runem.job_runner_simple_command import job_runner_simple_command
|
7
|
-
from runem.types.runem_config import JobConfig
|
8
|
-
|
9
|
-
|
10
|
-
@patch(
|
11
|
-
"runem.job_runner_simple_command.run_command",
|
12
|
-
# return_value=None,
|
13
|
-
)
|
14
|
-
def test_job_runner_simple_command(mock_run_command: Mock) -> None:
|
15
|
-
"""Tests the basics of job_runner_simple_command."""
|
16
|
-
job_config: JobConfig = {
|
17
|
-
"command": "echo 'testing job_runner_simple_command'",
|
18
|
-
}
|
19
|
-
with io.StringIO() as buf, redirect_stdout(buf):
|
20
|
-
ret: None = job_runner_simple_command( # type: ignore[func-returns-value]
|
21
|
-
# options=config_metadata.options, # type: ignore
|
22
|
-
# file_list=file_list,
|
23
|
-
# procs=config_metadata.args.procs,
|
24
|
-
# root_path=root_path,
|
25
|
-
verbose=True, # config_metadata.args.verbose,
|
26
|
-
# unpack useful data points from the job_config
|
27
|
-
label=Job.get_job_name(job_config),
|
28
|
-
job=job_config,
|
29
|
-
)
|
30
|
-
run_command_stdout = buf.getvalue()
|
31
|
-
|
32
|
-
assert ret is None
|
33
|
-
assert run_command_stdout.split("\n") == [""]
|
34
|
-
mock_run_command.assert_called_once_with(
|
35
|
-
cmd=["echo", '"testing job_runner_simple_command"'],
|
36
|
-
verbose=True,
|
37
|
-
label="echo 'testing job_runner_simple_command'",
|
38
|
-
job={"command": "echo 'testing job_runner_simple_command'"},
|
39
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|