Skip to content

Commit 91be04d

Browse files
committed
Application and deployment for fastq sync microservice
1 parent 00ea9fd commit 91be04d

File tree

25 files changed

+2351
-21
lines changed

25 files changed

+2351
-21
lines changed

config/config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import {
7272
getFastqUnarchivingManagerStackProps,
7373
getFastqUnarchivingManagerTableStackProps,
7474
} from './stacks/fastqUnarchivingManager';
75+
import {
76+
getFastqSyncManagerStackProps,
77+
getFastqSyncManagerTableStackProps,
78+
} from './stacks/fastqSyncManager';
7579

7680
interface EnvironmentConfig {
7781
name: string;
@@ -115,6 +119,7 @@ export const getEnvironmentConfig = (stage: AppStage): EnvironmentConfig | null
115119
accessKeySecretStackProps: getAccessKeySecretStackProps(stage),
116120
fastqManagerTableStackProps: getFastqManagerTableStackProps(stage),
117121
fastqUnarchivingManagerTableStackProps: getFastqUnarchivingManagerTableStackProps(),
122+
fastqSyncManagerTableStackProps: getFastqSyncManagerTableStackProps(),
118123
},
119124
statelessConfig: {
120125
metadataManagerStackProps: getMetadataManagerStackProps(stage),
@@ -147,6 +152,7 @@ export const getEnvironmentConfig = (stage: AppStage): EnvironmentConfig | null
147152
pgDDProps: getPgDDProps(stage),
148153
fastqManagerStackProps: getFastqManagerStackProps(stage),
149154
fastqUnarchivingManagerStackProps: getFastqUnarchivingManagerStackProps(stage),
155+
fastqSyncManagerStackProps: getFastqSyncManagerStackProps(),
150156
},
151157
};
152158

config/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -967,3 +967,8 @@ export const fastqUnarchivingEventDetailType = {
967967
updateJob: 'FastqUnarchivingJobUpdated',
968968
};
969969
export const fastqUnarchivingManagerEventSource = 'orcabus.fastqunarchivingmanager';
970+
971+
/*
972+
Fastq sync service
973+
*/
974+
export const fastqSyncEventDetailType = 'fastqSync';

