openjd-cli 0.7.0__tar.gz → 0.7.2__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 (31) hide show
  1. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/PKG-INFO +4 -4
  2. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/README.md +1 -1
  3. {openjd_cli-0.7.0/openjd/cli → openjd_cli-0.7.2}/_version.py +16 -3
  4. openjd_cli-0.7.2/hatch_version_hook.py +156 -0
  5. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/pyproject.toml +6 -12
  6. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_common/__init__.py +2 -1
  7. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_common/_extensions.py +1 -1
  8. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_create_argparser.py +7 -0
  9. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/_local_session/_session_manager.py +8 -0
  10. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/_run_command.py +13 -0
  11. openjd_cli-0.7.2/src/openjd/cli/_version.py +34 -0
  12. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/.gitignore +0 -0
  13. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/LICENSE +0 -0
  14. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/NOTICE +0 -0
  15. {openjd_cli-0.7.0 → openjd_cli-0.7.2}/hatch.toml +0 -0
  16. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/__main__.py +0 -0
  17. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/__init__.py +0 -0
  18. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_check/__init__.py +0 -0
  19. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_check/_check_command.py +0 -0
  20. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_common/_job_from_template.py +0 -0
  21. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_common/_validation_utils.py +0 -0
  22. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/__init__.py +0 -0
  23. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/_local_session/__init__.py +0 -0
  24. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/_local_session/_actions.py +0 -0
  25. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_run/_local_session/_logs.py +0 -0
  26. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_schema/__init__.py +0 -0
  27. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_schema/_schema_command.py +0 -0
  28. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_summary/__init__.py +0 -0
  29. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_summary/_summary_command.py +0 -0
  30. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/_summary/_summary_output.py +0 -0
  31. {openjd_cli-0.7.0 → openjd_cli-0.7.2/src}/openjd/cli/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openjd-cli
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Provides a command-line interface for working with Open Job Description templates.
5
5
  Project-URL: Homepage, https://github.com/OpenJobDescription/openjd-cli
6
6
  Project-URL: Source, https://github.com/OpenJobDescription/openjd-cli
@@ -22,8 +22,8 @@ Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
24
  Requires-Python: >=3.9
25
- Requires-Dist: openjd-model==0.7.*
26
- Requires-Dist: openjd-sessions<0.11,>=0.10.1
25
+ Requires-Dist: openjd-model<0.9,>=0.8
26
+ Requires-Dist: openjd-sessions<0.11,>=0.10.3
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  ## Open Job Description - CLI
@@ -205,7 +205,7 @@ You can download this package from:
205
205
 
206
206
  ### Verifying GitHub Releases
207
207
 
