openjd-cli 0.4.3__tar.gz → 0.4.4__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 (28) hide show
  1. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/PKG-INFO +2 -2
  2. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/_local_session/_session_manager.py +38 -9
  3. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_version.py +2 -2
  4. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/pyproject.toml +1 -1
  5. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/.gitignore +0 -0
  6. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/LICENSE +0 -0
  7. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/NOTICE +0 -0
  8. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/README.md +0 -0
  9. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/hatch.toml +0 -0
  10. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/__main__.py +0 -0
  11. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/__init__.py +0 -0
  12. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_check/__init__.py +0 -0
  13. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_check/_check_command.py +0 -0
  14. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_common/__init__.py +0 -0
  15. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_common/_job_from_template.py +0 -0
  16. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_common/_validation_utils.py +0 -0
  17. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_create_argparser.py +0 -0
  18. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/__init__.py +0 -0
  19. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/_local_session/__init__.py +0 -0
  20. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/_local_session/_actions.py +0 -0
  21. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/_local_session/_logs.py +0 -0
  22. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_run/_run_command.py +0 -0
  23. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_schema/__init__.py +0 -0
  24. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_schema/_schema_command.py +0 -0
  25. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_summary/__init__.py +0 -0
  26. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_summary/_summary_command.py +0 -0
  27. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/_summary/_summary_output.py +0 -0
  28. {openjd_cli-0.4.3 → openjd_cli-0.4.4}/openjd/cli/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openjd-cli
3
- Version: 0.4.3
3
+ Version: 0.4.4
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
@@ -23,7 +23,7 @@ Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
24
  Requires-Python: >=3.9
25
25
  Requires-Dist: openjd-model==0.4.*
26
- Requires-Dist: openjd-sessions==0.7.*
26
+ Requires-Dist: openjd-sessions==0.8.*
27
27
  Description-Content-Type: text/markdown
28
28
 
29
29
  ## Open Job Description - CLI
@@ -46,7 +46,8 @@ class LocalSession:
46
46
  _start_seconds: float
47
47
  _end_seconds: float
48
48
  _inner_session: Session
49
- _action_queue: Queue[SessionAction]
49
+ _enter_env_queue: Queue[EnterEnvironmentAction]
50
+ _action_queue: Queue[RunTaskAction]
50
51
  _current_action: Optional[SessionAction]
51
52
  _action_ended: Event
52
53
  _path_mapping_rules: Optional[list[PathMappingRule]]
@@ -90,7 +91,8 @@ class LocalSession:
90
91
  )
91
92
 
92
93
  # Initialize the action queue
93
- self._action_queue: Queue[SessionAction] = Queue()
94
+ self._enter_env_queue: Queue[EnterEnvironmentAction] = Queue()
95
+ self._action_queue: Queue[RunTaskAction] = Queue()
94
96
  self._current_action = None
95
97
 
96
98
  self._should_print_logs = should_print_logs
@@ -222,25 +224,52 @@ class LocalSession:
222
224
  RunTaskAction(self._inner_session, step=step, parameters=param_set)
223
225
  )
224
226
 
225
- # Finally, enqueue ExitEnvironment Actions in reverse order to EnterEnvironment
226
- for env_id in reversed(session_environment_ids):
227
- self._action_queue.put(ExitEnvironmentAction(self._inner_session, env_id))
228
-
229
227
  def run(self) -> None:
230
228
  if self._inner_session.state != SessionState.READY:
231
229
  raise RuntimeError("Session is not in a READY state")
232
230
 
231
+ environments_entered = list[str]()
232
+ failed_action: Optional[SessionAction] = None
233
+
233
234
  self._start_seconds = time.perf_counter()
235
+
236
+ # Enter all of the Environments, and keep track of which ones we've entered
237
+ while not self._enter_env_queue.empty() and not self.failed:
238
+ self._action_ended.clear()
239
+ action = self._enter_env_queue.get()
240
+ environments_entered.append(action._id)
241
+ self._current_action = action
242
+ self._current_action.run()
243
+ self._action_ended.wait()
244
+ if self.failed:
245
+ failed_action = self._current_action
246
+
247
+ # Run all of the Tasks that are enqueued
234
248
  while not self._action_queue.empty() and not self.failed:
235
249
  self._action_ended.clear()
236
250
  self._current_action = self._action_queue.get()
237
251
  self._current_action.run()
238
252
  self._action_ended.wait()
253
+ if self.failed:
254
+ failed_action = self._current_action
255
+
256
+ # Exit all environments that were entered. We always try to exit all failed environments; even
257
+ # if an environment-enter, task, or environment exit failed.
258
+ while environments_entered:
259
+ prev_action_failed = self.failed
260
+ self._action_ended.clear()
261
+ self._current_action = ExitEnvironmentAction(
262
+ self._inner_session, environments_entered.pop()
263
+ )
264
+ self._current_action.run()
265
+ self._action_ended.wait()
266
+ if self.failed and not prev_action_failed:
267
+ failed_action = self._current_action
239
268
 
240
269
  if self.failed:
241
270
  # Action encountered an error; clean up resources and end session
242
271
  LOG.info(
243
- msg=f"Open Job Description CLI: ERROR executing action: '{str(self._current_action)}' (see Task logs for details)",
272
+ msg=f"Open Job Description CLI: ERROR executing action: '{str(failed_action)}' (see Task logs for details)",
244
273
  extra={"session_id": self.session_id},
245
274
  )
246
275
 
@@ -347,13 +376,13 @@ class LocalSession:
347
376
  if isinstance(self._current_action, RunTaskAction):
348
377
  self.tasks_run += 1
349
378
  self._action_ended.set()
350
- if new_status.state in (ActionState.FAILED, ActionState.CANCELED):
379
+ if new_status.state in (ActionState.FAILED, ActionState.CANCELED, ActionState.TIMEOUT):
351
380
  self.failed = True
352
381
  self._action_ended.set()
353
382
 
354
383
  def _add_environments(self, envs: list) -> list[str]:
355
384
  ids: list[str] = []
356
385
  for env in envs:
357
- self._action_queue.put(EnterEnvironmentAction(self._inner_session, env, env.name))
386
+ self._enter_env_queue.put(EnterEnvironmentAction(self._inner_session, env, env.name))
358
387
  ids.append(env.name)
359
388
  return ids
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.4.3'
16
- __version_tuple__ = version_tuple = (0, 4, 3)
15
+ __version__ = version = '0.4.4'
16
+ __version_tuple__ = version_tuple = (0, 4, 4)
@@ -29,7 +29,7 @@ classifiers = [
29
29
  "Intended Audience :: End Users/Desktop"
30
30
  ]
31
31
  dependencies = [
32
- "openjd-sessions == 0.7.*",
32
+ "openjd-sessions == 0.8.*",
33
33
  "openjd-model == 0.4.*"
34
34
  ]
35
35
 
File without changes
File without changes
File without changes
File without changes
File without changes