runem 0.2.0__tar.gz → 0.3.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.
Files changed (78) hide show
  1. {runem-0.2.0 → runem-0.3.0}/HISTORY.md +23 -0
  2. {runem-0.2.0 → runem-0.3.0}/PKG-INFO +1 -1
  3. runem-0.3.0/runem/VERSION +1 -0
  4. {runem-0.2.0 → runem-0.3.0}/runem/job.py +16 -0
  5. {runem-0.2.0 → runem-0.3.0}/runem/job_runner_simple_command.py +19 -1
  6. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/PKG-INFO +1 -1
  7. {runem-0.2.0 → runem-0.3.0}/tests/test_job.py +19 -1
  8. {runem-0.2.0 → runem-0.3.0}/tests/test_job_runner_simple_command.py +59 -3
  9. {runem-0.2.0 → runem-0.3.0}/tests/test_runem.py +1 -1
  10. runem-0.2.0/runem/VERSION +0 -1
  11. {runem-0.2.0 → runem-0.3.0}/Containerfile +0 -0
  12. {runem-0.2.0 → runem-0.3.0}/LICENSE +0 -0
  13. {runem-0.2.0 → runem-0.3.0}/MANIFEST.in +0 -0
  14. {runem-0.2.0 → runem-0.3.0}/README.md +0 -0
  15. {runem-0.2.0 → runem-0.3.0}/requirements-test.txt +0 -0
  16. {runem-0.2.0 → runem-0.3.0}/requirements.txt +0 -0
  17. {runem-0.2.0 → runem-0.3.0}/runem/__init__.py +0 -0
  18. {runem-0.2.0 → runem-0.3.0}/runem/__main__.py +0 -0
  19. {runem-0.2.0 → runem-0.3.0}/runem/base.py +0 -0
  20. {runem-0.2.0 → runem-0.3.0}/runem/blocking_print.py +0 -0
  21. {runem-0.2.0 → runem-0.3.0}/runem/cli/initialise_options.py +0 -0
  22. {runem-0.2.0 → runem-0.3.0}/runem/cli.py +0 -0
  23. {runem-0.2.0 → runem-0.3.0}/runem/command_line.py +0 -0
  24. {runem-0.2.0 → runem-0.3.0}/runem/config.py +0 -0
  25. {runem-0.2.0 → runem-0.3.0}/runem/config_metadata.py +0 -0
  26. {runem-0.2.0 → runem-0.3.0}/runem/config_parse.py +0 -0
  27. {runem-0.2.0 → runem-0.3.0}/runem/files.py +0 -0
  28. {runem-0.2.0 → runem-0.3.0}/runem/hook_manager.py +0 -0
  29. {runem-0.2.0 → runem-0.3.0}/runem/informative_dict.py +0 -0
  30. {runem-0.2.0 → runem-0.3.0}/runem/job_execute.py +0 -0
  31. {runem-0.2.0 → runem-0.3.0}/runem/job_filter.py +0 -0
  32. {runem-0.2.0 → runem-0.3.0}/runem/job_wrapper.py +0 -0
  33. {runem-0.2.0 → runem-0.3.0}/runem/job_wrapper_python.py +0 -0
  34. {runem-0.2.0 → runem-0.3.0}/runem/log.py +0 -0
  35. {runem-0.2.0 → runem-0.3.0}/runem/py.typed +0 -0
  36. {runem-0.2.0 → runem-0.3.0}/runem/report.py +0 -0
  37. {runem-0.2.0 → runem-0.3.0}/runem/run_command.py +0 -0
  38. {runem-0.2.0 → runem-0.3.0}/runem/runem.py +0 -0
  39. {runem-0.2.0 → runem-0.3.0}/runem/runem_version.py +0 -0
  40. {runem-0.2.0 → runem-0.3.0}/runem/types/__init__.py +0 -0
  41. {runem-0.2.0 → runem-0.3.0}/runem/types/common.py +0 -0
  42. {runem-0.2.0 → runem-0.3.0}/runem/types/errors.py +0 -0
  43. {runem-0.2.0 → runem-0.3.0}/runem/types/filters.py +0 -0
  44. {runem-0.2.0 → runem-0.3.0}/runem/types/hooks.py +0 -0
  45. {runem-0.2.0 → runem-0.3.0}/runem/types/options.py +0 -0
  46. {runem-0.2.0 → runem-0.3.0}/runem/types/runem_config.py +0 -0
  47. {runem-0.2.0 → runem-0.3.0}/runem/types/types_jobs.py +0 -0
  48. {runem-0.2.0 → runem-0.3.0}/runem/utils.py +0 -0
  49. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/SOURCES.txt +0 -0
  50. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/dependency_links.txt +0 -0
  51. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/entry_points.txt +0 -0
  52. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/requires.txt +0 -0
  53. {runem-0.2.0 → runem-0.3.0}/runem.egg-info/top_level.txt +0 -0
  54. {runem-0.2.0 → runem-0.3.0}/setup.cfg +0 -0
  55. {runem-0.2.0 → runem-0.3.0}/setup.py +0 -0
  56. {runem-0.2.0 → runem-0.3.0}/tests/__init__.py +0 -0
  57. {runem-0.2.0 → runem-0.3.0}/tests/cli/test_initialise_options.py +0 -0
  58. {runem-0.2.0 → runem-0.3.0}/tests/conftest.py +0 -0
  59. {runem-0.2.0 → runem-0.3.0}/tests/data/help_output.3.10.txt +0 -0
  60. {runem-0.2.0 → runem-0.3.0}/tests/data/help_output.3.11.txt +0 -0
  61. {runem-0.2.0 → runem-0.3.0}/tests/intentional_test_error.py +0 -0
  62. {runem-0.2.0 → runem-0.3.0}/tests/sanitise_reports_footer.py +0 -0
  63. {runem-0.2.0 → runem-0.3.0}/tests/test_base.py +0 -0
  64. {runem-0.2.0 → runem-0.3.0}/tests/test_blocking_print.py +0 -0
  65. {runem-0.2.0 → runem-0.3.0}/tests/test_cli.py +0 -0
  66. {runem-0.2.0 → runem-0.3.0}/tests/test_config.py +0 -0
  67. {runem-0.2.0 → runem-0.3.0}/tests/test_config_parse.py +0 -0
  68. {runem-0.2.0 → runem-0.3.0}/tests/test_files.py +0 -0
  69. {runem-0.2.0 → runem-0.3.0}/tests/test_hook_manager.py +0 -0
  70. {runem-0.2.0 → runem-0.3.0}/tests/test_informative_dict.py +0 -0
  71. {runem-0.2.0 → runem-0.3.0}/tests/test_job_execute.py +0 -0
  72. {runem-0.2.0 → runem-0.3.0}/tests/test_job_filter.py +0 -0
  73. {runem-0.2.0 → runem-0.3.0}/tests/test_job_wrapper.py +0 -0
  74. {runem-0.2.0 → runem-0.3.0}/tests/test_job_wrapper_python.py +0 -0
  75. {runem-0.2.0 → runem-0.3.0}/tests/test_report.py +0 -0
  76. {runem-0.2.0 → runem-0.3.0}/tests/test_run_command.py +0 -0
  77. {runem-0.2.0 → runem-0.3.0}/tests/test_types/__init__.py +0 -0
  78. {runem-0.2.0 → runem-0.3.0}/tests/test_types/test_public_api.py +0 -0
