openjd-cli 0.4.0__tar.gz → 0.4.1__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.
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/PKG-INFO +9 -7
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/README.md +8 -6
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_common/__init__.py +3 -1
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/_local_session/_session_manager.py +2 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/_run_command.py +29 -3
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_version.py +2 -2
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/pyproject.toml +21 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/.gitignore +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/LICENSE +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/NOTICE +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/hatch.toml +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/__main__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_check/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_check/_check_command.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_common/_job_from_template.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_common/_validation_utils.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_create_argparser.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/_local_session/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/_local_session/_actions.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_run/_local_session/_logs.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_schema/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_schema/_schema_command.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_summary/__init__.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_summary/_summary_command.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/_summary/_summary_output.py +0 -0
- {openjd_cli-0.4.0 → openjd_cli-0.4.1}/openjd/cli/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: openjd-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
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
|
|
@@ -105,7 +105,7 @@ customize the Job, as parameters can have an impact on the amount of Steps and T
|
|
|
105
105
|
|---|---|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
|
|
106
106
|
|`path`|path|yes| A path leading to a Job template file. |`/path/to/job.template.json`|
|
|
107
107
|
|`--job-param`, `-p`|string, path|no| The values for the job template's parameters. Can be provided as key-value pairs, inline JSON string, or path(s) to a JSON or YAML document. If provided more than once then the given values are combined in the order that they appear. |`--job-param MyParam=5`, `-p file://parameter_file.json`, `-p '{"MyParam": "5"}'`|
|
|
108
|
-
|`--step
|
|
108
|
+
|`--step`|string|no| The name of the Step to summarize. |`--step Step1`|
|
|
109
109
|
|`--output`|string|no| How to display the results of the command. Allowed values are `human-readable` (default), `json`, and `yaml`. |`--output json`, `--output yaml`|
|
|
110
110
|
|
|
111
111
|
#### Example
|
|
@@ -150,22 +150,24 @@ details on how Open Job Description's Jobs are run within Sessions.
|
|
|
150
150
|
|Name|Type|Required| Description |Example|
|
|
151
151
|
|---|---|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
|
|
152
152
|
|`path`|path|yes| A path leading to a Job template file. |`/path/to/job.template.json`|
|
|
153
|
-
|`--step
|
|
153
|
+
|`--step`|string|yes| The name of the Step to run in a local Session. |`--step Step1`|
|
|
154
154
|
|`--environment`|paths|no| Path to a file containing Environment Template definitions. Can be provided multiple times. |`--environment /path/to/env.template1.json --environment /path/to/env.template2.yaml`|
|
|
155
155
|
|`--job-param`, `-p`|string, path|no| The values for the job template's parameters. Can be provided as key-value pairs, inline JSON string, or as path(s) to a JSON or YAML document. If provided more than once then the given values are combined in the order that they appear. |`--job-param MyParam=5`, `-p file://parameter_file.json`, `-p '{"MyParam": "5"}'`|
|
|
156
|
-
|`--task-
|
|
156
|
+
|`--task-param`, `-tp`|string|no| Instructs the command to run a single task in a Session with the given value for one of the task parameters. The option must be provided once for each task parameter defined for the Step, with each instance providing the value for a different task parameter. Mutually exclusive with `--tasks` and `--maximum-tasks`. |`-tp MyParam=5 -tp MyOtherParam=Foo`|
|
|
157
157
|
|`--tasks`|string, path|no| Instructs the command to run one or more tasks for the Step in a Session. The argument must be either the filename of a JSON or YAML file containing an array of maps from task parameter name to value; or an inlined JSON string of the same. Mutually exclusive with `--task-param/-tp` and `--maximum-tasks`. |`--tasks '[{"MyParam": 5}]'`, `--tasks file://parameter_set_file.json`|
|
|
158
|
-
|`--maximum-tasks`|integer|no| A maximum number of Tasks to run from this Step. Unless present, the Session will run all Tasks defined in the Step's parameter space or the Task(s) selected by the `--task-
|
|
158
|
+
|`--maximum-tasks`|integer|no| A maximum number of Tasks to run from this Step. Unless present, the Session will run all Tasks defined in the Step's parameter space or the Task(s) selected by the `--task-param` or `--tasks` arguments. Mutually exclusive with `--task-param/-tp` and `--tasks`. |`--maximum-tasks 5`|
|
|
159
159
|
|`--run-dependencies`|flag|no| If present, runs all of a Step's dependencies in the Session prior to the Step itself. |`--run-dependencies`|
|
|
160
160
|
|`--path-mapping-rules`|string, path|no| The path mapping rules to apply to the template. Should be a JSON-formatted list of Open Job Description path mapping rules, provided as a string or a path to a JSON/YAML document prefixed with 'file://'. |`--path-mapping-rules [{"source_os": "Windows", "source_path": "C:\test", "destination_path": "/mnt/test"}]`, `--path-mapping-rules file://rules_file.json`|
|
|
161
|
+
|`--preserve`|flag|no| If present, the Session's working directory will not be deleted when the run is completed. |`--preserve`|
|
|
162
|
+
|`--verbose`|flag|no| If present, then verbose logging will be enabled in the Session's log. |`--verbose`|
|
|
161
163
|
|`--output`|string|no| How to display the results of the command. Allowed values are `human-readable` (default), `json`, and `yaml`. |`--output json`, `--output yaml`|
|
|
162
164
|
|
|
163
165
|
#### Example
|
|
164
166
|
```sh
|
|
165
167
|
$ openjd-cli run /path/to/job.template.json --step Step1 \
|
|
166
168
|
--job-param PingServer=amazon.com \
|
|
167
|
-
--task-
|
|
168
|
-
--task-
|
|
169
|
+
--task-param PingCount=20 \
|
|
170
|
+
--task-param PingDelay=30
|
|
169
171
|
|
|
170
172
|
# ... Task logs accompanied by timestamps ...
|
|
171
173
|
|
|
@@ -78,7 +78,7 @@ customize the Job, as parameters can have an impact on the amount of Steps and T
|
|
|
78
78
|
|---|---|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
|
|
79
79
|
|`path`|path|yes| A path leading to a Job template file. |`/path/to/job.template.json`|
|
|
80
80
|
|`--job-param`, `-p`|string, path|no| The values for the job template's parameters. Can be provided as key-value pairs, inline JSON string, or path(s) to a JSON or YAML document. If provided more than once then the given values are combined in the order that they appear. |`--job-param MyParam=5`, `-p file://parameter_file.json`, `-p '{"MyParam": "5"}'`|
|
|
81
|
-
|`--step
|
|
81
|
+
|`--step`|string|no| The name of the Step to summarize. |`--step Step1`|
|
|
82
82
|
|`--output`|string|no| How to display the results of the command. Allowed values are `human-readable` (default), `json`, and `yaml`. |`--output json`, `--output yaml`|
|
|
83
83
|
|
|
84
84
|
#### Example
|
|
@@ -123,22 +123,24 @@ details on how Open Job Description's Jobs are run within Sessions.
|
|
|
123
123
|
|Name|Type|Required| Description |Example|
|
|
124
124
|
|---|---|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
|
|
125
125
|
|`path`|path|yes| A path leading to a Job template file. |`/path/to/job.template.json`|
|
|
126
|
-
|`--step
|
|
126
|
+
|`--step`|string|yes| The name of the Step to run in a local Session. |`--step Step1`|
|
|
127
127
|
|`--environment`|paths|no| Path to a file containing Environment Template definitions. Can be provided multiple times. |`--environment /path/to/env.template1.json --environment /path/to/env.template2.yaml`|
|
|
128
128
|
|`--job-param`, `-p`|string, path|no| The values for the job template's parameters. Can be provided as key-value pairs, inline JSON string, or as path(s) to a JSON or YAML document. If provided more than once then the given values are combined in the order that they appear. |`--job-param MyParam=5`, `-p file://parameter_file.json`, `-p '{"MyParam": "5"}'`|
|
|
129
|
-
|`--task-
|
|
129
|
+
|`--task-param`, `-tp`|string|no| Instructs the command to run a single task in a Session with the given value for one of the task parameters. The option must be provided once for each task parameter defined for the Step, with each instance providing the value for a different task parameter. Mutually exclusive with `--tasks` and `--maximum-tasks`. |`-tp MyParam=5 -tp MyOtherParam=Foo`|
|
|
130
130
|
|`--tasks`|string, path|no| Instructs the command to run one or more tasks for the Step in a Session. The argument must be either the filename of a JSON or YAML file containing an array of maps from task parameter name to value; or an inlined JSON string of the same. Mutually exclusive with `--task-param/-tp` and `--maximum-tasks`. |`--tasks '[{"MyParam": 5}]'`, `--tasks file://parameter_set_file.json`|
|
|
131
|
-
|`--maximum-tasks`|integer|no| A maximum number of Tasks to run from this Step. Unless present, the Session will run all Tasks defined in the Step's parameter space or the Task(s) selected by the `--task-
|
|
131
|
+
|`--maximum-tasks`|integer|no| A maximum number of Tasks to run from this Step. Unless present, the Session will run all Tasks defined in the Step's parameter space or the Task(s) selected by the `--task-param` or `--tasks` arguments. Mutually exclusive with `--task-param/-tp` and `--tasks`. |`--maximum-tasks 5`|
|
|
132
132
|
|`--run-dependencies`|flag|no| If present, runs all of a Step's dependencies in the Session prior to the Step itself. |`--run-dependencies`|
|
|
133
133
|
|`--path-mapping-rules`|string, path|no| The path mapping rules to apply to the template. Should be a JSON-formatted list of Open Job Description path mapping rules, provided as a string or a path to a JSON/YAML document prefixed with 'file://'. |`--path-mapping-rules [{"source_os": "Windows", "source_path": "C:\test", "destination_path": "/mnt/test"}]`, `--path-mapping-rules file://rules_file.json`|
|
|
134
|
+
|`--preserve`|flag|no| If present, the Session's working directory will not be deleted when the run is completed. |`--preserve`|
|
|
135
|
+
|`--verbose`|flag|no| If present, then verbose logging will be enabled in the Session's log. |`--verbose`|
|
|
134
136
|
|`--output`|string|no| How to display the results of the command. Allowed values are `human-readable` (default), `json`, and `yaml`. |`--output json`, `--output yaml`|
|
|
135
137
|
|
|
136
138
|
#### Example
|
|
137
139
|
```sh
|
|
138
140
|
$ openjd-cli run /path/to/job.template.json --step Step1 \
|
|
139
141
|
--job-param PingServer=amazon.com \
|
|
140
|
-
--task-
|
|
141
|
-
--task-
|
|
142
|
+
--task-param PingCount=20 \
|
|
143
|
+
--task-param PingDelay=30
|
|
142
144
|
|
|
143
145
|
# ... Task logs accompanied by timestamps ...
|
|
144
146
|
|
|
@@ -157,7 +157,7 @@ def print_cli_result(command: Callable[[Namespace], OpenJDCliResult]) -> Callabl
|
|
|
157
157
|
Used to decorate the `do_<command>` functions for each command.
|
|
158
158
|
"""
|
|
159
159
|
|
|
160
|
-
def format_results(args: Namespace) ->
|
|
160
|
+
def format_results(args: Namespace) -> OpenJDCliResult:
|
|
161
161
|
response = command(args)
|
|
162
162
|
|
|
163
163
|
if args.output == "human-readable":
|
|
@@ -175,4 +175,6 @@ def print_cli_result(command: Callable[[Namespace], OpenJDCliResult]) -> Callabl
|
|
|
175
175
|
if response.status == "error":
|
|
176
176
|
raise SystemExit(1)
|
|
177
177
|
|
|
178
|
+
return response
|
|
179
|
+
|
|
178
180
|
return format_results
|
|
@@ -62,6 +62,7 @@ class LocalSession:
|
|
|
62
62
|
path_mapping_rules: Optional[list[PathMappingRule]] = None,
|
|
63
63
|
environments: Optional[list[EnvironmentTemplate]] = None,
|
|
64
64
|
should_print_logs: bool = True,
|
|
65
|
+
retain_working_dir: bool = False,
|
|
65
66
|
):
|
|
66
67
|
self.session_id = session_id
|
|
67
68
|
self.ended = Event()
|
|
@@ -85,6 +86,7 @@ class LocalSession:
|
|
|
85
86
|
job_parameter_values=job_parameters,
|
|
86
87
|
path_mapping_rules=self._path_mapping_rules,
|
|
87
88
|
callback=self._action_callback,
|
|
89
|
+
retain_working_dir=retain_working_dir,
|
|
88
90
|
)
|
|
89
91
|
|
|
90
92
|
# Initialize the action queue
|
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
import json
|
|
7
7
|
from typing import Optional
|
|
8
8
|
import re
|
|
9
|
+
import logging
|
|
9
10
|
|
|
10
11
|
from ._local_session._session_manager import LocalSession, LogEntry
|
|
11
12
|
from .._common import (
|
|
@@ -22,7 +23,7 @@ from openjd.model import (
|
|
|
22
23
|
Step,
|
|
23
24
|
StepParameterSpaceIterator,
|
|
24
25
|
)
|
|
25
|
-
from openjd.sessions import PathMappingRule
|
|
26
|
+
from openjd.sessions import PathMappingRule, LOG
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
@dataclass
|
|
@@ -119,6 +120,20 @@ def add_run_arguments(run_parser: ArgumentParser):
|
|
|
119
120
|
metavar="<path-to-JSON/YAML-file> [<path-to-JSON/YAML-file>] ...",
|
|
120
121
|
help="Apply the given environments to the Session in the order given.",
|
|
121
122
|
)
|
|
123
|
+
run_parser.add_argument(
|
|
124
|
+
"--preserve",
|
|
125
|
+
action="store_const",
|
|
126
|
+
const=True,
|
|
127
|
+
default=False,
|
|
128
|
+
help="Do not automatically delete the Session's Working Directory when complete.",
|
|
129
|
+
)
|
|
130
|
+
run_parser.add_argument(
|
|
131
|
+
"--verbose",
|
|
132
|
+
action="store_const",
|
|
133
|
+
const=True,
|
|
134
|
+
default=False,
|
|
135
|
+
help="Enable verbose logging while running the Session.",
|
|
136
|
+
)
|
|
122
137
|
|
|
123
138
|
|
|
124
139
|
def _collect_required_steps(step_map: dict[str, Step], step: Step) -> list[Step]:
|
|
@@ -301,6 +316,7 @@ def _run_local_session(
|
|
|
301
316
|
path_mapping_rules: Optional[list[PathMappingRule]],
|
|
302
317
|
should_run_dependencies: bool = False,
|
|
303
318
|
should_print_logs: bool = True,
|
|
319
|
+
retain_working_dir: bool = False,
|
|
304
320
|
) -> OpenJDCliResult:
|
|
305
321
|
"""
|
|
306
322
|
Creates a Session object and listens for log messages to synchronously end the session.
|
|
@@ -320,6 +336,7 @@ def _run_local_session(
|
|
|
320
336
|
path_mapping_rules=path_mapping_rules,
|
|
321
337
|
environments=environments,
|
|
322
338
|
should_print_logs=should_print_logs,
|
|
339
|
+
retain_working_dir=retain_working_dir,
|
|
323
340
|
) as session:
|
|
324
341
|
session.initialize(
|
|
325
342
|
dependencies=dependencies,
|
|
@@ -332,10 +349,15 @@ def _run_local_session(
|
|
|
332
349
|
# Monitor the local Session state
|
|
333
350
|
session.ended.wait()
|
|
334
351
|
|
|
352
|
+
preserved_message: str = ""
|
|
353
|
+
if retain_working_dir:
|
|
354
|
+
preserved_message = (
|
|
355
|
+
f"\nWorking directory preserved at: {str(session._inner_session.working_directory)}"
|
|
356
|
+
)
|
|
335
357
|
if session.failed:
|
|
336
358
|
return OpenJDRunResult(
|
|
337
359
|
status="error",
|
|
338
|
-
message="Session ended with errors; see Task logs for details",
|
|
360
|
+
message="Session ended with errors; see Task logs for details" + preserved_message,
|
|
339
361
|
job_name=job.name,
|
|
340
362
|
step_name=step.name,
|
|
341
363
|
duration=session.get_duration(),
|
|
@@ -345,7 +367,7 @@ def _run_local_session(
|
|
|
345
367
|
|
|
346
368
|
return OpenJDRunResult(
|
|
347
369
|
status="success",
|
|
348
|
-
message="Session ended successfully",
|
|
370
|
+
message="Session ended successfully" + preserved_message,
|
|
349
371
|
job_name=job.name,
|
|
350
372
|
step_name=step.name,
|
|
351
373
|
duration=session.get_duration(),
|
|
@@ -397,6 +419,9 @@ def do_run(args: Namespace) -> OpenJDCliResult:
|
|
|
397
419
|
rules_list = parsed_rules.get("path_mapping_rules")
|
|
398
420
|
path_mapping_rules = [PathMappingRule.from_dict(rule) for rule in rules_list]
|
|
399
421
|
|
|
422
|
+
if args.verbose:
|
|
423
|
+
LOG.setLevel(logging.DEBUG)
|
|
424
|
+
|
|
400
425
|
try:
|
|
401
426
|
# Raises: RuntimeError
|
|
402
427
|
the_job = generate_job(args)
|
|
@@ -430,4 +455,5 @@ def do_run(args: Namespace) -> OpenJDCliResult:
|
|
|
430
455
|
path_mapping_rules=path_mapping_rules,
|
|
431
456
|
should_run_dependencies=(args.run_dependencies),
|
|
432
457
|
should_print_logs=(args.output == "human-readable"),
|
|
458
|
+
retain_working_dir=args.preserve,
|
|
433
459
|
)
|
|
@@ -174,6 +174,27 @@ omit= [
|
|
|
174
174
|
major_on_zero = false
|
|
175
175
|
tag_format = "{version}"
|
|
176
176
|
|
|
177
|
+
[tool.semantic_release.commit_parser_options]
|
|
178
|
+
allowed_tags = [
|
|
179
|
+
"build",
|
|
180
|
+
"chore",
|
|
181
|
+
"ci",
|
|
182
|
+
"docs",
|
|
183
|
+
"feat",
|
|
184
|
+
"fix",
|
|
185
|
+
"perf",
|
|
186
|
+
"style",
|
|
187
|
+
"refactor",
|
|
188
|
+
"test",
|
|
189
|
+
]
|
|
190
|
+
minor_tags = []
|
|
191
|
+
patch_tags = [
|
|
192
|
+
"chore",
|
|
193
|
+
"feat",
|
|
194
|
+
"fix",
|
|
195
|
+
"refactor",
|
|
196
|
+
]
|
|
197
|
+
|
|
177
198
|
[tool.semantic_release.publish]
|
|
178
199
|
upload_to_vcs_release = false
|
|
179
200
|
|
|
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
|