config/stacks/fastqSyncManager.ts

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import {
2+
/* Events */
3+
eventBusName,
4+
fastqManagerEventDetails,
5+
fastqManagerEventSource,
6+
fastqSyncEventDetailType,
7+
fastqUnarchivingEventDetailType,
8+
fastqUnarchivingManagerEventSource,
9+
hostedZoneNameParameterPath,
10+
jwtSecretName,
11+
} from '../constants';
12+
13+
import { FastqSyncManagerStackConfig } from '../../lib/workload/stateless/stacks/fastq-sync/deploy/interfaces';
14+
import { FastqSyncTableConfig } from '../../lib/workload/stateful/stacks/fastq-sync-dynamodb/deploy/stack';
15+
16+
/*
17+
export interface FastqSyncManagerStackConfig {
18+
/*
19+
Orcabus token and zone name for external lambda functions
20+
*/
21+
//orcabusTokenSecretsManagerPath: string;
22+
//hostedZoneNameSsmParameterPath: string;
23+
24+
/*
25+
Data tables
26+
*/
27+
//fastqSyncDynamodbTableName: string;
28+
/*
29+
Event bus stuff
30+
*/
31+
//eventBusName: string;
32+
// eventTriggers: FastqSyncEventTriggers
33+
//}
34+
//*/
35+
36+
const fastqSyncDynamodbTableName = 'fastqSyncTokenTable';
37+
38+
// Stateful
39+
export const getFastqSyncManagerTableStackProps = (): FastqSyncTableConfig => {
40+
return {
41+
/* DynamoDB table for fastq list rows */
42+
dynamodbTableName: fastqSyncDynamodbTableName,
43+
};
44+
};
45+
46+
// Stateless
47+
export const getFastqSyncManagerStackProps = (): FastqSyncManagerStackConfig => {
48+
return {
49+
/*
50+
Table stuff
51+
*/
52+
fastqSyncDynamodbTableName: fastqSyncDynamodbTableName,
53+
54+
/*
55+
Events stuff
56+
*/
57+
eventBusName: eventBusName,
58+
eventTriggers: {
59+
fastqSetUpdated: {
60+
eventSource: fastqManagerEventSource,
61+
eventDetailType: fastqManagerEventDetails.updateFastqSet,
62+
},
63+
fastqListRowUpdated: {
64+
eventSource: fastqManagerEventSource,
65+
eventDetailType: fastqManagerEventDetails.updateFastqListRow,
66+
},
67+
fastqUnarchiving: {
68+
eventSource: fastqUnarchivingManagerEventSource,
69+
eventDetailType: fastqUnarchivingEventDetailType.updateJob,
70+
},
71+
fastqSync: {
72+
eventDetailType: fastqSyncEventDetailType,
73+
},
74+
},
75+
76+
/*
77+
Orcabus token and zone name for external lambda functions
78+
*/
79+
orcabusTokenSecretsManagerPath: jwtSecretName,
80+
hostedZoneNameSsmParameterPath: hostedZoneNameParameterPath,
81+
};
82+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Fastq Sync dynamodb
2+
3+
Simple database with dynamodb to store task tokens and link them to fastq set ids (And vice versa)
4+
5+
A task token can only map to one fastq set id, but a fastq set id can map to multiple task tokens.
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { DynamodbPartitionedPipelineConstruct } from '../../../../components/dynamodb-partitioned-table';
4+
5+
export interface FastqSyncTableConfig {
6+
dynamodbTableName: string;
7+
}
8+
9+
export type FastqSyncManagerTableStackProps = FastqSyncTableConfig & cdk.StackProps;
10+
11+
export class FastqSyncManagerTable extends cdk.Stack {
12+
constructor(scope: Construct, id: string, props: FastqSyncManagerTableStackProps) {
13+
super(scope, id, props);
14+
15+
/*
16+
Initialise dynamodb table, where id_type is the primary sort key
17+
*/
18+
const dynamodbTable = new DynamodbPartitionedPipelineConstruct(this, 'fastq_sync_table', {
19+
tableName: props.dynamodbTableName,
20+
});
21+
}
22+
}

lib/workload/stateful/statefulStackCollectionClass.ts

+15
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ import {
7474
FastqUnarchivingManagerTable,
7575
FastqUnarchivingManagerTableStackProps,
7676
} from './stacks/fastq-unarchiving-dynamodb/deploy';
77+
import {
78+
FastqSyncManagerTable,
79+
FastqSyncManagerTableStackProps,
80+
} from './stacks/fastq-sync-dynamodb/deploy/stack';
7781

7882
export interface StatefulStackCollectionProps {
7983
dataBucketStackProps: DataBucketStackProps;
@@ -98,6 +102,7 @@ export interface StatefulStackCollectionProps {
98102
accessKeySecretStackProps: AccessKeySecretStackProps;
99103
fastqManagerTableStackProps: FastqManagerTableStackProps;
100104
fastqUnarchivingManagerTableStackProps: FastqUnarchivingManagerTableStackProps;
105+
fastqSyncManagerTableStackProps: FastqSyncManagerTableStackProps;
101106
}
102107

103108
export class StatefulStackCollection {
@@ -125,6 +130,7 @@ export class StatefulStackCollection {
125130
readonly accessKeySecretStack: Stack;
126131
readonly fastqManagerTableStack: Stack;
127132
readonly fastqUnarchivingManagerTableStack: Stack;
133+
readonly fastqSyncManagerTableStack: Stack;
128134

129135
constructor(
130136
scope: Construct,
@@ -292,6 +298,15 @@ export class StatefulStackCollection {
292298
...statefulConfiguration.fastqUnarchivingManagerTableStackProps,
293299
}
294300
);
301+
302+
this.fastqSyncManagerTableStack = new FastqSyncManagerTable(
303+
scope,
304+
'FastqSyncManagerTableStack',
305+
{
306+
...this.createTemplateProps(env, 'FastqSyncManagerTableStack'),
307+
...statefulConfiguration.fastqSyncManagerTableStackProps,
308+
}
309+
);
295310
}
296311

297312
/**
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Fastq Sync Service
22

3-
The fastq sync service is a simple service that allows step functions with task tokens to 'hang'
4-
until the requirements of either a fastq list row or fastq set have been met.
3+
The fastq sync service is a simple service that allows step functions with fastq set ids as inputs to 'hang'
4+
until the requirements of the fastq set have been met.
55

66
This is useful for workflow-glue services that have fastq set ids but need to wait for either
77

88
1. The fastq set readsets to be created
99
2. The fastq set to have been qc'd AND have a fingerprint file and compression information
1010
3. This is also useful for data sharing services that require the fastqs to be unarchived before they can be shared
1111

12-
The step function will then hang at that step until the task token has been 'unlocked'
12+
The step function will then hang at that step until the task token has been 'unlocked' by the fastq sync service.
1313

1414
## Registering task tokens
1515

@@ -25,34 +25,38 @@ Workflow glue services can use the fastq sync service by generating the followin
2525
"fastqSetId": "fqs.123456",
2626
// Then one or more of the following
2727
// Requirements can be left out if not needed
28-
// Do all fastq list rows in the set contain readsets?
29-
"hasReadsets": true,
30-
// Do all fastq list rows in the set contain an ntsm uri?
31-
"hasFingerprints": true,
32-
// Do all fastq list rows in the set contain compression information?
33-
// Useful if the fastq list rows are in ora format.
34-
// Some pipelines require the gzip file size in bytes in order
35-
// to stream the gzip file from ora back into s3
36-
"hasCompressionInformation": true,
37-
// Do all fastq list rows in the set contain qc information?
38-
// We don't use this for anything yet but we may use this in the future
39-
// to ensure that a fastq set has met the ideal coverage levels
40-
"hasQc": true,
28+
"requirements": {
29+
// Do all fastq list rows in the set contain readsets?
30+
"hasActiveReadSet": true,
31+
// Do all fastq list rows in the set contain an ntsm uri?
32+
"hasFingerprint": true,
33+
// Do all fastq list rows in the set contain compression information?
34+
// Useful if the fastq list rows are in ora format.
35+
// Some pipelines require the gzip file size in bytes in order
36+
// to stream the gzip file from ora back into s3
37+
"hasFileCompressionInformation": true,
38+
// Do all fastq list rows in the set contain qc information?
39+
// We don't use this for anything yet but we may use this in the future
40+
// to ensure that a fastq set has met the ideal coverage levels
41+
"hasQc": true,
42+
}
4143
}
4244
}
4345
```
4446

4547
The fastq sync service will also trigger the qc, fingerprint or compression information services if they do not exist.
4648

47-
If any of the fastq list rows are in archive, the fastq sync service will also trigger the archive service to unarchive these fastq list rows.
49+
If any of the fastq list rows are in archive, the fastq sync service will also trigger the fastq unarchiving service to thaw out these fastq list rows.
50+
And place them into the 'byob' bucket.
51+
4852

4953
## Unlocking task tokens
5054

51-
The fastq sync service will listen for the following events:
55+
The fastq sync service will then also listen for the following event typed:
5256

5357
1. FastqListRowUpdated (from the fastq management service)
5458
2. FastqSetUpdated (from the fastq management service)
55-
3. UnarchivingCompleted (from the fastq unarchiving service)
56-
57-
The fastq sync service will then check against the requirements of the fastq set or fastq list row for each task token and if so, unlock the task token.
59+
3. UnarchivingJobUpdated (from the fastq unarchiving service, where the status is 'SUCCEEDED')
5860

61+
Everytime one of the events is triggered, the fastq sync service will check if the fastq list row or fastq set has met the requirements.
62+
If all requirements are met for the fastq set, the fastq sync service will unlock the task token.

0 commit comments

Comments
 (0)