@orcabus/platform-cdk-constructs 0.0.47 → 0.0.48

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.
package/.jsii CHANGED
@@ -6756,6 +6756,6 @@
6756
6756
  "symbolId": "shared-config/slack:SlackAlerts"
6757
6757
  }
6758
6758
  },
6759
- "version": "0.0.47",
6760
- "fingerprint": "efnw8JJpfwVcImj5oidEElmBzpYb6UgaPKxmvh9hB9k="
6759
+ "version": "0.0.48",
6760
+ "fingerprint": "2o+clcDs/L5F1h+iDeYKodwO0D2DU26xdnQrBgLLPDc="
6761
6761
  }
@@ -15,7 +15,7 @@ const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
15
15
  const aws_route53_targets_1 = require("aws-cdk-lib/aws-route53-targets");
16
16
  const config_1 = require("./config");
17
17
  class OrcaBusApiGateway extends constructs_1.Construct {
18
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.apigateway.OrcaBusApiGateway", version: "0.0.47" };
18
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.apigateway.OrcaBusApiGateway", version: "0.0.48" };
19
19
  /**
20
20
  * The AWS region where the API Gateway is deployed.
21
21
  */
@@ -13,7 +13,7 @@ exports.CROSS_DEPLOYMENT_ARTIFACT_BUCKET_NAME = "orcabus-cross-deployment-codepi
13
13
  exports.CROSS_DEPLOYMENT_ARTIFACT_KMS_ALIAS = "orcabus-cross-deployment-codepipeline-artifact";
14
14
  exports.CROSS_DEPLOYMENT_ARTIFACT_KMS_ARN_SSM_PARAMETER_NAME = "/orcabus/deployment-stack-pipeline/artifact-bucket/kms-key-arn";
15
15
  class CrossDeploymentArtifactBucket extends constructs_1.Construct {
16
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.deploymentPipeline.CrossDeploymentArtifactBucket", version: "0.0.47" };
16
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.deploymentPipeline.CrossDeploymentArtifactBucket", version: "0.0.48" };
17
17
  /**
18
18
  * The S3 bucket used to store artifacts for cross-deployment pipelines.
19
19
  */
@@ -32,7 +32,7 @@ exports.DEFAULT_SYNTH_STEP_PARTIAL_BUILD_SPEC = {
32
32
  * before using this construct.
33
33
  */
34
34
  class DeploymentStackPipeline extends constructs_1.Construct {
35
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.deploymentPipeline.DeploymentStackPipeline", version: "0.0.47" };
35
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.deploymentPipeline.DeploymentStackPipeline", version: "0.0.48" };
36
36
  /**
37
37
  * The code pipeline construct that is created.
38
38
  */
package/dynamodb/index.js CHANGED
@@ -40,7 +40,7 @@ const dynamodb = __importStar(require("aws-cdk-lib/aws-dynamodb"));
40
40
  const aws_cdk_lib_1 = require("aws-cdk-lib");
41
41
  const config_1 = require("./config");
42
42
  class DynamoDbPartitionedConstruct extends constructs_1.Construct {
43
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.dynamodb.DynamoDbPartitionedConstruct", version: "0.0.47" };
43
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.dynamodb.DynamoDbPartitionedConstruct", version: "0.0.48" };
44
44
  table;
45
45
  constructor(scope, id, props) {
46
46
  super(scope, id);
@@ -75,7 +75,7 @@ class DynamoDbPartitionedConstruct extends constructs_1.Construct {
75
75
  }
76
76
  exports.DynamoDbPartitionedConstruct = DynamoDbPartitionedConstruct;
77
77
  class DynamoDbNonPartitionedConstruct extends constructs_1.Construct {
78
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.dynamodb.DynamoDbNonPartitionedConstruct", version: "0.0.47" };
78
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.dynamodb.DynamoDbNonPartitionedConstruct", version: "0.0.48" };
79
79
  table;
80
80
  constructor(scope, id, props) {
81
81
  super(scope, id);
package/ecs/index.js CHANGED
@@ -55,7 +55,7 @@ exports.LAMBDA_ARCHITECTURE_MAP = {
55
55
  ['ARM64']: lambda.Architecture.ARM_64
56
56
  };
57
57
  class EcsFargateTaskConstruct extends constructs_1.Construct {
58
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.ecs.EcsFargateTaskConstruct", version: "0.0.47" };
58
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.ecs.EcsFargateTaskConstruct", version: "0.0.48" };
59
59
  cluster;
60
60
  taskDefinition;
61
61
  taskExecutionRole;
package/lambda/index.js CHANGED
@@ -56,7 +56,7 @@ function getPythonUvDockerImage() {
56
56
  return aws_cdk_lib_1.DockerImage.fromBuild(path_1.default.join(__dirname, 'build_python'));
57
57
  }
58
58
  class PythonUvFunction extends aws_lambda_python_alpha_1.PythonFunction {
59
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.lambda.PythonUvFunction", version: "0.0.47" };
59
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.lambda.PythonUvFunction", version: "0.0.48" };
60
60
  // Class constructs, to be used for caching the layers
61
61
  // This means that if there are multiple lambdas throughout the stack
62
62
  // They will all use the same layer
@@ -1,15 +1,59 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
+ # Standard imports
4
+ from typing import Dict
5
+
6
+ # Local imports
7
+ from ..utils.requests_helpers import (
8
+ get_request_response_results,
9
+ get_request,
10
+ get_url
11
+ )
12
+ from .globals import SEQUENCE_SUBDOMAIN_NAME
13
+ from .models import Sequence, SequenceDetail, SampleSheet
14
+
15
+
16
+ def get_sequence_url(endpoint: str) -> str:
17
+ """
18
+ Get the base URL for the sequence api
19
+ :param endpoint:
20
+ :return:
21
+ """
22
+ return get_url(
23
+ endpoint,
24
+ SEQUENCE_SUBDOMAIN_NAME
25
+ )
26
+
27
+
28
+ def get_sequence_request(
29
+ endpoint: str,
30
+ params: Optional[Dict] = None,
31
+ ):
32
+ return get_request(get_sequence_url(endpoint), params=params)
33
+
34
+
35
+ def get_sequence_request_response_results(
36
+ endpoint: str,
37
+ params: Optional[Dict] = None,
38
+ ):
39
+ return get_request_response_results(get_sequence_url(endpoint), params=params)
40
+
41
+
42
+
3
43
  from .sequence_helpers import (
4
44
  get_sequence_object_from_instrument_run_id,
45
+ get_libraries_from_instrument_run_id,
5
46
  get_sample_sheet_from_orcabus_id,
6
47
  get_library_ids_in_sequence,
48
+ get_sample_sheet_from_instrument_run_id
7
49
  )
8
50
 
9
51
  __all__ = [
10
52
  "get_sequence_object_from_instrument_run_id",
53
+ "get_libraries_from_instrument_run_id",
11
54
  "get_sample_sheet_from_orcabus_id",
12
55
  "get_library_ids_in_sequence",
56
+ "get_sample_sheet_from_instrument_run_id",
13
57
  ]
14
58
 
15
59
 
@@ -1,2 +1,6 @@
1
1
  # Run name for sequence run manager
2
- SEQUENCE_SUBDOMAIN_NAME = 'sequence'
2
+ SEQUENCE_SUBDOMAIN_NAME = 'sequence'
3
+
4
+ SEQUENCE_ENDPOINT = "api/v1/sequence"
5
+
6
+ SEQUENCE_RUN_ENDPOINT = "api/v1/sequence_run"
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
- from typing import TypedDict, Literal, Optional, Dict
3
+ from typing import TypedDict, Literal, Optional, Dict, List
4
4
 
5
- statusLiteral = Literal['STARTED', 'FAILED', 'SUCCEEDED', 'ABORTED', 'RESOLVED']
5
+ StatusType = Literal['STARTED', 'FAILED', 'SUCCEEDED', 'ABORTED', 'RESOLVED']
6
6
 
7
7
 
8
8
  class SequenceDetail(TypedDict):
@@ -10,15 +10,15 @@ class SequenceDetail(TypedDict):
10
10
  instrumentRunId: str
11
11
  experimentName: str
12
12
  startTime: str
13
- endTime: str
14
- status: statusLiteral
13
+ endTime: Optional[str]
14
+ status: Optional[StatusType]
15
15
 
16
16
 
17
17
  class Sequence(TypedDict):
18
18
  orcabusId: str
19
- libraries: str
19
+ libraries: List[str]
20
20
  sequenceRunId: str
21
- status: statusLiteral
21
+ status: StatusType
22
22
  startTime: str
23
23
  sampleSheetName: str
24
24
  v1pre3Id: str
@@ -1,38 +1,82 @@
1
1
  #!/usr/bin/env python3
2
- from .globals import SEQUENCE_SUBDOMAIN_NAME
3
- from .models import Sequence, SequenceDetail, SampleSheet
4
- from ..utils.requests_helpers import get_request_response_results, get_request, get_url
5
2
 
3
+ # Standard imports
4
+ from typing import Optional, cast, List
5
+ import logging
6
6
 
7
- def get_sequence_url(endpoint: str) -> str:
7
+
8
+ # Local imports
9
+ from . import get_sequence_request
10
+ from .globals import SEQUENCE_RUN_ENDPOINT, SEQUENCE_ENDPOINT
11
+ from .models import SequenceDetail, SampleSheet, Sequence
12
+
13
+
14
+ def get_sample_sheet_from_instrument_run_id(instrument_run_id: str) -> Optional[SampleSheet]:
15
+ samplesheet_dict_list = sorted(
16
+ get_sequence_request(endpoint=f"{SEQUENCE_ENDPOINT}/{instrument_run_id}/sample_sheets"),
17
+ key=lambda x: x.get("orcabusId")
18
+ )
19
+
20
+ if len(samplesheet_dict_list) == 0:
21
+ logging.warning("Could not find sample sheet for instrument run id: %s", instrument_run_id)
22
+ return None
23
+
24
+ # If there are multiple sample sheets, print to logs, but return the last one
25
+ if len(samplesheet_dict_list) > 1:
26
+ logging.warning(
27
+ f"Multiple sample sheets found for instrument run id {instrument_run_id}. "
28
+ f"Returning the last one."
29
+ )
30
+
31
+ return cast(SampleSheet, samplesheet_dict_list[-1])
32
+
33
+
34
+ def get_libraries_from_instrument_run_id(instrument_run_id: str) -> List[str]:
8
35
  """
9
- Get the URL for the Metadata endpoint
10
- :param endpoint:
36
+ Get the sequence run object
37
+ :param instrument_run_id:
11
38
  :return:
12
39
  """
13
- return get_url(
14
- endpoint,
15
- SEQUENCE_SUBDOMAIN_NAME
40
+ sequence_run_object = get_sequence_object_from_instrument_run_id(
41
+ instrument_run_id=instrument_run_id
16
42
  )
17
43
 
18
- def get_sequence_object_from_instrument_run_id(instrument_run_id: str) -> SequenceDetail:
44
+ if sequence_run_object is None:
45
+ logging.warning("Could not find sequence run for instrument run id: %s", instrument_run_id)
46
+ return []
47
+
48
+ return sequence_run_object.get('libraries', [])
49
+
50
+
51
+ def get_sequence_object_from_instrument_run_id(instrument_run_id: str) -> Optional[Sequence]:
19
52
  """
20
53
  Get the sequence object from the instrument run id.
21
54
  :param instrument_run_id:
22
55
  :return:
23
56
  """
24
57
 
25
- return Sequence(
26
- **dict(
27
- get_request_response_results(
28
- get_sequence_url(endpoint="api/v1/sequence"),
29
- params={
30
- "instrumentRunId": instrument_run_id,
31
- }
32
- )[0]
33
- )
58
+ # Get the sequence run details from the instrument run id
59
+ sequence_run_dict_list = sorted(
60
+ get_sequence_request(endpoint=f"{SEQUENCE_ENDPOINT}/{instrument_run_id}/sequence_run"),
61
+ # Orcabus ids are ulids so they are sortable by timestamp
62
+ key=lambda x: x.get("orcabusId")
34
63
  )
35
64
 
65
+ # Check we have at least one sequence run
66
+ if len(sequence_run_dict_list) == 0:
67
+ logging.warning("Could not find sequence run for instrument run id: %s", instrument_run_id)
68
+ return None
69
+
70
+ # Check if there are multiple sequence runs
71
+ if len(sequence_run_dict_list) > 1:
72
+ logging.warning(
73
+ f"Multiple sequence runs found for instrument run id {instrument_run_id}. "
74
+ f"Returning the last one."
75
+ )
76
+
77
+ # Return the last sequence run
78
+ return cast(Sequence, sequence_run_dict_list[-1])
79
+
36
80
 
37
81
  def get_sample_sheet_from_orcabus_id(sequence_orcabus_id: str) -> SampleSheet:
38
82
  """
@@ -43,20 +87,15 @@ def get_sample_sheet_from_orcabus_id(sequence_orcabus_id: str) -> SampleSheet:
43
87
 
44
88
  return SampleSheet(
45
89
  **dict(
46
- get_request(
47
- get_sequence_url(endpoint=f"api/v1/sequence/{sequence_orcabus_id}/sample_sheet")
48
- )
90
+ get_sequence_request(endpoint=f"{SEQUENCE_RUN_ENDPOINT}/{sequence_orcabus_id}/sample_sheet")
49
91
  )
50
92
  )
51
93
 
52
94
 
53
- def get_library_ids_in_sequence(sequence_orcabus_id: str) -> list[str]:
95
+ def get_library_ids_in_sequence(sequence_orcabus_id: str) -> List[str]:
54
96
  """
55
97
  Get the library ids in the sequence run.
56
98
  :param sequence_orcabus_id:
57
99
  :return:
58
100
  """
59
-
60
- return get_request(
61
- get_sequence_url(endpoint=f"api/v1/sequence/{sequence_orcabus_id}")
62
- )['libraries']
101
+ return get_sequence_request(endpoint=f"{SEQUENCE_RUN_ENDPOINT}/{sequence_orcabus_id}").get('libraries', [])
@@ -13,7 +13,7 @@ const aws_cloudwatch_actions_1 = require("aws-cdk-lib/aws-cloudwatch-actions");
13
13
  * SNS topic.
14
14
  */
15
15
  class MonitoredQueue extends constructs_1.Construct {
16
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.monitoredQueue.MonitoredQueue", version: "0.0.47" };
16
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.monitoredQueue.MonitoredQueue", version: "0.0.48" };
17
17
  queue;
18
18
  deadLetterQueue;
19
19
  alarm;
@@ -7,7 +7,7 @@ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
7
7
  * A construct which represents a named role that a Lambda function can assume.
8
8
  */
9
9
  class NamedLambdaRole extends aws_iam_1.Role {
10
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.namedLambdaRole.NamedLambdaRole", version: "0.0.47" };
10
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.namedLambdaRole.NamedLambdaRole", version: "0.0.48" };
11
11
  constructor(scope, id, props) {
12
12
  super(scope, id, {
13
13
  assumedBy: new aws_iam_1.ServicePrincipal("lambda.amazonaws.com"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orcabus/platform-cdk-constructs",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "CDK Package for OrcaBus infrastructure.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
@@ -15,7 +15,7 @@ const aws_cdk_lib_1 = require("aws-cdk-lib");
15
15
  * to the provider framework.
16
16
  */
17
17
  class ProviderFunction extends constructs_1.Construct {
18
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.provider.ProviderFunction", version: "0.0.47" };
18
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.provider.ProviderFunction", version: "0.0.48" };
19
19
  _function;
20
20
  _response;
21
21
  constructor(scope, id, props) {
@@ -23,7 +23,7 @@ exports.VPC_LOOKUP_PROPS = {
23
23
  * Helper for looking up the shared OrcaBus VPC.
24
24
  */
25
25
  class OrcaBusVpc {
26
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.networking.OrcaBusVpc", version: "0.0.47" };
26
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.networking.OrcaBusVpc", version: "0.0.48" };
27
27
  /**
28
28
  * The shared VPC that is used by OrcaBus.
29
29
  * @param scope
@@ -42,7 +42,7 @@ exports.SHARED_SECURITY_GROUP_NAME = "OrcaBusSharedComputeSecurityGroup";
42
42
  * Helper for looking up the shared compute security group by name.
43
43
  */
44
44
  class OrcaBusSharedComputeSecurityGroup {
45
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.networking.OrcaBusSharedComputeSecurityGroup", version: "0.0.47" };
45
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.networking.OrcaBusSharedComputeSecurityGroup", version: "0.0.48" };
46
46
  /**
47
47
  * The shared security group that is used by compute resources to access the database.
48
48
  * @param scope
@@ -11,7 +11,7 @@ exports.SLACK_ALERTS_SNS_TOPIC = "AwsChatBotTopic-alerts";
11
11
  * A helper class to construct the arn for the slack SNS topic.
12
12
  */
13
13
  class SlackAlerts {
14
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.slack.SlackAlerts", version: "0.0.47" };
14
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@orcabus/platform-cdk-constructs.sharedConfig.slack.SlackAlerts", version: "0.0.48" };
15
15
  /**
16
16
  * Format the ARN for the slack alerts SNS topic for the current stack.
17
17
  * @param stack