pinexq-client 0.9.2.20250515.43__py3-none-any.whl → 0.9.2.20250716.44__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.
@@ -1,9 +1,10 @@
1
1
  import json as json_
2
2
  import warnings
3
- from typing import Any, Self
3
+ from typing import Any, Self, List
4
4
 
5
5
  import httpx
6
6
  from httpx import URL
7
+ from pydantic import BaseModel, ConfigDict
7
8
 
8
9
  from pinexq_client.core import Link, MediaTypes, ClientException, ApiException
9
10
  from pinexq_client.core.polling import wait_until, PollingException
@@ -35,12 +36,51 @@ from pinexq_client.job_management.model import (
35
36
  SelectProcessingParameters,
36
37
  SelectWorkDataCollectionForDataSlotParameters,
37
38
  SelectWorkDataForDataSlotParameters,
38
- SetJobTagsParameters, RapidJobSetupParameters,
39
+ SetJobTagsParameters, RapidJobSetupParameters, InputDataSlotParameter,
39
40
  )
40
41
  from pinexq_client.job_management.tool.processing_step import ProcessingStep
41
42
  from pinexq_client.job_management.tool.workdata import WorkData
42
43
 
43
44
 
45
+ class InputDataSlotParameterFlexible(BaseModel):
46
+ model_config = ConfigDict(
47
+ extra='allow',
48
+ arbitrary_types_allowed=True
49
+ )
50
+ index: int
51
+ work_data_urls: List[str] | None = None
52
+ work_data_instances: List[WorkData] | None = None
53
+
54
+ @classmethod
55
+ def create(cls, *,
56
+ index: int,
57
+ work_data_urls: List[WorkDataLink] | None = None,
58
+ work_data_instances: List[WorkData] | None = None
59
+ ) -> "InputDataSlotParameterFlexible":
60
+ """Creates an instance of InputDataSlotParameterFlexible that can be used to assign work data to a job.
61
+
62
+ Args:
63
+ index: The index of the input data slot.
64
+ work_data_urls: A list of URLs pointing to the work data.
65
+ work_data_instances: A list of WorkData instances.
66
+
67
+ Returns:
68
+ An instance of InputDataSlotParameterFlexible.
69
+ """
70
+ if sum(p is not None for p in [work_data_urls, work_data_instances]) != 1:
71
+ raise ValueError("Exactly one parameter must be provided")
72
+
73
+ if work_data_instances is not None:
74
+ if not isinstance(work_data_instances, list) or any(
75
+ not isinstance(i, WorkData) for i in work_data_instances):
76
+ raise Exception('Instance passed to "work_data_instances" is not of type "list[WorkData]"')
77
+ work_data_urls = [work_data_instance.self_link() for work_data_instance in work_data_instances]
78
+ return InputDataSlotParameterFlexible(
79
+ index=index,
80
+ work_data_urls=[str(wd.get_url()) for wd in work_data_urls] if work_data_urls else None,
81
+ work_data_instances=None
82
+ )
83
+
44
84
  class Job:
45
85
  """Convenience wrapper for handling JobHcos in the JobManagement-Api.
46
86
 
@@ -61,7 +101,7 @@ class Job:
61
101
  _entrypoint: EntryPointHco
62
102
  _jobs_root: JobsRootHco
63
103
  _processing_step_root: ProcessingStepsRootHco
64
- job_hco: JobHco | None = None # Internal hco of the wrapper. This is updated by this class. You should not take a reference to this object.
104
+ job_hco: JobHco | None = None # Internal hco of the wrapper. This is updated by this class. You should not take a reference to this object.
65
105
 
66
106
  def __init__(self, client: httpx.Client):
67
107
  """
@@ -313,6 +353,19 @@ class Job:
313
353
 
314
354
  return self
315
355
 
