runem 0.2.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.4.0
runem/blocking_print.py CHANGED
@@ -1,6 +1,40 @@
1
1
  import time
2
2
  import typing
3
3
 
4
+ from rich.console import Console
5
+
6
+
7
+ def _reset_console() -> Console:
8
+ """Sets the nice user-facing console.
9
+
10
+ This function exists so we can reset the output from tests.
11
+ """
12
+ global RICH_CONSOLE # pylint: disable=global-statement
13
+
14
+ RICH_CONSOLE = Console(
15
+ log_path=False, # Do NOT print the source path.
16
+ markup=False, # Do NOT print markup e.g. `[blink]Don't Panic![/blink]`.
17
+ )
18
+ return RICH_CONSOLE
19
+
20
+
21
+ # Overridden in tests.
22
+ RICH_CONSOLE: Console = _reset_console()
23
+
24
+
25
+ def _reset_console_for_tests() -> None:
26
+ """Overrides the console output with more deterministic version.
27
+
28
+ ... so we can have deterministic tests.
29
+ """
30
+ global RICH_CONSOLE # pylint: disable=global-statement
31
+ RICH_CONSOLE = Console(
32
+ log_path=False, # Do NOT print the source path.
33
+ log_time=False, # Do not prefix with log time e.g. `[time] log message`.
34
+ markup=False, # Do NOT print markup e.g. `[blink]Don't Panic![/blink]`.
35
+ width=999, # A very wide width.
36
+ )
37
+
4
38
 