@@ -4,6 +4,29 @@ Changelog
4
4
 
5
5
  (unreleased)
6
6
  ------------
7
+ - Merge pull request #66 from
8
+ lursight/feat/option_switches_in_simple_commands. [Frank Harrison]
9
+
10
+ Feat/option switches in simple commands
11
+ - Chore(pytest): force colour output in pytest, makes it easier to read.
12
+ [Frank Harrison]
13
+ - Feat(option-switches): adds ability to turn on/off switches in simple
14
+ commands. [Frank Harrison]
15
+
16
+ THis is pretty noddy for now, but it means we can do more things like
17
+ run `black` or `ruff` with `--check` enabled... as well as some other
18
+ switches.
19
+ - Merge pull request #65 from lursight/feat/error_on_misplaced_config.
20
+ [Frank Harrison]
21
+
22
+ feat(where-errors): errors when 'tags' and 'phase' are not under 'where'
23
+ - Feat(where-errors): errors when 'tags' and 'phase' are not under
24
+ 'where' [Frank Harrison]
25
+
26
+
27
+ 0.2.0 (2024-11-21)
28
+ ------------------
29
+ - Release: version 0.2.0 🚀 [Frank Harrison]
7
30
  - Merge pull request #63 from
8
31
  lursight/dependabot/github_actions/actions/cache-4. [Frank Harrison]
9
32
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: runem
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Awesome runem created by lursight
5
5
  Home-page: https://github.com/lursight/runem/
6
6
  Author: lursight
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -11,6 +11,12 @@ class NoJobName(ValueError):
11
11
  pass
12
12
 
13
13
 
14
+ class BadWhenConfigLocation(ValueError):
15
+ """The job-config does not contain a label and can't be coerced to crate one."""
16
+
17
+ pass
18
+
19
+
14
20
  class Job:
