@orcabus/platform-cdk-constructs 0.0.34 → 0.0.36

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 (38) hide show
  1. package/.jsii +2 -2
  2. package/api-gateway/api-gateway.js +1 -1
  3. package/deployment-stack-pipeline/artifact-bucket.js +1 -1
  4. package/deployment-stack-pipeline/pipeline.js +1 -1
  5. package/dynamodb/index.js +2 -2
  6. package/ecs/index.js +1 -1
  7. package/lambda/index.js +1 -1
  8. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/data_sharing/__init__.py +70 -0
  9. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/data_sharing/globals.py +15 -0
  10. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/data_sharing/models.py +28 -0
  11. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/data_sharing/update_helpers.py +53 -0
  12. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/__init__.py +12 -2
  13. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/create_helpers.py +22 -5
  14. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/globals.py +1 -1
  15. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/job_helpers.py +16 -4
  16. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/models.py +80 -24
  17. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/query_helpers.py +25 -14
  18. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/update_helpers.py +42 -18
  19. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq/workflow_helpers.py +3 -2
  20. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_decompression/create_helpers.py +14 -14
  21. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_decompression/models.py +7 -0
  22. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/__init__.py +4 -1
  23. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/create_helpers.py +2 -2
  24. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/globals.py +0 -8
  25. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/models.py +13 -14
  26. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/query_helpers.py +3 -3
  27. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/fastq_unarchiving/update_helpers.py +3 -3
  28. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/filemanager/__init__.py +2 -0
  29. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/filemanager/file_helpers.py +18 -11
  30. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/filemanager/globals.py +0 -28
  31. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/filemanager/models.py +24 -2
  32. package/lambda/layers/orcabus_api_tools/src/orcabus_api_tools/utils/requests_helpers.py +9 -2
  33. package/monitored-queue/index.js +1 -1
  34. package/named-lambda-role/index.js +1 -1
  35. package/package.json +1 -1
  36. package/provider-function/index.js +1 -1
  37. package/shared-config/networking.js +2 -2
  38. package/shared-config/slack.js +1 -1
@@ -25,20 +25,22 @@ from typing import List, Unpack
25
25
  from fastapi.encoders import jsonable_encoder
26
26
 
27
27
  from . import get_fastq_request_response_results, get_fastq_request
28
- from .globals import FASTQ_LIST_ROW_ENDPOINT, FASTQ_SET_ENDPOINT
29
- from .models import FastqListRow, FastqSet, Job, FastqListRowQueryParameters, FastqSetQueryParameters, \
30
- FastqGetResponseParameters, VALID_BATCH_KEYS
28
+ from .globals import FASTQ_ENDPOINT, FASTQ_SET_ENDPOINT
29
+ from .models import (
30
+ FastqSet, Job, FastqParameters, FastqSetQueryParameters,
31
+ FastqGetResponseParameters, VALID_BATCH_KEYS, Fastq
32
+ )
31
33
 
32
34
 
33
- def get_fastq(fastq_id: str, **kwargs: Unpack[FastqGetResponseParameters]) -> FastqListRow:
35
+ def get_fastq(fastq_id: str, **kwargs: Unpack[FastqGetResponseParameters]) -> Fastq:
34
36
  # Raise error if any of the kwargs are not in the FastqSetQueryParameters
35
37
  for key in kwargs.keys():
36
38
  if key not in FastqGetResponseParameters.__annotations__:
37
39
  raise ValueError(f"Invalid parameter: {key}")
38
40
 
39
- return FastqListRow(
41
+ return Fastq(
40
42
  **get_fastq_request(
41
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}",
43
+ f"{FASTQ_ENDPOINT}/{fastq_id}",
42
44
  params=dict(kwargs)
43
45
  )
44
46
  )
@@ -67,17 +69,17 @@ def get_fastq_set(
67
69
  )
68
70
 
69
71
 
70
- def get_fastqs(**kwargs: Unpack[FastqListRowQueryParameters]) -> List[FastqListRow]:
72
+ def get_fastqs(**kwargs: Unpack[FastqParameters]) -> List[Fastq]:
71
73
  """
72
74
  Get all fastqs
73
75
  """
74
- # Raise error if any of the kwargs are not in the FastqListRowQueryParameters
76
+ # Raise error if any of the kwargs are not in the FastqParameters
75
77
  for key in kwargs.keys():