208
- See [VERIFYING_PGP_SIGNATURE](VERIFYING_PGP_SIGNATURE.md) for more information.
208
+ See [Verifying GitHub Releases](https://github.com/OpenJobDescription/openjd-cli?tab=security-ov-file#verifying-github-releases) for more information.
209
209
 
210
210
  ## Security
211
211
 
@@ -177,7 +177,7 @@ You can download this package from:
177
177
 
178
178
  ### Verifying GitHub Releases
179
179
 
180
- See [VERIFYING_PGP_SIGNATURE](VERIFYING_PGP_SIGNATURE.md) for more information.
180
+ See [Verifying GitHub Releases](https://github.com/OpenJobDescription/openjd-cli?tab=security-ov-file#verifying-github-releases) for more information.
181
181
 
182
182
  ## Security
183
183
 
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '0.7.0'
21
- __version_tuple__ = version_tuple = (0, 7, 0)
31
+ __version__ = version = '0.7.2'
32
+ __version_tuple__ = version_tuple = (0, 7, 2)
33
+
34
+ __commit_id__ = commit_id = None
@@ -0,0 +1,156 @@
1
+ import logging
2
+ import os
3
+ import shutil
4
+ import sys
5
+
6
+ from dataclasses import dataclass
7
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
8
+ from typing import Any, Optional
9
+
10
+
11
+ _logger = logging.Logger(__name__, logging.INFO)
12
+ _stdout_handler = logging.StreamHandler(sys.stdout)
13
+ _stdout_handler.addFilter(lambda record: record.levelno <= logging.INFO)
14
+ _stderr_handler = logging.StreamHandler(sys.stderr)
15
+ _stderr_handler.addFilter(lambda record: record.levelno > logging.INFO)
16
+ _logger.addHandler(_stdout_handler)
17
+ _logger.addHandler(_stderr_handler)
18
+
19
+
20
+ @dataclass
21
+ class CopyConfig:
22
+ sources: list[str]
23
+ destinations: list[str]
24
+
25
+
26
+ class CustomBuildHookException(Exception):
27
+ pass
28
+
29
+
30
+ class CustomBuildHook(BuildHookInterface):
31
+ """
32
+ A Hatch build hook that is pulled in automatically by Hatch's "custom" hook support
33
+ See: https://hatch.pypa.io/1.6/plugins/build-hook/custom/
34
+ This build hook copies files from one location (sources) to another (destinations).
35
+ Config options:
36
+ - `log_level (str)`: The logging level. Any value accepted by logging.Logger.setLevel is allowed. Default is INFO.
37
+ - `copy_map (list[dict])`: A list of mappings of files to copy and the destinations to copy them into. In TOML files,
38
+ this is expressed as an array of tables. See https://toml.io/en/v1.0.0#array-of-tables
39
+ Example TOML config:
40
+ ```
41
+ [tool.hatch.build.hooks.custom]
42
+ path = "hatch_hook.py"
43
+ log_level = "DEBUG"
44
+ [[tool.hatch.build.hooks.custom.copy_map]]
45
+ sources = [
46
+ "_version.py",
47
+ ]
48
+ destinations = [
49
+ "src/openjd",
50
+ ]
51
+ [[tool.hatch.build.hooks.custom.copy_map]]
52
+ sources = [
53
+ "something_the_tests_need.py",
54
+ "something_else_the_tests_need.ini",
55
+ ]
56
+ destinations = [
57
+ "test/openjd",
58
+ ]
59
+ ```
60
+ """
61
+
62
+ REQUIRED_OPTS = [
63
+ "copy_map",
64
+ ]
65
+
66
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
67
+ if not self._prepare():
68
+ return
69
+
70
+ for copy_cfg in self.copy_map:
71
+ _logger.info(f"Copying {copy_cfg.sources} to {copy_cfg.destinations}")
72
+ for destination in copy_cfg.destinations:
73
+ for source in copy_cfg.sources:
74
+ copy_func = shutil.copy if os.path.isfile(source) else shutil.copytree
75
+ copy_func(
76
+ os.path.join(self.root, source),
77
+ os.path.join(self.root, destination),
78
+ )
79
+ _logger.info("Copy complete")
80
+
81
+ def clean(self, versions: list[str]) -> None:
82
+ if not self._prepare():
83
+ return
84
+
85
+ for copy_cfg in self.copy_map:
86
+ _logger.info(f"Cleaning {copy_cfg.sources} from {copy_cfg.destinations}")
87
+ cleaned_count = 0
88
+ for destination in copy_cfg.destinations:
89
+ for source in copy_cfg.sources:
90
+ source_path = os.path.join(self.root, destination, source)
91
+ remove_func = os.remove if os.path.isfile(source_path) else os.rmdir
92
+ try:
93
+ remove_func(source_path)
94
+ except FileNotFoundError:
95
+ _logger.debug(f"Skipping {source_path} because it does not exist...")
96
+ else:
97
+ cleaned_count += 1
98
+ _logger.info(f"Cleaned {cleaned_count} items")
99
+
100
+ def _prepare(self) -> bool:
101
+ missing_required_opts = [
102
+ opt for opt in self.REQUIRED_OPTS if opt not in self.config or not self.config[opt]
103
+ ]
104
+ if missing_required_opts:
105
+ _logger.warn(
106
+ f"Required options {missing_required_opts} are missing or empty. "
107
+ "Contining without copying sources to destinations...",
108
+ file=sys.stderr,
109
+ )
110
+ return False
111
+
112
+ log_level = self.config.get("log_level")
113
+ if log_level:
114
+ _logger.setLevel(log_level)
115
+
116
+ return True
117
+
118
+ @property
119
+ def copy_map(self) -> Optional[list[CopyConfig]]:
120
+ raw_copy_map: list[dict] = self.config.get("copy_map")
121
+ if not raw_copy_map:
122
+ return None
123
+
124
+ if not (
125
+ isinstance(raw_copy_map, list)
126
+ and all(isinstance(copy_cfg, dict) for copy_cfg in raw_copy_map)
127
+ ):
128
+ raise CustomBuildHookException(
129
+ f'"copy_map" config option is a nonvalid type. Expected list[dict], but got {raw_copy_map}'
130
+ )
131
+
132
+ def verify_list_of_file_paths(file_paths: Any, config_name: str):
133
+ if not (isinstance(file_paths, list) and all(isinstance(fp, str) for fp in file_paths)):
134
+ raise CustomBuildHookException(
135
+ f'"{config_name}" config option is a nonvalid type. Expected list[str], but got {file_paths}'
136
+ )
137
+
138
+ missing_paths = [
139
+ fp for fp in file_paths if not os.path.exists(os.path.join(self.root, fp))
140
+ ]
141
+ if len(missing_paths) > 0:
142
+ raise CustomBuildHookException(
143
+ f'"{config_name}" config option contains some file paths that do not exist: {missing_paths}'
144
+ )
145
+
146
+ copy_map: list[CopyConfig] = []
147
+ for copy_cfg in raw_copy_map:
148
+ destinations: list[str] = copy_cfg.get("destinations")
149
+ verify_list_of_file_paths(destinations, "destinations")
150
+
151
+ sources: list[str] = copy_cfg.get("sources")
152
+ verify_list_of_file_paths(sources, "source")
153
+
154
+ copy_map.append(CopyConfig(sources, destinations))
155
+
156
+ return copy_map
@@ -29,8 +29,8 @@ classifiers = [
29
29
  "Intended Audience :: End Users/Desktop"
30
30
  ]
31
31
  dependencies = [
32
- "openjd-sessions >= 0.10.1,< 0.11",
33
- "openjd-model == 0.7.*"
32
+ "openjd-sessions >= 0.10.3,< 0.11",
33
+ "openjd-model >= 0.8,< 0.9"
34
34
  ]
35
35
 
36
36
  [project.urls]
@@ -46,8 +46,6 @@ openjd = "openjd.cli:main"
46
46
  artifacts = [
47
47
  "*_version.py",
48
48
  ]
49
- only-packages = true
50
-
51
49
 
52
50
  [tool.hatch.version]
53
51
  source = "vcs"
@@ -70,15 +68,10 @@ destinations = [
70
68
  ]
71
69
 
72
70
  [tool.hatch.build.targets.sdist]
73
- packages = [
71
+ include = [
74
72
  "src/openjd",
73
+ "hatch_version_hook.py",
75
74
  ]
76
- only-include = [
77
- "src/openjd",
78
- ]
79
-
80
- [tool.hatch.build.targets.sdist.force-include]
81
- "src/openjd/__main__.py" = "openjd/__main__.py"
82
75
 
83
76
  [tool.hatch.build.targets.wheel]
84
77
  packages = [
@@ -176,6 +169,7 @@ omit= [
176
169
  # Can be removed or set to true once we are v1
177
170
  major_on_zero = false
178
171
  tag_format = "{version}"
172
+ allow_zero_version = true
179
173
 
180
174
  [tool.semantic_release.commit_parser_options]
181
175
  allowed_tags = [
@@ -209,4 +203,4 @@ trim_blocks = true
209
203
  lstrip_blocks = true
210
204
 
211
205
  [tool.semantic_release.branches.release]
212
- match = "(mainline|release)"
206
+ match = "(mainline|release|patch_.*)"
@@ -9,7 +9,7 @@ import json
9
9
  import yaml
10
10
  import os
11
11
 
12
- from ._extensions import add_extensions_argument, process_extensions_argument
12
+ from ._extensions import add_extensions_argument, process_extensions_argument, SUPPORTED_EXTENSIONS
13
13
  from ._job_from_template import (
14
14
  job_from_template,
15
15
  get_job_params,
@@ -33,6 +33,7 @@ __all__ = [
33
33
  "read_job_template",
34
34
  "read_environment_template",
35
35
  "validate_task_parameters",
36
+ "SUPPORTED_EXTENSIONS",
36
37
  ]
37
38
 
38
39
 
@@ -4,7 +4,7 @@ from argparse import ArgumentParser
4
4
  from typing import Optional
5
5
 
6
6
  # This is the list of Open Job Description extensions with implemented support
7
- SUPPORTED_EXTENSIONS = ["TASK_CHUNKING"]
7
+ SUPPORTED_EXTENSIONS = ["TASK_CHUNKING", "REDACTED_ENV_VARS"]
8
8
 
9
9
 
10
10
  def add_extensions_argument(run_parser: ArgumentParser):
@@ -5,6 +5,8 @@ import sys
5
5
  import traceback
6
6
  from typing import Optional
7
7
 
8
+ from ._version import version
9
+
8
10
  from ._common import SubparserGroup
9
11
 
10
12
  from ._check import populate_argparser as populate_check_subparser
@@ -22,6 +24,11 @@ def create_argparser() -> ArgumentParser:
22
24
  """Generate the root argparser for the CLI"""
23
25
  parser = ArgumentParser(prog="openjd", usage="openjd <command> [arguments]")
24
26
  parser.set_defaults(func=lambda _: parser.print_help())
27
+
28
+ parser.add_argument(
29
+ "--version", action="version", version=f"Open Job Description CLI {version}"
30
+ )
31
+
25
32
  subcommands = SubparserGroup(
26
33
  parser,
27
34
  title="commands",
@@ -17,10 +17,14 @@ from ._actions import (
17
17
  EnvironmentType,
18
18
  )
19
19
  from ._logs import LocalSessionLogHandler, LogEntry, LoggingTimestampFormat
20
+ from ..._common import SUPPORTED_EXTENSIONS
21
+
20
22
  from openjd.model import (
21
23
  IntRangeExpr,
22
24
  Job,
23
25
  JobParameterValues,
26
+ RevisionExtensions,
27
+ SpecificationRevision,
24
28
  Step,
25
29
  StepParameterSpaceIterator,
26
30
  TaskParameterSet,
@@ -83,6 +87,9 @@ class LocalSession:
83
87
  environments: Optional[list[Any]] = None,
84
88
  should_print_logs: bool = True,
85
89
  retain_working_dir: bool = False,
90
+ revision_extensions: RevisionExtensions = RevisionExtensions(
91
+ spec_rev=SpecificationRevision.v2023_09, supported_extensions=SUPPORTED_EXTENSIONS
92
+ ),
86
93
  ):
87
94
  self.session_id = session_id
88
95
  self._action_ended = Event()
@@ -98,6 +105,7 @@ class LocalSession:
98
105
  path_mapping_rules=self._path_mapping_rules,
99
106
  callback=self._action_callback,
100
107
  retain_working_dir=retain_working_dir,
108
+ revision_extensions=revision_extensions,
101
109
  )
102
110
 
103
111
  self._should_print_logs = should_print_logs
@@ -34,6 +34,8 @@ from openjd.model import (
34
34
  StepParameterSpaceIterator,
35
35
  ParameterValue,
36
36
  ParameterValueType,
37
+ RevisionExtensions,
38
+ SpecificationRevision,
37
39
  TaskParameterSet,
38
40
  )
39
41
  from openjd.sessions import PathMappingRule, LOG
@@ -328,6 +330,9 @@ def _run_local_session(
328
330
  path_mapping_rules: Optional[list[PathMappingRule]],
329
331
  should_print_logs: bool = True,
330
332
  retain_working_dir: bool = False,
333
+ revision_extensions: RevisionExtensions = RevisionExtensions(
334
+ spec_rev=SpecificationRevision.v2023_09, supported_extensions=[]
335
+ ),
331
336
  ) -> OpenJDCliResult:
332
337
  """
333
338
  Creates a Session object and listens for log messages to synchronously end the session.
@@ -346,6 +351,7 @@ def _run_local_session(
346
351
  environments=[env.environment for env in environments] if environments else [],
347
352
  should_print_logs=should_print_logs,
348
353
  retain_working_dir=retain_working_dir,
354
+ revision_extensions=revision_extensions,
349
355
  ) as session:
350
356
  for dep_step in step_list:
351
357
  step_name = dep_step.name
@@ -512,6 +518,12 @@ def do_run(args: Namespace) -> OpenJDCliResult:
512
518
  except RuntimeError as rte:
513
519
  return OpenJDCliResult(status="error", message=str(rte))
514
520
 
521
+ # Create a RevisionExtensions object with the default specification version and enabled extensions
522
+ # We use the default v2023_09 since that's what we're currently supporting
523
+ revision_extensions = RevisionExtensions(
524
+ spec_rev=the_job.revision, supported_extensions=extensions
525
+ )
526
+
515
527
  return _run_local_session(
516
528
  job=the_job,
517
529
  job_parameter_values=job_parameter_values,
@@ -524,4 +536,5 @@ def do_run(args: Namespace) -> OpenJDCliResult:
524
536
  path_mapping_rules=path_mapping_rules,
525
537
  should_print_logs=(args.output == "human-readable"),
526
538
  retain_working_dir=args.preserve,
539
+ revision_extensions=revision_extensions,
527
540
  )
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.7.2'
32
+ __version_tuple__ = version_tuple = (0, 7, 2)
33
+
34
+ __commit_id__ = commit_id = None
File without changes
File without changes
File without changes
File without changes