15
21
  """A class with utility functions for jobs.
16
22
 
@@ -27,6 +33,16 @@ class Job:
27
33
 
28
34
  TODO: make a non-static member function
29
35
  """
36
+ if "tags" in job:
37
+ raise BadWhenConfigLocation(
38
+ "'tags' should be listed inside the 'when' config for jobs"
39
+ )
40
+
41
+ if "phase" in job:
42
+ raise BadWhenConfigLocation(
43
+ "'phase' should be listed inside the 'when' config for jobs"
44
+ )
45
+
30
46
  if "when" not in job or "tags" not in job["when"]:
31
47
  # handle the special case where we have No tags
32
48
  return None
@@ -3,8 +3,10 @@ import typing
3
3
 
4
4
  from typing_extensions import Unpack
5
5
 
6
+ from runem.config_metadata import ConfigMetadata
6
7
  from runem.run_command import run_command
7
8
  from runem.types.common import FilePathList
9
+ from runem.types.options import OptionsWritable
8
10
  from runem.types.runem_config import JobConfig
9
11
  from runem.types.types_jobs import AllKwargs
10
12
 
@@ -36,8 +38,24 @@ def job_runner_simple_command(
36
38
  "{file_list}", " ".join(file_list_with_quotes)
37
39
  )
38
40
 
41
+ config_metadata: ConfigMetadata = kwargs["config_metadata"]
42
+ options: OptionsWritable = config_metadata.options
43
+ command_string_options: str = command_string_files
44
+ for name, value in options.items():
45
+ # For now, just pass `--option-name`, `--check` or similar to the
46
+ # command line. At some point we will want this to be cleverer, but
47
+ # this will do for now.
48
+ option_search = f"{{{name}}}"
49
+ if option_search in command_string_files:
50
+ replacement = ""
51
+ if value:
52
+ replacement = f"--{name}"
53
+ command_string_options = command_string_options.replace(
54
+ option_search, replacement
55
+ )
56
+
39
57
  # use shlex to handle parsing of the command string, a non-trivial problem.
40
- cmd = validate_simple_command(command_string_files)
58
+ cmd = validate_simple_command(command_string_options)
41
59
 
42
60
  # preserve quotes for consistent handling of strings and avoid the "word
43
61
  # splitting" problem for unix-like shells.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: runem
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Awesome runem created by lursight
5
5
  Home-page: https://github.com/lursight/runem/
6
6
  Author: lursight
@@ -3,7 +3,7 @@ from collections import defaultdict
3
3
 
4
4
  import pytest
5
5
 
6
- from runem.job import Job, NoJobName
6
+ from runem.job import BadWhenConfigLocation, Job, NoJobName
7
7
  from runem.types.common import FilePathList, JobTags
8
8
  from runem.types.filters import FilePathListLookup
9
9
  from runem.types.runem_config import JobConfig