76
- if key not in FastqListRowQueryParameters.__annotations__:
78
+ if key not in FastqParameters.__annotations__:
77
79
  raise ValueError(f"Invalid parameter: {key}")
78
80
 
79
81
  return get_fastq_request_response_results(
80
- FASTQ_LIST_ROW_ENDPOINT,
82
+ FASTQ_ENDPOINT,
81
83
  params=dict(kwargs)
82
84
  )
83
85
 
@@ -89,7 +91,7 @@ def get_fastq_sets(**kwargs: Unpack[FastqSetQueryParameters]) -> List[FastqSet]:
89
91
  :param kwargs:
90
92
  :return:
91
93
  """
92
- # Raise error if any of the kwargs are not in the FastqListRowQueryParameters
94
+ # Raise error if any of the kwargs are not in the FastqParameters
93
95
  for key in kwargs.keys():
94
96
  if key not in FastqSetQueryParameters.__annotations__:
95
97
  raise ValueError(f"Invalid parameter: {key}")
@@ -123,7 +125,7 @@ def get_fastqs_batched(
123
125
  item_list: List[str],
124
126
  batch_size: int = 100,
125
127
  **kwargs
126
- ) -> List[FastqListRow]:
128
+ ) -> List[Fastq]:
127
129
  """
128
130
  Get all fastqs in a list of libraries
129
131
  """
@@ -153,7 +155,7 @@ def get_fastqs_batched(
153
155
 
154
156
  def get_fastqs_in_library_list(
155
157
  library_id_list: List[str]
156
- ) -> List[FastqListRow]:
158
+ ) -> List[Fastq]:
157
159
  """
158
160
  Get all fastqs in a list of libraries
159
161
  """
@@ -229,8 +231,17 @@ def get_fastqs_in_project(project_id):
229
231
 
230
232
 
231
233
  def get_fastq_list_rows_in_fastq_set(fastq_set_id):
234
+ """
235
+ DEPRECATED: Use get_fastqs_in_fastq_set instead
236
+ """
237
+ return get_fastqs_in_fastq_set(fastq_set_id)
238
+
239
+
240
+ def get_fastqs_in_fastq_set(fastq_set_id: str) -> List[Fastq]:
232
241
  """
233
242
  Get all fastqs in a fastq set
243
+ :param fastq_set_id:
244
+ :return:
234
245
  """
235
246
  return get_fastqs(
236
247
  fastqSetId=fastq_set_id
@@ -244,6 +255,6 @@ def get_fastq_jobs(fastq_id: str) -> List[Job]:
244
255
  return list(map(
245
256
  lambda job_iter_: Job(**job_iter_),
246
257
  get_fastq_request_response_results(
247
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/jobs"
258
+ f"{FASTQ_ENDPOINT}/{fastq_id}/jobs"
248
259
  )
249
260
  ))
@@ -15,15 +15,15 @@ Update helpers for the update script.
15
15
 
16
16
  # Local imports
17
17
  from . import fastq_patch_request
18
- from .globals import FASTQ_LIST_ROW_ENDPOINT, FASTQ_SET_ENDPOINT
18
+ from .globals import FASTQ_ENDPOINT, FASTQ_SET_ENDPOINT
19
19
  from .models import (
20
- QcStats, FastqListRow, ReadCount,
20
+ QcStats, Fastq, ReadCount,
21
21
  FileCompressionInformation, FileStorageObject, ReadSet,
22
22
  FastqSet
23
23
  )
24
24
 
25
25
 
26
- def add_qc_stats(fastq_id: str, qc_stats: QcStats) -> FastqListRow:
26
+ def add_qc_stats(fastq_id: str, qc_stats: QcStats) -> Fastq:
27
27
  """
28
28
  Add QC stats to a fastq_id.
29
29
 
@@ -36,12 +36,12 @@ def add_qc_stats(fastq_id: str, qc_stats: QcStats) -> FastqListRow:
36
36
  raise ValueError(f"Invalid parameter: {key}")
37
37
 
38
38
  return fastq_patch_request(
39
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/addQcStats",
39
+ f"{FASTQ_ENDPOINT}/{fastq_id}/addQcStats",
40
40
  params=dict(qc_stats)
41
41
  )
42
42
 
43
43
 