356
+ def wait_for_completion(self, timeout_ms: int = 60000, polling_interval_ms: int = 500) -> Self:
357
+ """Wait for this job to reach the state 'completed'.
358
+
359
+ Args:
360
+ timeout_ms: Timeout to wait for the job to reach the next state.
361
+ polling_interval_ms: will determine how fast the API is polled for updates.
362
+ Note that low values will produce unnecessary load.
363
+
364
+ Returns:
365
+ This `Job` object
366
+ """
367
+ return self.wait_for_state(JobStates.completed, timeout_ms, polling_interval_ms)
368
+
316
369
  def assign_input_dataslot(
317
370
  self,
318
371
  index: int,
@@ -564,7 +617,7 @@ class Job:
564
617
 
565
618
  job_was_deleted = False
566
619
  try:
567
- if self.job_hco.delete_action.is_available():
620
+ if self.job_hco.delete_action.is_available():
568
621
  self.job_hco.delete_action.execute()
569
622
  # do not delete the hco here since we want to access its data slots just below
570
623
  job_was_deleted = True
@@ -663,7 +716,17 @@ class Job:
663
716
 
664
717
  def create_and_configure_rapidly(
665
718
  self,
666
- parameters: RapidJobSetupParameters
719
+ *,
720
+ name: str,
721
+ parent_job_url: JobLink | None = None,
722
+ parent_job_instance: Self | None = None,
723
+ tags: list[str] | None = None,
724
+ processing_step_url: ProcessingStepLink | None = None,
725
+ processing_step_instance: ProcessingStep | None = None,
726
+ start: bool = True,
727
+ parameters: str | None = None,
728
+ allow_output_data_slots: bool | None = None,
729
+ input_data_slots: List[InputDataSlotParameterFlexible] | None = None,
667
730
  ) -> Self:
668
731
  """
669
732
  Creates a new job and configures it rapidly with RapidJobSetupParameters.
@@ -674,7 +737,54 @@ class Job:
674
737
  Returns:
675
738
  The newly created job as `Job` object
676
739
  """
677
- job_link = self._jobs_root.rapid_job_setup_action.execute(parameters)
740
+
741
+ # handle parent job
742
+ if sum(p is not None for p in [parent_job_url, parent_job_instance]) > 1:
743
+ raise ValueError("Either none or at most 1 one of parent_job_url or parent_job_instance must be provided")
744
+ parent_job = None
745
+ if parent_job_instance is not None:
746
+ if not isinstance(parent_job_instance, Job):
747
+ raise Exception('Instance passed to "parent_job_instance" is not of type "Job"')
748
+ parent_job = parent_job_instance.self_link().get_url()
749
+ elif parent_job_url is not None:
750
+ if not isinstance(parent_job_url, JobLink):
751
+ raise Exception('Instance passed to "parent_job_url" is not of type "JobLink"')
752
+ parent_job = parent_job_url.get_url()
753
+
754
+ # handle processing step
755
+ if sum(p is not None for p in [processing_step_url, processing_step_instance]) != 1:
756
+ raise ValueError("Exactly one of processing_step_url or processing_step_instance must be provided")
757
+ if processing_step_instance is not None:
758
+ if not isinstance(processing_step_instance, ProcessingStep):
759
+ raise Exception('Instance passed to "processing_step_instance" is not of type "ProcessingStep"')
760
+ processing_step = processing_step_instance.self_link().get_url()
761
+ else:
762
+ if not isinstance(processing_step_url, ProcessingStepLink):
763
+ raise Exception('Instance passed to "processing_step_url" is not of type "ProcessingStepLink"')
764
+ processing_step = processing_step_url.get_url()
765
+
766
+ # handle input data slots
767
+ if input_data_slots is not None:
768
+ input_data_slots = [
769
+ InputDataSlotParameter(
770
+ Index=slot.index,
771
+ WorkDataUrls=slot.work_data_urls
772
+ ) for slot in input_data_slots
773
+ ]
774
+
775
+ # build RapidJobSetupParameters
776
+ params = RapidJobSetupParameters(
777
+ Name=name,
778
+ ParentJobUrl=None if parent_job is None else str(parent_job),
779
+ ProcessingStepUrl=str(processing_step),
780
+ Tags=tags,
781
+ Start=start,
782
+ Parameters=parameters,
783
+ AllowOutputDataDeletion=allow_output_data_slots,
784
+ InputDataSlots=input_data_slots
785
+ )
786
+
787
+ job_link = self._jobs_root.rapid_job_setup_action.execute(params)
678
788
  self._get_by_link(job_link)
679
789
  return self
680
790
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pinexq-client
3
- Version: 0.9.2.20250515.43
3
+ Version: 0.9.2.20250716.44
4
4
  Summary: A hypermedia-based client for the DataCybernetics PinexQ platform.
5
5
  Author-Email: =?utf-8?q?Sebastian_H=C3=B6fer?= <hoefer@data-cybernetics.com>, Mathias Reichardt <reichardt@data-cybernetics.com>, Jasim Ahmed <ahmed@data-cybernetics.com>, Pratik Poudel <poudel@data-cybernetics.com>
6
6
  Maintainer-Email: Mathias Reichardt <reichardt@data-cybernetics.com>, =?utf-8?q?Sebastian_H=C3=B6fer?= <hoefer@data-cybernetics.com>, Carsten Blank <blank@data-cybernetics.com>
@@ -1,7 +1,7 @@
1
- pinexq_client-0.9.2.20250515.43.dist-info/METADATA,sha256=0WwpBhk9GA6PUPIi3nDnyX9fvaaRIb9nloEjn2OVsBk,3279
2
- pinexq_client-0.9.2.20250515.43.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- pinexq_client-0.9.2.20250515.43.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- pinexq_client-0.9.2.20250515.43.dist-info/licenses/LICENSE,sha256=3oz3tAhM7kOgRukkRe7wmh5T_HihZY77ZtJDJm91ZN8,1072
1
+ pinexq_client-0.9.2.20250716.44.dist-info/METADATA,sha256=d2Xxx8jzezOpdVEJrGiLUdb5b7Y5mB5S5x6WCb8pn6g,3279
2
+ pinexq_client-0.9.2.20250716.44.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ pinexq_client-0.9.2.20250716.44.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ pinexq_client-0.9.2.20250716.44.dist-info/licenses/LICENSE,sha256=3oz3tAhM7kOgRukkRe7wmh5T_HihZY77ZtJDJm91ZN8,1072
5
5
  pinexq_client/core/__init__.py,sha256=zO9vUuAl6AEokL-SqQO3Jl1qrxFBZPA2kH99VNZugEU,598
6
6
  pinexq_client/core/base_relations.py,sha256=oIUS58pkbMDdqm-3YOdsenhL1smtzeAk4fp7-U595MY,162
7
7
  pinexq_client/core/enterapi.py,sha256=eB4F2_t3lCbMgKhy-M-Sf_u9MhuJMO7OGh-GB-4Cc-8,731
@@ -46,8 +46,8 @@ pinexq_client/job_management/model/__init__.py,sha256=iuAKRXdW_Mxo0i3HsBfEzhJJZU
46
46
  pinexq_client/job_management/model/open_api_generated.py,sha256=s-XtnhuK5YmBhbOqKsy09iRKrQMtZL6-N2be-g5d8QU,33211
47
47
  pinexq_client/job_management/model/sirenentities.py,sha256=MUjgByEwzQcrduCEJuNK85uAj8SLTdyaiKmnlB44h3E,3430
48
48
  pinexq_client/job_management/tool/__init__.py,sha256=zPobd-hQyANHzC0-TjJG91z9XrewvE54ZJ6VViymW5M,128
49
- pinexq_client/job_management/tool/job.py,sha256=p9WDfJiIcQMZyLfNajpxK9kSd0DqF2H9hoS7lvDIFC0,25496
49
+ pinexq_client/job_management/tool/job.py,sha256=yVEVE3RRalQy8abA2G1X-a1Tj3v32YCsDeN52LDMSp8,30572
50
50
  pinexq_client/job_management/tool/job_group.py,sha256=TNWw46UDyP2gmArhbzMAqpHa6lS2hzwarLIrxxpOMnk,4822
51
51
  pinexq_client/job_management/tool/processing_step.py,sha256=LLesEbS7vaAiCoGs7MV8bnaD8bWnkK-2YTxAsyPiJFM,10796
52
52
  pinexq_client/job_management/tool/workdata.py,sha256=wRy_yfFZUJDh-hoGUuAbQaRGtPysDmEOhLwD84Fgz04,5510
53
- pinexq_client-0.9.2.20250515.43.dist-info/RECORD,,
53
+ pinexq_client-0.9.2.20250716.44.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.4.4)
2
+ Generator: pdm-backend (2.4.5)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any