5
39
  def blocking_print(
6
40
  msg: str = "",
@@ -15,9 +49,11 @@ def blocking_print(
15
49
  already being written to (for example), i.e. the `print` would need to be a
16
50
  'blocking' call, which it is not.
17
51
  """
52
+ if end is None:
53
+ end = "\n"
18
54
  for _ in range(max_retries):
19
55
  try:
20
- print(msg, end=end)
56
+ RICH_CONSOLE.print(msg, end=end)
21
57
  break # Success, exit the retry loop
22
58
  except BlockingIOError:
23
59
  time.sleep(sleep_time_s) # Wait a bit for the buffer to clear
runem/job.py CHANGED
@@ -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.
runem/runem.py CHANGED
@@ -36,6 +36,7 @@ from rich.console import Console, ConsoleOptions, ConsoleRenderable, RenderResul
36
36
  from rich.spinner import Spinner
37
37
  from rich.text import Text
38
38
 
39
+ from runem.blocking_print import RICH_CONSOLE
39
40
  from runem.command_line import parse_args
40
41
  from runem.config import load_project_config, load_user_configs
41
42
  from runem.config_metadata import ConfigMetadata
@@ -57,8 +58,6 @@ from runem.types.types_jobs import (
57
58
  )
58
59
  from runem.utils import printable_set
59
60
 
60
- rich_console = Console()
61
-
62
61
 
63
62
  def _determine_run_parameters(argv: typing.List[str]) -> ConfigMetadata:
64
63
  """Loads config, parsing cli input and produces the run config.
@@ -143,7 +142,7 @@ def _update_progress(
143
142
 
144
143
  last_running_jobs_set: typing.Set[str] = set()
145
144
 
146
- with rich_console.status(spinner):
145
+ with RICH_CONSOLE.status(spinner):
147
146
  while is_running.value:
148
147
  running_jobs_set: typing.Set[str] = set(running_jobs.values())
149
148
 
@@ -157,7 +156,7 @@ def _update_progress(
157
156
  spinner.text = report
158
157
  else:
159
158
  if last_running_jobs_set != running_jobs_set:
160
- rich_console.log(report)
159
+ RICH_CONSOLE.log(report)
161
160
 
162
161
  # Sleep for reduced CPU usage
163
162
  time.sleep(0.1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: runem
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Awesome runem created by lursight
5
5
  Home-page: https://github.com/lursight/runem/
6
6
  Author: lursight
@@ -1,8 +1,8 @@
1
- runem/VERSION,sha256=H5MN0fEzwfl6lP46y42zQ3LPTAH_2ys_9Mpy-UlBIek,6
1
+ runem/VERSION,sha256=QLjrQACpE6d5EJBTXykdPTaYdBYqie88nj1OiHobnnk,6
2
2
  runem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  runem/__main__.py,sha256=dsOiVZegpfK9JOs5n7UmbX5iwwbj7iFkEbLoVeEgAn4,136
4
4
  runem/base.py,sha256=EZfR7FIlwEdU9Vfe47Wk2DOO8GQqpKxxLNKp6YHueZ4,316
5
- runem/blocking_print.py,sha256=S9dtgAeuTzc2-ht-vk9Wl6l-0PwS2tYbHDHDQQitrlA,841
5
+ runem/blocking_print.py,sha256=R3c3HSnRMPCf7ykDXdKG2hKH4CzbBaxmOfP3xEU_wEI,1919
6
6
  runem/cli.py,sha256=wEt_Jnumhl8SiOdKdSJzLkJpWv6n3_Odhi_HeIixr1k,134
7
7
  runem/command_line.py,sha256=HsZjxJsVQZLfAeSRI6cpx6P1foeuqCYhHmeQ8Xg9RHY,13774
8
8
  runem/config.py,sha256=UiEU0Jyg5qjrNStvasWYjMOABQHhpZjbPiX3-sH_CMg,5969
@@ -11,17 +11,17 @@ runem/config_parse.py,sha256=sXPMA8HSUcaJoq0dUfphK181waZqnIrq20mpYOQ_XCo,13498
11
11
  runem/files.py,sha256=59boeFvUANYOS-PllIjeKIht6lNINZ43WxahDg90oAc,4392
12
12
  runem/hook_manager.py,sha256=H0TL3HCqU2mgKm_-dgCD7TsK5T1bLT4g7x6kpytMPhU,4350
13
13
  runem/informative_dict.py,sha256=U7p9z78UwOT4TAfng1iDXCEyeYz6C-XZlx9Z1pWNVrI,1548
14
- runem/job.py,sha256=LmNXDHxDxAwyJxAAdPHIv_0bwZy2btyTPHPGO_N7euI,2986
14
+ runem/job.py,sha256=NOdRQnGePPyYdmIR_6JKVFzp9nbgNGetpE13bHEHaf4,3442
15
15
  runem/job_execute.py,sha256=BPkeTpeTGJs3QWa0-07DZvF1f0uKO79e4yMsTxq1UHk,4656
16
16
  runem/job_filter.py,sha256=7vgG4YWJ9gyGBFjV7QbSojG5ofYoszAmxXx9HnMLkHo,5384
17
- runem/job_runner_simple_command.py,sha256=RcM6tfw3i_idgv77MSVmoxGXIF2VfngGOYHOKiuJvX4,1625
17
+ runem/job_runner_simple_command.py,sha256=iP5an6yixW8o4C0ZBtu6csb-oVK3Q62ZZgtHBmxlXaU,2428
18
18
  runem/job_wrapper.py,sha256=q5GtopZ5vhSJ581rwU4-lF9KnbL3ZYgOC8fqaCnXD_g,983
19
19
  runem/job_wrapper_python.py,sha256=rx7J_N-JXs8GgMq7Sla7B9s_ZAfofKUhEnzgMcq_bts,4303
20
20
  runem/log.py,sha256=dIrocigvIJs1ZGkAzTogXkAK-0ZW3q5FkjpDgLdeW-E,630
21
21
  runem/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  runem/report.py,sha256=IedwW9mmJfGC6vKQdKDHQH5eoiYzTWHaaD4a3J4e_Pc,9020
23
23
  runem/run_command.py,sha256=Egl_j4bJ9mwi2JEFCsl0W6WH2IRgIdpMN7qdj8voClQ,6386
24
- runem/runem.py,sha256=QbJU48zx1hyiRIG5Kf4DAa4Kka2dOKYgqlZ1T6fN62k,13316
24
+ runem/runem.py,sha256=tQg-4e--GmIBJrX3gP8dAUGQTCP6QOPiSSGwKxVmBac,13336
25
25
  runem/runem_version.py,sha256=MbETwZO2Tb1Y3hX_OYZjKepEMKA1cjNvr-7Cqhz6e3s,271
26
26
  runem/utils.py,sha256=3N_kel9LsriiMq7kOjT14XhfxUOgz4hdDg97wlLKm3U,221
27
27
  runem/types/__init__.py,sha256=6TzF4KV9tDGuDTr2qAXmWWkfDU52WuVlQ8Hcz48aYDk,286
@@ -34,9 +34,9 @@ runem/types/runem_config.py,sha256=qG_bghm5Nr-ZTbaZbf1v8Fx447V-hgEvvRy5NZ3t-Io,5
34
34
  runem/types/types_jobs.py,sha256=wqiiBmRIJDbGlKcfOqewHGKx350w0p4_7pysMm7xGmo,4906
35
35
  tests/test_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  tests/test_types/test_public_api.py,sha256=QHiwt7CetQur65JSbFRnOzQxhCJkX5MVLymHHVd_6yc,160
37
- runem-0.2.0.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
38
- runem-0.2.0.dist-info/METADATA,sha256=g7u9feZjpdo9L3U8hWqYIhSx3_6K1514AL_Nxyk_gkk,5842
39
- runem-0.2.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
40
- runem-0.2.0.dist-info/entry_points.txt,sha256=nu0g_vBeuPihYtimbtlNusxWovylMppvJ8UxdJlJfvM,46
41
- runem-0.2.0.dist-info/top_level.txt,sha256=Zu65aVeDPh8WbChU4Mi7-Md4S3XJDPuqdQjEE3DSQno,12
42
- runem-0.2.0.dist-info/RECORD,,
37
+ runem-0.4.0.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
38
+ runem-0.4.0.dist-info/METADATA,sha256=EaVqmVWBeMkJI4tLfI7Nt0A5L3i_OkGCtD_Y8zTJ9kY,5842
39
+ runem-0.4.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
40
+ runem-0.4.0.dist-info/entry_points.txt,sha256=nu0g_vBeuPihYtimbtlNusxWovylMppvJ8UxdJlJfvM,46
41
+ runem-0.4.0.dist-info/top_level.txt,sha256=Zu65aVeDPh8WbChU4Mi7-Md4S3XJDPuqdQjEE3DSQno,12
42
+ runem-0.4.0.dist-info/RECORD,,
File without changes
File without changes