44
- def add_read_count(fastq_id: str, read_count: ReadCount) -> FastqListRow:
44
+ def add_read_count(fastq_id: str, read_count: ReadCount) -> Fastq:
45
45
  """
46
46
  Add read count to a fastq id
47
47
  :param fastq_id:
@@ -53,12 +53,12 @@ def add_read_count(fastq_id: str, read_count: ReadCount) -> FastqListRow:
53
53
  raise ValueError(f"Invalid parameter: {key}")
54
54
 
55
55
  return fastq_patch_request(
56
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/addReadCount",
56
+ f"{FASTQ_ENDPOINT}/{fastq_id}/addReadCount",
57
57
  params=dict(read_count)
58
58
  )
59
59
 
60
60
 
61
- def add_file_compression_information(fastq_id: str, file_compression_information: FileCompressionInformation) -> FastqListRow:
61
+ def add_file_compression_information(fastq_id: str, file_compression_information: FileCompressionInformation) -> Fastq:
62
62
  """
63
63
  Add file compression information to a fastq id
64
64
  :param fastq_id:
@@ -70,12 +70,12 @@ def add_file_compression_information(fastq_id: str, file_compression_information
70
70
  raise ValueError(f"Invalid parameter: {key}")
71
71
 
72
72
  return fastq_patch_request(
73
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/addFileCompressionInformation",
73
+ f"{FASTQ_ENDPOINT}/{fastq_id}/addFileCompressionInformation",
74
74
  params=dict(file_compression_information)
75
75
  )
76
76
 
77
77
 
78
- def add_ntsm_storage_object(fastq_id: str, ntsm_fastq_storage_object: FileStorageObject) -> FastqListRow:
78
+ def add_ntsm_storage_object(fastq_id: str, ntsm_fastq_storage_object: FileStorageObject) -> Fastq:
79
79
  """
80
80
  Add a Ntsm storage object to a fastq id.
81
81
 
@@ -87,12 +87,12 @@ def add_ntsm_storage_object(fastq_id: str, ntsm_fastq_storage_object: FileStorag
87
87
  raise ValueError(f"Invalid parameter: {key}")
88
88
 
89
89
  return fastq_patch_request(
90
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/addNtsmStorageObject",
90
+ f"{FASTQ_ENDPOINT}/{fastq_id}/addNtsmStorageObject",
91
91
  params=dict(ntsm_fastq_storage_object)
92
92
  )
93
93
 
94
94
 
95
- def add_read_set(fastq_id: str, read_set: ReadSet) -> FastqListRow:
95
+ def add_read_set(fastq_id: str, read_set: ReadSet) -> Fastq:
96
96
  """
97
97
  Add a read set to a fastq id.
98
98
 
@@ -104,48 +104,62 @@ def add_read_set(fastq_id: str, read_set: ReadSet) -> FastqListRow:
104
104
  raise ValueError(f"Invalid parameter: {key}")
105
105
 
106
106
  return fastq_patch_request(
107
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/addFastqPairStorageObject",
107
+ f"{FASTQ_ENDPOINT}/{fastq_id}/addFastqPairStorageObject",
108
108
  params=dict(read_set)
109
109
  )
110
110
 
111
111
 
112
- def detach_read_set(fastq_id: str) -> FastqListRow:
112
+ def detach_read_set(fastq_id: str) -> Fastq:
113
113
  """
114
114
  Detach a read set to a fastq id.
115
115
 
116
116
  :param fastq_id: Fastq str
117
117
  """
118
118
  return fastq_patch_request(
119
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/detachFastqPairStorageObject"
119
+ f"{FASTQ_ENDPOINT}/{fastq_id}/detachFastqPairStorageObject"
120
120
  )
121
121
 
122
122
 
123
- def validate_fastq(fastq_id: str) -> FastqListRow:
123
+ def validate_fastq(fastq_id: str) -> Fastq:
124
124
  """
125
125
  Validate a fastq id.
126
126
 
127
127
  :param fastq_id: Fastq str
128
128
  """
129
129
  return fastq_patch_request(
130
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/validate"
130
+ f"{FASTQ_ENDPOINT}/{fastq_id}/validate"
131
131
  )
132
132
 
133
133
 
134
- def invalidate_fastq(fastq_id: str) -> FastqListRow:
134
+ def invalidate_fastq(fastq_id: str) -> Fastq:
135
135
  """
136
136
  Invalidate a fastq id.
137
137
 
138
138
  :param fastq_id: Fastq str
139
139
  """
140
140
  return fastq_patch_request(
141
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/invalidate"
141
+ f"{FASTQ_ENDPOINT}/{fastq_id}/invalidate"
142
142
  )
143
143
 
144
144
 
145
145
  def link_fastq_list_row_to_fastq_set(fastq_id: str, fastq_set_id: str) -> FastqSet:
146
146
  """
147
+ Deprecated: Use `link_fastq_to_fast_set` instead.
147
148
  Link a fastq id to a fastq set.
148
149
 
150
+ :param fastq_id:
151
+ :param fastq_set_id:
152
+ :return:
153
+ """
154
+ return link_fastq_to_fastq_set(
155
+ fastq_id=fastq_id,
156
+ fastq_set_id=fastq_set_id
157
+ )
158
+
159
+
160
+ def link_fastq_to_fastq_set(fastq_id: str, fastq_set_id: str) -> FastqSet:
161
+ """
162
+ Link a fastq id to a fastq set.
149
163
  :param fastq_id:
150
164
  :param fastq_set_id:
151
165
  :return:
@@ -156,6 +170,16 @@ def link_fastq_list_row_to_fastq_set(fastq_id: str, fastq_set_id: str) -> FastqS
156
170
 
157
171
 
158
172
  def unlink_fastq_list_row_from_fastq_set(fastq_id: str, fastq_set_id: str) -> FastqSet:
173
+ """
174
+ Deprecated: Use `unlink_fastq_from_fastq_set` instead.
175
+ """
176
+ return unlink_fastq_from_fastq_set(
177
+ fastq_id=fastq_id,
178
+ fastq_set_id=fastq_set_id
179
+ )
180
+
181
+
182
+ def unlink_fastq_from_fastq_set(fastq_id: str, fastq_set_id: str) -> FastqSet:
159
183
  """
160
184
  Unlink a fastq id from a fastq set.
161
185
 
@@ -8,15 +8,16 @@ Workflow helpers - a collection of helper functions for the workflow
8
8
 
9
9
  # Standard library imports
10
10
  from typing import List
11
+
11
12
  # Local imports
12
13
  from . import get_fastq_request
13
- from .globals import FASTQ_LIST_ROW_ENDPOINT, FASTQ_SET_ENDPOINT
14
+ from .globals import FASTQ_ENDPOINT, FASTQ_SET_ENDPOINT
14
15
  from .models import FastqListRowDict
15
16
 
16
17
 
17
18
  def to_fastq_list_row(fastq_id) -> FastqListRowDict:
18
19
  return get_fastq_request(
19
- f"{FASTQ_LIST_ROW_ENDPOINT}/{fastq_id}/toFastqListRow"
20
+ f"{FASTQ_ENDPOINT}/{fastq_id}/toFastqListRow"
20
21
  )
21
22
 
22
23
  def to_fastq_list_rows(fastq_set_id: str) -> List[FastqListRowDict]:
@@ -4,31 +4,31 @@
4
4
  Create the job
5
5
  """
6
6
 
7
- from typing import List, Optional
7
+ from typing import List, Optional, Unpack
8
8
 
9
9
  from . import fastq_decompression_post_request
10
10
  from .globals import JOB_ENDPOINT
11
- from .models import Job, JobType
11
+ from .models import Job, JobType, JobCreateParameters
12
12
 
13
13
 
14
14
  def create_job(
15
- fastq_id_list: List[str],
16
- output_uri_prefix: str = None,
17
- job_type: Optional[JobType] = None,
15
+ **kwargs: Unpack[JobCreateParameters]
18
16
  ) -> Job:
19
17
  """
20
18
  Create the job
21
19
  """
22
- if job_type is None:
23
- job_type = 'FASTQ_DECOMPRESSION'
20
+
21
+ # Raise error if any of the kwargs are not in the FastqListRowQueryParameters
22
+ for key in kwargs.keys():
23
+ if key not in JobCreateParameters.__annotations__:
24
+ raise ValueError(f"Invalid parameter: {key}")
25
+
26
+ non_null_kwargs = dict(filter(
27
+ lambda kv_iter_: kv_iter_[1] is not None,
28
+ kwargs.items()
29
+ ))
24
30
 
25
31
  return fastq_decompression_post_request(
26
32
  JOB_ENDPOINT,
27
- params={
28
- "fastqIdList": fastq_id_list,
29
- "jobType": job_type,
30
- "outputUriPrefix": output_uri_prefix,
31
- }
33
+ params=non_null_kwargs
32
34
  )
33
-
34
-
@@ -80,6 +80,13 @@ class Job(TypedDict):
80
80
  outputs: NotRequired[JobOutputType]
81
81
 
82
82
 
83
+ class JobCreateParameters(TypedDict):
84
+ fastqIdList: List[str]
85
+ jobType: JobType
86
+ maxReads: NotRequired[int]
87
+ outputUriPrefix: NotRequired[str]
88
+
89
+
83
90
  class JobQueryParameters(TypedDict):
84
91
  fastqId: NotRequired[str]
85
92
  fastqSetId: NotRequired[str]
@@ -6,7 +6,10 @@ from typing import Dict, Optional
6
6
  # Local imports
7
7
  from .globals import FASTQ_UNARCHIVING_SUBDOMAIN_NAME
8
8
  from ..utils.requests_helpers import (
9
- get_request_response_results, get_url, patch_request, get_request
9
+ get_request_response_results,
10
+ get_url,
11
+ patch_request,
12
+ get_request
10
13
  )
11
14
 
12
15
 
@@ -16,12 +16,12 @@ def create_job(fastq_ids: List[str], job_type: Optional[JobType] = None) -> Job:
16
16
  Create the job
17
17
  """
18
18
  if job_type is None:
19
- job_type = JobType.S3_UNARCHIVING
19
+ job_type = 'S3_UNARCHIVING'
20
20
 
21
21
  return fastq_unarchiving_post_request(
22
22
  JOB_ENDPOINT,
23
23
  params={
24
24
  "fastqIds": fastq_ids,
25
- "jobType": job_type.value
25
+ "jobType": job_type
26
26
  }
27
27
  )
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
3
  import re
4
- from enum import Enum
5
4
 
6
5
  # AWS PARAMETERS
7
6
  FASTQ_UNARCHIVING_SUBDOMAIN_NAME = "fastq-unarchiving"
@@ -12,10 +11,3 @@ JOB_ENDPOINT = "api/v1/jobs"
12
11
  # REGEX
13
12
  ORCABUS_ULID_REGEX_MATCH = re.compile(r'^[a-z0-9]{3}\.[A-Z0-9]{26}$')
14
13
 
15
-
16
- class JobStatus(Enum):
17
- PENDING = "PENDING"
18
- RUNNING = "RUNNING"
19
- FAILED = "FAILED"
20
- ABORTED = "ABORTED"
21
- SUCCEEDED = "SUCCEEDED"
@@ -13,28 +13,27 @@
13
13
 
14
14
  from typing import (
15
15
  TypedDict, NotRequired,
16
+ Literal
16
17
  )
17
18
 
18
- from enum import Enum
19
+ JobType = Literal[
20
+ "S3_UNARCHIVING",
21
+ ]
19
22
 
20
23
 
21
- class JobType(Enum):
22
- S3_UNARCHIVING = "S3_UNARCHIVING"
23
-
24
-
25
- class JobStatus(Enum):
26
- PENDING = "PENDING"
27
- RUNNING = "RUNNING"
28
- FAILED = "FAILED"
29
- ABORTED = "ABORTED"
30
- SUCCEEDED = "SUCCEEDED"
31
-
24
+ JobStatusType = Literal[
25
+ "PENDING",
26
+ "RUNNING",
27
+ "FAILED",
28
+ "ABORTED",
29
+ "SUCCEEDED",
30
+ ]
32
31
 
33
32
  class Job(TypedDict):
34
33
  id: str
35
34
  jobType: JobType
36
35
  stepsExecutionArn: str
37
- status: JobStatus
36
+ status: JobStatusType
38
37
  startTime: str
39
38
  endTime: str
40
39
  errorMessages: str
@@ -42,7 +41,7 @@ class Job(TypedDict):
42
41
 
43
42
  class JobQueryParameters(TypedDict):
44
43
  fastqId: NotRequired[str]
45
- status: NotRequired[JobStatus]
44
+ status: NotRequired[JobStatusType]
46
45
  createdAfter: NotRequired[str]
47
46
  createdBefore: NotRequired[str]
48
47
  completedAfter: NotRequired[str]
@@ -14,7 +14,7 @@ from typing import List, Unpack
14
14
 
15
15
  # Local imports
16
16
  from . import get_fastq_unarchiving_request_response_results
17
- from .models import Job, JobStatus, JobQueryParameters
17
+ from .models import Job, JobStatusType, JobQueryParameters
18
18
 
19
19
  from .globals import JOB_ENDPOINT
20
20
 
@@ -40,7 +40,7 @@ def get_unarchiving_job_list(**kwargs: Unpack[JobQueryParameters]) -> List[Job]:
40
40
 
41
41
  def get_job_list_for_fastq(
42
42
  fastq_id: str,
43
- job_status: JobStatus
43
+ job_status: JobStatusType
44
44
  ) -> List[Job]:
45
45
  """
46
46
  Check if fastq in job list
@@ -48,5 +48,5 @@ def get_job_list_for_fastq(
48
48
  """
49
49
  return get_unarchiving_job_list(
50
50
  fastqId=fastq_id,
51
- status=job_status.value
51
+ status=job_status
52
52
  )
@@ -17,13 +17,13 @@ from typing import Optional
17
17
 
18
18
  # Local imports
19
19
  from . import fastq_unarchiving_patch_request
20
- from .globals import JobStatus, JOB_ENDPOINT
21
- from .models import Job
20
+ from .globals import JOB_ENDPOINT
21
+ from .models import Job, JobStatusType
22
22
 
23
23
 
24
24
  def update_status(
25
25
  job_id: str,
26
- job_status: JobStatus,
26
+ job_status: JobStatusType,
27
27
  error_message: Optional[str] = None
28
28
  ) -> Job:
29
29
  """
@@ -40,10 +40,12 @@ def get_file_manager_request(
40
40
 
41
41
  def file_manager_patch_request(
42
42
  endpoint: str,
43
+ json_data: Optional[Dict] = None,
43
44
  params: Optional[Dict] = None
44
45
  ):
45
46
  return patch_request(
46
47
  get_file_manager_url(endpoint),
48
+ json_data=json_data,
47
49
  params=params
48
50
  )
49
51
 
@@ -1,24 +1,30 @@
1
1
  #!/usr/bin/env python3
2
+
3
+ # Standard imports
4
+ import json
2
5
  from functools import reduce
3
6
  from operator import concat
4
7
  from typing import List, Dict, Union
5
8
  import typing
6
-
7
9
  import boto3
10
+ from datetime import datetime, timedelta, timezone
11
+ from urllib.parse import urlparse
12
+ from itertools import batched
8
13
 
14
+ # Local imports
9
15
  from .errors import S3FileNotFoundError, S3DuplicateFileCopyError
10
- from .models import FileObject
16
+ from .models import FileObject, StorageClassPriority
11
17
  from ..utils.miscell import get_bucket_key_pair_from_uri
12
- from . import get_file_manager_request_response_results, get_file_manager_request, file_manager_patch_request
18
+ from . import (
19
+ get_file_manager_request_response_results,
20
+ get_file_manager_request,
21
+ file_manager_patch_request
22
+ )
13
23
  from .globals import (
14
24
  S3_LIST_ENDPOINT,
15
25
  S3_BUCKETS_BY_ACCOUNT_ID,
16
- S3_PREFIXES_BY_ACCOUNT_ID,
17
- StorageEnum, StoragePriority,
26
+ S3_PREFIXES_BY_ACCOUNT_ID
18
27
  )
19
- from datetime import datetime, timedelta, timezone
20
- from urllib.parse import urlparse
21
- from itertools import batched
22
28
 
23
29
  if typing.TYPE_CHECKING:
24
30
  from mypy_boto3_sts import STSClient
@@ -94,7 +100,7 @@ def get_file_object_from_ingest_id(ingest_id: str, **kwargs) -> FileObject:
94
100
  ))
95
101
 
96
102
  # Order by storage class
97
- file_objects_list.sort(key=lambda file_obj_iter_: StoragePriority[StorageEnum(file_obj_iter_['storageClass']).name].value)
103
+ file_objects_list.sort(key=lambda file_obj_iter_: StorageClassPriority[file_obj_iter_['storageClass']])
98
104
 
99
105
  # Return as a FileObject model
100
106
  return file_objects_list[0]
@@ -263,8 +269,9 @@ def get_s3_objs_from_ingest_ids_map(ingest_ids: List[str], **kwargs) -> List[Dic
263
269
  continue
264
270
 
265
271
  s3_objects_match.sort(
266
- key=lambda s3_object_iter_: StoragePriority[
267
- StorageEnum(s3_object_iter_['fileObject']['storageClass']).name].value
272
+ key=lambda s3_object_iter_: StorageClassPriority[
273
+ s3_object_iter_['fileObject']['storageClass']
274
+ ]
268
275
  )
269
276
 
270
277
  s3_objects_by_ingest_id_filtered.append(
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env python
2
- from enum import Enum
3
2
 
4
3
  # AWS PARAMETERS
5
4
  FILEMANAGER_SUBDOMAIN_NAME = "file"
@@ -41,30 +40,3 @@ S3_PREFIXES_BY_ACCOUNT_ID = {
41
40
  },
42
41
  }
43
42
 
44
- # FROM FileManager Schema
45
- # "DeepArchive"
46
- # "Glacier"
47
- # "GlacierIr"
48
- # "IntelligentTiering"
49
- # "OnezoneIa"
50
- # "Outposts"
51
- # "ReducedRedundancy"
52
- # "Snow"
53
- # "Standard"
54
- # "StandardIa"
55
- class StorageEnum(Enum):
56
- STANDARD = "Standard"
57
- STANDARD_IA = "StandardIa"
58
- INTELLIGENT_TIERING = "IntelligentTiering"
59
- GLACIER_INSTANT_RETRIEVAL = "GlacierIr"
60
- GLACIER = "Glacier"
61
- DEEP_ARCHIVE = "DeepArchive"
62
-
63
-
64
- class StoragePriority(Enum):
65
- STANDARD = 1
66
- STANDARD_IA = 2
67
- INTELLIGENT_TIERING = 3
68
- GLACIER_INSTANT_RETRIEVAL = 4
69
- GLACIER = 5
70
- DEEP_ARCHIVE = 6
@@ -1,4 +1,9 @@
1
- from typing import Optional, TypedDict, Dict
1
+ from typing import (
2
+ Optional,
3
+ TypedDict,
4
+ Dict,
5
+ Literal
6
+ )
2
7
 
3
8
  """
4
9
  Example File Object response
@@ -26,6 +31,23 @@ Example File Object response
26
31
  }
