pinexq-client 0.3.0.20240620.2__py3-none-any.whl → 0.4.2.20241009.1__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.
- pinexq_client/core/enterapi.py +8 -9
- pinexq_client/core/exceptions.py +73 -2
- pinexq_client/core/hco/action_hco.py +12 -22
- pinexq_client/core/hco/action_with_parameters_hco.py +15 -21
- pinexq_client/core/hco/download_link_hco.py +2 -3
- pinexq_client/core/hco/hco_base.py +2 -3
- pinexq_client/core/hco/link_hco.py +10 -9
- pinexq_client/core/hco/unavailable.py +17 -0
- pinexq_client/core/hco/upload_action_hco.py +11 -10
- pinexq_client/core/model/error.py +5 -1
- pinexq_client/core/sirenaccess.py +18 -27
- pinexq_client/job_management/__init__.py +1 -1
- pinexq_client/job_management/enterjma.py +2 -4
- pinexq_client/job_management/hcos/entrypoint_hco.py +36 -35
- pinexq_client/job_management/hcos/input_dataslot_hco.py +53 -51
- pinexq_client/job_management/hcos/job_hco.py +121 -120
- pinexq_client/job_management/hcos/job_query_result_hco.py +72 -47
- pinexq_client/job_management/hcos/jobsroot_hco.py +44 -42
- pinexq_client/job_management/hcos/output_dataslot_hco.py +1 -1
- pinexq_client/job_management/hcos/processing_step_hco.py +71 -70
- pinexq_client/job_management/hcos/processingstep_query_result_hco.py +76 -51
- pinexq_client/job_management/hcos/processingsteproot_hco.py +44 -43
- pinexq_client/job_management/hcos/workdata_hco.py +81 -80
- pinexq_client/job_management/hcos/workdata_query_result_hco.py +75 -52
- pinexq_client/job_management/hcos/workdataroot_hco.py +53 -52
- pinexq_client/job_management/model/open_api_generated.py +3 -1
- pinexq_client/job_management/tool/job.py +108 -11
- pinexq_client/job_management/tool/job_group.py +158 -0
- pinexq_client/job_management/tool/processing_step.py +83 -5
- pinexq_client/job_management/tool/workdata.py +8 -0
- {pinexq_client-0.3.0.20240620.2.dist-info → pinexq_client-0.4.2.20241009.1.dist-info}/METADATA +2 -2
- pinexq_client-0.4.2.20241009.1.dist-info/RECORD +53 -0
- {pinexq_client-0.3.0.20240620.2.dist-info → pinexq_client-0.4.2.20241009.1.dist-info}/WHEEL +1 -1
- pinexq_client-0.4.2.20241009.1.dist-info/entry_points.txt +4 -0
- pinexq_client-0.3.0.20240620.2.dist-info/RECORD +0 -50
- {pinexq_client-0.3.0.20240620.2.dist-info → pinexq_client-0.4.2.20241009.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,64 +1,89 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import List, Iterator, Self
|
|
2
2
|
|
|
3
3
|
import httpx
|
|
4
4
|
|
|
5
5
|
from pinexq_client.core.hco.hco_base import Hco, Property
|
|
6
6
|
from pinexq_client.core.hco.link_hco import LinkHco
|
|
7
|
+
from pinexq_client.core.hco.unavailable import UnavailableLink
|
|
7
8
|
from pinexq_client.job_management.hcos.job_hco import JobHco
|
|
8
9
|
from pinexq_client.job_management.known_relations import Relations
|
|
9
10
|
from pinexq_client.job_management.model.sirenentities import JobQueryResultEntity, JobEntity
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class JobQueryResultPaginationLink(LinkHco):
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
def navigate(self) -> 'JobQueryResultHco':
|
|
15
|
+
return JobQueryResultHco.from_entity(self._client, self._navigate_internal(JobQueryResultEntity))
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class JobQueryResultLink(LinkHco):
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
def navigate(self) -> 'JobQueryResultHco':
|
|
20
|
+
return JobQueryResultHco.from_entity(self._client, self._navigate_internal(JobQueryResultEntity))
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
class JobQueryResultHco(Hco[JobQueryResultEntity]):
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
24
|
+
self_link: JobQueryResultLink
|
|
25
|
+
all_link: JobQueryResultPaginationLink | UnavailableLink
|
|
26
|
+
first_link: JobQueryResultPaginationLink | UnavailableLink
|
|
27
|
+
last_link: JobQueryResultPaginationLink | UnavailableLink
|
|
28
|
+
next_link: JobQueryResultPaginationLink | UnavailableLink
|
|
29
|
+
previous_link: JobQueryResultPaginationLink | UnavailableLink
|
|
30
|
+
|
|
31
|
+
total_entities: int = Property()
|
|
32
|
+
current_entities_count: int = Property()
|
|
33
|
+
jobs: List[JobHco]
|
|
34
|
+
remaining_tags: List[str] | None = Property()
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_entity(cls, client: httpx.Client, entity: JobQueryResultEntity) -> 'JobQueryResultHco':
|
|
38
|
+
instance = cls(client, entity)
|
|
39
|
+
|
|
40
|
+
Hco.check_classes(instance._entity.class_, ["JobQueryResult"])
|
|
41
|
+
|
|
42
|
+
# pagination links
|
|
43
|
+
instance.self_link = JobQueryResultLink.from_entity(instance._client, instance._entity, Relations.SELF)
|
|
44
|
+
instance.all_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
|
|
45
|
+
Relations.ALL)
|
|
46
|
+
instance.first_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
|
|
47
|
+
Relations.FIRST)
|
|
48
|
+
instance.last_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
|
|
49
|
+
Relations.LAST)
|
|
50
|
+
instance.next_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
|
|
51
|
+
Relations.NEXT)
|
|
52
|
+
instance.previous_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
|
|
53
|
+
Relations.PREVIOUS)
|
|
54
|
+
|
|
55
|
+
# entities
|
|
56
|
+
instance._extract_jobs()
|
|
57
|
+
|
|
58
|
+
return instance
|
|
59
|
+
|
|
60
|
+
def _extract_jobs(self):
|
|
61
|
+
self.jobs = []
|
|
62
|
+
jobs = self._entity.find_all_entities_with_relation(Relations.ITEM, JobEntity)
|
|
63
|
+
for job in jobs:
|
|
64
|
+
job_hco: JobHco = JobHco.from_entity(job, self._client)
|
|
65
|
+
self.jobs.append(job_hco)
|
|
66
|
+
|
|
67
|
+
def iter(self) -> Iterator[Self]:
|
|
68
|
+
"""
|
|
69
|
+
Returns an Iterator of `JobQueryResultHco` so that all pages can be processed in a loop.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
An iterator of `JobQueryResultHco` objects
|
|
73
|
+
"""
|
|
74
|
+
result = self
|
|
75
|
+
while result is not None:
|
|
76
|
+
yield result
|
|
77
|
+
if isinstance(result.next_link, UnavailableLink):
|
|
78
|
+
return
|
|
79
|
+
result = result.next_link.navigate()
|
|
80
|
+
|
|
81
|
+
def iter_flat(self) -> Iterator[JobHco]:
|
|
82
|
+
"""
|
|
83
|
+
Returns an Iterator of `JobHco` so that all jobs can be processed in a loop.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
An iterator of `JobHco` objects
|
|
87
|
+
"""
|
|
88
|
+
for page in self.iter():
|
|
89
|
+
yield from page.jobs
|
|
@@ -7,74 +7,76 @@ from pinexq_client.core import MediaTypes, Link
|
|
|
7
7
|
from pinexq_client.core.hco.action_with_parameters_hco import ActionWithParametersHco
|
|
8
8
|
from pinexq_client.core.hco.hco_base import Hco
|
|
9
9
|
from pinexq_client.core.hco.link_hco import LinkHco
|
|
10
|
+
from pinexq_client.core.hco.unavailable import UnavailableAction, UnavailableLink
|
|
10
11
|
from pinexq_client.job_management.hcos.job_hco import JobLink
|
|
11
12
|
from pinexq_client.job_management.hcos.job_query_result_hco import (
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
JobQueryResultHco,
|
|
14
|
+
JobQueryResultLink
|
|
14
15
|
)
|
|
15
16
|
from pinexq_client.job_management.hcos.job_used_tags_hco import JobUsedTagsLink
|
|
16
17
|
from pinexq_client.job_management.known_relations import Relations
|
|
17
18
|
from pinexq_client.job_management.model.open_api_generated import (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
CreateJobParameters,
|
|
20
|
+
JobQueryParameters,
|
|
21
|
+
CreateSubJobParameters
|
|
21
22
|
)
|
|
22
23
|
from pinexq_client.job_management.model.sirenentities import JobsRootEntity
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
class CreateJobAction(ActionWithParametersHco[CreateJobParameters]):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
def execute(self, parameters: CreateJobParameters) -> JobLink:
|
|
28
|
+
url: URL = self._execute_returns_url(parameters)
|
|
29
|
+
link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created job", MediaTypes.SIREN)
|
|
30
|
+
return JobLink.from_link(self._client, link)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
def default_parameters(self) -> CreateJobParameters:
|
|
33
|
+
return self._get_default_parameters(CreateJobParameters, CreateJobParameters())
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
class CreateSubJobAction(ActionWithParametersHco[CreateSubJobParameters]):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
def execute(self, parameters: CreateSubJobParameters) -> JobLink:
|
|
38
|
+
url = self._execute_returns_url(parameters)
|
|
39
|
+
link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created sub-job", MediaTypes.SIREN)
|
|
40
|
+
return JobLink.from_link(self._client, link)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
def default_parameters(self) -> CreateSubJobParameters:
|
|
43
|
+
return self._get_default_parameters(CreateSubJobParameters, CreateSubJobParameters())
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
class JobQueryAction(ActionWithParametersHco):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
def execute(self, parameters: JobQueryParameters) -> JobQueryResultHco:
|
|
48
|
+
url = self._execute_returns_url(parameters)
|
|
49
|
+
link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created job query", MediaTypes.SIREN)
|
|
50
|
+
# resolve link immediately
|
|
51
|
+
return JobQueryResultLink.from_link(self._client, link).navigate()
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
def default_parameters(self) -> JobQueryParameters:
|
|
54
|
+
return self._get_default_parameters(JobQueryParameters, JobQueryParameters())
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
class JobsRootHco(Hco[JobsRootEntity]):
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
create_job_action: CreateJobAction | UnavailableAction
|
|
59
|
+
job_query_action: JobQueryAction | UnavailableAction
|
|
60
|
+
create_subjob_action: CreateSubJobAction | UnavailableAction
|
|
61
|
+
used_tags_link: JobUsedTagsLink | UnavailableLink
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
self_link: 'JobsRootLink'
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
@classmethod
|
|
66
|
+
def from_entity(cls, entity: JobsRootEntity, client: httpx.Client) -> Self:
|
|
67
|
+
instance = cls(client, entity)
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
Hco.check_classes(instance._entity.class_, ["JobsRoot"])
|
|
70
|
+
instance.create_job_action = CreateJobAction.from_entity_optional(client, instance._entity, "CreateJob")
|
|
71
|
+
instance.create_subjob_action = CreateSubJobAction.from_entity_optional(client, instance._entity,
|
|
72
|
+
"CreateSubJob")
|
|
73
|
+
instance.job_query_action = JobQueryAction.from_entity_optional(client, instance._entity, "CreateJobQuery")
|
|
74
|
+
instance.used_tags_link = JobUsedTagsLink.from_entity_optional(
|
|
75
|
+
instance._client, instance._entity, Relations.USED_TAGS)
|
|
76
|
+
instance.self_link = JobsRootLink.from_entity(instance._client, instance._entity, Relations.SELF)
|
|
77
|
+
return instance
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
class JobsRootLink(LinkHco):
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
def navigate(self) -> JobsRootHco:
|
|
82
|
+
return JobsRootHco.from_entity(self._navigate_internal(JobsRootEntity), self._client)
|
|
@@ -21,7 +21,7 @@ class OutputDataSlotHco(Hco[OutputDataSlotEntity]):
|
|
|
21
21
|
title: str | None = Property()
|
|
22
22
|
description: str | None = Property()
|
|
23
23
|
media_type: str | None = Property()
|
|
24
|
-
|
|
24
|
+
assigned_workdatas: list[WorkDataHco]
|
|
25
25
|
|
|
26
26
|
@classmethod
|
|
27
27
|
def from_entity(cls, entity: OutputDataSlotEntity, client: httpx.Client) -> Self:
|
|
@@ -10,105 +10,106 @@ from pinexq_client.core.hco.action_with_parameters_hco import ActionWithParamete
|
|
|
10
10
|
from pinexq_client.core.hco.download_link_hco import DownloadLinkHco
|
|
11
11
|
from pinexq_client.core.hco.hco_base import Hco, Property
|
|
12
12
|
from pinexq_client.core.hco.link_hco import LinkHco
|
|
13
|
+
from pinexq_client.core.hco.unavailable import UnavailableAction
|
|
13
14
|
from pinexq_client.core.hco.upload_action_hco import UploadAction, UploadParameters
|
|
14
15
|
from pinexq_client.job_management.known_relations import Relations
|
|
15
16
|
from pinexq_client.job_management.model import EditProcessingStepParameters
|
|
16
17
|
from pinexq_client.job_management.model.open_api_generated import DataSpecificationHto, \
|
|
17
|
-
|
|
18
|
+
SetProcessingStepTagsParameters
|
|
18
19
|
from pinexq_client.job_management.model.sirenentities import ProcessingStepEntity
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class ProcessingStepLink(LinkHco):
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
def navigate(self) -> 'ProcessingStepHco':
|
|
24
|
+
return ProcessingStepHco.from_entity(self._navigate_internal(ProcessingStepEntity), self._client)
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class ProcessingStepEditTagsAction(ActionWithParametersHco[SetProcessingStepTagsParameters]):
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
def execute(self, parameters: SetProcessingStepTagsParameters):
|
|
29
|
+
self._execute(parameters)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
def default_parameters(self) -> SetProcessingStepTagsParameters:
|
|
32
|
+
# todo check why we have to manually set tags
|
|
33
|
+
return self._get_default_parameters(SetProcessingStepTagsParameters, SetProcessingStepTagsParameters(tags=[]))
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
class ProcessingStepEditPropertiesAction(ActionWithParametersHco[EditProcessingStepParameters]):
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
def execute(self, parameters: EditProcessingStepParameters):
|
|
38
|
+
self._execute(parameters)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
def default_parameters(self) -> EditProcessingStepParameters:
|
|
41
|
+
return self._get_default_parameters(EditProcessingStepParameters, EditProcessingStepParameters())
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
class GenericProcessingConfigureParameters(BaseModel):
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
"""Generic parameter model, that can be set with any dictionary"""
|
|
46
|
+
model_config = ConfigDict(extra='allow')
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
class ConfigureDefaultParametersAction(ActionWithParametersHco[GenericProcessingConfigureParameters]):
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
def execute(self, parameters: GenericProcessingConfigureParameters):
|
|
51
|
+
self._execute(parameters)
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
def default_parameters(self) -> GenericProcessingConfigureParameters:
|
|
54
|
+
return self._get_default_parameters(GenericProcessingConfigureParameters,
|
|
55
|
+
GenericProcessingConfigureParameters())
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
class ClearDefaultParametersAction(ActionHco):
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
def execute(self):
|
|
60
|
+
self._execute_internal()
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
class UploadConfigurationAction(UploadAction):
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
def execute(self, parameters: UploadParameters):
|
|
65
|
+
upload_json(self._client, self._action, parameters.json_, parameters.filename)
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
class ProcessingStepHco(Hco[ProcessingStepEntity]):
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
69
|
+
title: str = Property()
|
|
70
|
+
version: str | None = Property()
|
|
71
|
+
function_name: str | None = Property()
|
|
72
|
+
short_description: str | None = Property()
|
|
73
|
+
long_description: str | None = Property()
|
|
74
|
+
tags: list[str] | None = Property()
|
|
75
|
+
has_parameters: bool | None = Property()
|
|
76
|
+
is_public: bool | None = Property()
|
|
77
|
+
is_configured: bool | None = Property()
|
|
78
|
+
created_at: datetime | None = Property()
|
|
79
|
+
last_modified_at: datetime | None = Property()
|
|
80
|
+
parameter_schema: str | None = Property()
|
|
81
|
+
default_parameters: str | None = Property()
|
|
82
|
+
return_schema: str | None = Property()
|
|
83
|
+
error_schema: str | None = Property()
|
|
84
|
+
input_data_slot_specification: List[DataSpecificationHto] | None = Property()
|
|
85
|
+
output_data_slot_specification: List[DataSpecificationHto] | None = Property()
|
|
86
|
+
edit_tags_action: ProcessingStepEditTagsAction | UnavailableAction
|
|
87
|
+
edit_properties_action: ProcessingStepEditPropertiesAction | UnavailableAction
|
|
88
|
+
configure_default_parameters_action: ConfigureDefaultParametersAction | UnavailableAction
|
|
89
|
+
clear_default_parameters_action: ClearDefaultParametersAction | UnavailableAction
|
|
90
|
+
upload_configuration_action: UploadConfigurationAction | None
|
|
91
|
+
|
|
92
|
+
self_link: ProcessingStepLink
|
|
93
|
+
download_link: DownloadLinkHco
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_entity(cls, entity: ProcessingStepEntity, client: httpx.Client) -> Self:
|
|
97
|
+
instance = cls(client, entity)
|
|
98
|
+
Hco.check_classes(instance._entity.class_, ["ProcessingStep"])
|
|
99
|
+
|
|
100
|
+
instance.self_link = ProcessingStepLink.from_entity(instance._client, instance._entity, Relations.SELF)
|
|
101
|
+
instance.download_link = DownloadLinkHco.from_entity(instance._client, instance._entity, Relations.DOWNLOAD)
|
|
102
|
+
|
|
103
|
+
# todo tests
|
|
104
|
+
|
|
105
|
+
instance.edit_tags_action = ProcessingStepEditTagsAction.from_entity_optional(
|
|
106
|
+
client, instance._entity, "EditTags")
|
|
107
|
+
instance.edit_properties_action = ProcessingStepEditPropertiesAction.from_entity_optional(
|
|
108
|
+
client, instance._entity, "EditProperties")
|
|
109
|
+
instance.configure_default_parameters_action = ConfigureDefaultParametersAction.from_entity_optional(
|
|
110
|
+
client, instance._entity, "ConfigureDefaultParameters")
|
|
111
|
+
instance.clear_default_parameters_action = ClearDefaultParametersAction.from_entity_optional(
|
|
112
|
+
client, instance._entity, "ClearDefaultParameters")
|
|
113
|
+
instance.upload_configuration_action = UploadConfigurationAction.from_entity_optional(
|
|
114
|
+
client, instance._entity, "Upload")
|
|
115
|
+
return instance
|
|
@@ -1,69 +1,94 @@
|
|
|
1
|
-
from typing import Self, List
|
|
1
|
+
from typing import Self, List, Iterator
|
|
2
2
|
|
|
3
3
|
import httpx
|
|
4
4
|
|
|
5
5
|
from pinexq_client.core.hco.hco_base import Hco, Property
|
|
6
6
|
from pinexq_client.core.hco.link_hco import LinkHco
|
|
7
|
+
from pinexq_client.core.hco.unavailable import UnavailableLink
|
|
7
8
|
from pinexq_client.job_management.hcos.processing_step_hco import ProcessingStepHco
|
|
8
9
|
from pinexq_client.job_management.known_relations import Relations
|
|
9
10
|
from pinexq_client.job_management.model.sirenentities import (
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
ProcessingStepQueryResultEntity,
|
|
12
|
+
ProcessingStepEntity
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class ProcessingStepQueryResultPaginationLink(LinkHco):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
def navigate(self) -> 'ProcessingStepQueryResultHco':
|
|
18
|
+
return ProcessingStepQueryResultHco.from_entity(self._navigate_internal(ProcessingStepQueryResultEntity),
|
|
19
|
+
self._client)
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class ProcessingStepQueryResultLink(LinkHco):
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
def navigate(self) -> 'ProcessingStepQueryResultHco':
|
|
24
|
+
return ProcessingStepQueryResultHco.from_entity(self._navigate_internal(ProcessingStepQueryResultEntity),
|
|
25
|
+
self._client)
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class ProcessingStepQueryResultHco(Hco[ProcessingStepQueryResultEntity]):
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
29
|
+
total_entities: int = Property()
|
|
30
|
+
current_entities_count: int = Property()
|
|
31
|
+
processing_steps: list[ProcessingStepHco]
|
|
32
|
+
remaining_tags: List[str] | None = Property()
|
|
33
|
+
|
|
34
|
+
self_link: ProcessingStepQueryResultLink
|
|
35
|
+
all_link: ProcessingStepQueryResultPaginationLink | UnavailableLink
|
|
36
|
+
first_link: ProcessingStepQueryResultPaginationLink | UnavailableLink
|
|
37
|
+
last_link: ProcessingStepQueryResultPaginationLink | UnavailableLink
|
|
38
|
+
next_link: ProcessingStepQueryResultPaginationLink | UnavailableLink
|
|
39
|
+
previous_link: ProcessingStepQueryResultPaginationLink | UnavailableLink
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def from_entity(cls, entity: ProcessingStepQueryResultEntity, client: httpx.Client) -> Self:
|
|
43
|
+
instance = cls(client, entity)
|
|
44
|
+
|
|
45
|
+
Hco.check_classes(instance._entity.class_, ["ProcessingStepQueryResult"])
|
|
46
|
+
|
|
47
|
+
# pagination links
|
|
48
|
+
instance.self_link = ProcessingStepQueryResultLink.from_entity(
|
|
49
|
+
instance._client, instance._entity, Relations.SELF)
|
|
50
|
+
instance.all_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
|
|
51
|
+
instance._client, instance._entity, Relations.ALL)
|
|
52
|
+
instance.first_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
|
|
53
|
+
instance._client, instance._entity, Relations.FIRST)
|
|
54
|
+
instance.last_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
|
|
55
|
+
instance._client, instance._entity, Relations.LAST)
|
|
56
|
+
instance.next_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
|
|
57
|
+
instance._client, instance._entity, Relations.NEXT)
|
|
58
|
+
instance.previous_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
|
|
59
|
+
instance._client, instance._entity, Relations.PREVIOUS)
|
|
60
|
+
|
|
61
|
+
instance._extract_processing_steps()
|
|
62
|
+
|
|
63
|
+
return instance
|
|
64
|
+
|
|
65
|
+
def _extract_processing_steps(self):
|
|
66
|
+
self.processing_steps = []
|
|
67
|
+
processing_steps = self._entity.find_all_entities_with_relation(Relations.ITEM, ProcessingStepEntity)
|
|
68
|
+
for processing_step in processing_steps:
|
|
69
|
+
processing_step_hco: ProcessingStepHco = ProcessingStepHco.from_entity(processing_step, self._client)
|
|
70
|
+
self.processing_steps.append(processing_step_hco)
|
|
71
|
+
|
|
72
|
+
def iter(self) -> Iterator[Self]:
|
|
73
|
+
"""
|
|
74
|
+
Returns an Iterator of `ProcessingStepQueryResultHco` objects so that all pages can be processed in a loop.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
An iterator of `ProcessingStepQueryResultHco` objects
|
|
78
|
+
"""
|
|
79
|
+
result = self
|
|
80
|
+
while result is not None:
|
|
81
|
+
yield result
|
|
82
|
+
if isinstance(result.next_link, UnavailableLink):
|
|
83
|
+
return
|
|
84
|
+
result = result.next_link.navigate()
|
|
85
|
+
|
|
86
|
+
def iter_flat(self) -> Iterator[ProcessingStepHco]:
|
|
87
|
+
"""
|
|
88
|
+
Returns an Iterator of `ProcessingStepHco` objects so that all processing steps can be processed in a loop.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
An iterator of `ProcessingStepHco` objects
|
|
92
|
+
"""
|
|
93
|
+
for page in self.iter():
|
|
94
|
+
yield from page.processing_steps
|