@@ -27,6 +27,24 @@ def test_get_job_tags(
27
27
  assert result == expected_result
28
28
 
29
29
 
30
+ def test_get_job_tags_bad_tags_path() -> None:
31
+ """Tests that the 'tags' entry is on 'when' and not on root."""
32
+ job_config: JobConfig = { # type: ignore[typeddict-unknown-key]
33
+ "tags": ["dummy tags"],
34
+ }
35
+ with pytest.raises(BadWhenConfigLocation):
36
+ Job.get_job_tags(job_config)
37
+
38
+
39
+ def test_get_job_tags_bad_phase_path() -> None:
40
+ """Tests that the 'phase' entry is on 'when' and not on root."""
41
+ job_config: JobConfig = { # type: ignore[typeddict-unknown-key]
42
+ "phase": "dummy tags",
43
+ }
44
+ with pytest.raises(BadWhenConfigLocation):
45
+ Job.get_job_tags(job_config)
46
+
47
+
30
48
  @pytest.fixture(name="file_lists")
31
49
  def file_lists_fixture() -> FilePathListLookup:
32
50
  """Define a sample file_lists dictionary for testing."""
@@ -2,7 +2,7 @@ import io
2
2
  import typing
3
3
  from contextlib import redirect_stdout
4
4
  from pathlib import Path
5
- from unittest.mock import Mock, patch
5
+ from unittest.mock import ANY, Mock, patch
6
6
 
7
7
  from runem.config_metadata import ConfigMetadata
8
8
  from runem.job import Job
@@ -23,6 +23,7 @@ def test_job_runner_simple_command(mock_run_command: Mock) -> None:
23
23
  config_metadata: ConfigMetadata = gen_dummy_config_metadata()
24
24
  with io.StringIO() as buf, redirect_stdout(buf):
25
25
  ret: None = job_runner_simple_command( # type: ignore[func-returns-value]
26
+ config_metadata=config_metadata,
26
27
  options=config_metadata.options, # type: ignore
27
28
  file_list=[],
28
29
  procs=config_metadata.args.procs,
@@ -38,10 +39,11 @@ def test_job_runner_simple_command(mock_run_command: Mock) -> None:
38
39
  assert run_command_stdout.split("\n") == [""]
39
40
  mock_run_command.assert_called_once_with(
40
41
  cmd=["echo", '"testing job_runner_simple_command"'],
42
+ config_metadata=ANY,
41
43
  file_list=[],
42
44
  job={"command": "echo 'testing job_runner_simple_command'"},
43
45
  label="echo 'testing job_runner_simple_command'",
44
- options={},
46
+ options=ANY,
45
47
  procs=1,
46
48
  root_path=Path("."),
47
49
  verbose=True,
@@ -71,6 +73,7 @@ def test_job_runner_simple_command_with_file_list(mock_run_command: Mock) -> Non
71
73
  file_list=file_list, # type: ignore[arg-type] # intentional type mismatch
72
74
  job=job_config,
73
75
  label=Job.get_job_name(job_config),
76
+ config_metadata=config_metadata,
74
77
  options=config_metadata.options, # type: ignore
75
78
  procs=config_metadata.args.procs,
76
79
  root_path=Path("."),
@@ -89,10 +92,63 @@ def test_job_runner_simple_command_with_file_list(mock_run_command: Mock) -> Non
89
92
  '"file with spaces"',
90
93
  '"some option after files"',
91
94
  ],
95
+ config_metadata=ANY,
92
96
  file_list=file_list,
93
97
  job=job_config,
94
98
  label=test_cmd_string,
95
- options={},
99
+ options=ANY,
100
+ procs=1,
101
+ root_path=Path("."),
102
+ verbose=True,
103
+ )
104
+
105
+
106
+ @patch(
107
+ "runem.job_runner_simple_command.run_command",
108
+ # return_value=None,
109
+ )
110
+ def test_job_runner_simple_command_with_option(mock_run_command: Mock) -> None:
111
+ """Tests that option-passing to jobs, pass --option_on but not --option_off."""
112
+ test_cmd_string: str = (
113
+ 'echo "some option before switch" {option_on} {option_off} "some option after switch"'
114
+ )
115
+ job_config: JobConfig = {
116
+ "command": test_cmd_string,
117
+ }
118
+ config_metadata: ConfigMetadata = gen_dummy_config_metadata()
119
+ file_list: typing.List[typing.Union[str, Path]] = [
120
+ Path("file1"),
121
+ "file2",
122
+ "file with spaces",
123
+ ]
124
+ with io.StringIO() as buf, redirect_stdout(buf):
125
+ ret: None = job_runner_simple_command( # type: ignore[func-returns-value]
126
+ file_list=file_list, # type: ignore[arg-type] # intentional type mismatch
127
+ job=job_config,
128
+ label=Job.get_job_name(job_config),
129
+ config_metadata=config_metadata,
130
+ options=config_metadata.options, # type: ignore
131
+ procs=config_metadata.args.procs,
132
+ root_path=Path("."),
133
+ verbose=True, # config_metadata.args.verbose,
134
+ )
135
+ run_command_stdout = buf.getvalue()
136
+
137
+ assert ret is None
138
+ assert run_command_stdout.split("\n") == [""]
139
+ mock_run_command.assert_called_once_with(
140
+ cmd=[
141
+ "echo",
142
+ '"some option before switch"',
143
+ "--option_on",
144
+ # Not this -> "--option_off",
145
+ '"some option after switch"',
146
+ ],
147
+ config_metadata=ANY,
148
+ file_list=file_list,
149
+ job=job_config,
150
+ label=test_cmd_string,
151
+ options={"option_on": True, "option_off": False},
96
152
  procs=1,
97
153
  root_path=Path("."),
98
154
  verbose=True,
@@ -1803,7 +1803,7 @@ def gen_dummy_config_metadata() -> ConfigMetadata:
1803
1803
  phases_to_run=set(), # JobPhases,
1804
1804
  tags_to_run=set(), # ignored JobTags,
1805
1805
  tags_to_avoid=set(), # ignored JobTags,
1806
- options=InformativeDict({}), # Options,
1806
+ options=InformativeDict({"option_on": True, "option_off": False}), # Options,
1807
1807
  )
1808
1808
  return config_metadata
1809
1809
 
runem-0.2.0/runem/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0
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