27
32
  """
28
33
 
34
+ StorageClassType = Literal[
35
+ "Standard",
36
+ "StandardIa",
37
+ "IntelligentTiering",
38
+ "GlacierIr",
39
+ "Glacier",
40
+ "DeepArchive",
41
+ ]
42
+
43
+ StorageClassPriority: Dict[StorageClassType, int] = {
44
+ "Standard": 1,
45
+ "StandardIa": 2,
46
+ "IntelligentTiering": 3,
47
+ "GlacierIr": 4,
48
+ "Glacier": 5,
49
+ "DeepArchive": 6,
50
+ }
29
51
 
30
52
  class FileObject(TypedDict):
31
53
  # Identifier
@@ -47,7 +69,7 @@ class FileObject(TypedDict):
47
69
  numberReordered: int
48
70
  sequencer: str
49
71
  size: int
50
- storageClass: str
72
+ storageClass: StorageClassType
51
73
 
52
74
  # Attribute attributes
53
75
  attributes: Optional[Dict]
@@ -9,6 +9,8 @@ from copy import deepcopy
9
9
 
10
10
  from requests import HTTPError
11
11
 
12
+ from fastapi.encoders import jsonable_encoder
13
+
12
14
  # Locals
13
15
  from .aws_helpers import (
14
16
  get_orcabus_token, get_hostname
@@ -103,7 +105,11 @@ def get_request(url: str, params: Optional[Dict] = None) -> Dict:
103
105
  return response.json()
104
106
 
105
107
 
106
- def patch_request(url: str, params: Optional[Dict] = None) -> Dict:
108
+ def patch_request(
109
+ url: str,
110
+ json_data: Optional[Dict] = None,
111
+ params: Optional[Dict] = None
112
+ ) -> Dict:
107
113
  # Get authorization header
108
114
  headers = {
109
115
  "Authorization": f"Bearer {get_orcabus_token()}"
@@ -119,7 +125,8 @@ def patch_request(url: str, params: Optional[Dict] = None) -> Dict:
119
125
  response = requests.patch(
120
126
  url,
121
127
  headers=headers,
122
- json=req_params
128
+ params=req_params,
129
+ json=json_data
123
130
  )
124
131
 
125
132
  try: