Skip to content

Commit

Permalink
Refactored project setup on initial structure
Browse files Browse the repository at this point in the history
* Changed CDK to be coded in TypeScript
* Followed CDK CodePipeline best practise and reference architecture
  by introducing concepts: workload, stateful, stateless, component
* Split CDK entry points: manual and self-mutating pipeline
* Initial mark up for unit tests structure for both TS/Py
  * deploy time code in TypeScript
  * run time code in Python
  • Loading branch information
victorskl committed Apr 18, 2023
1 parent c5e0f4e commit 3cae7ad
Show file tree
Hide file tree
Showing 77 changed files with 3,612 additions and 490 deletions.
43 changes: 43 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"restParams": true,
"spread": true
}
},
"plugins": ["prettier", "@typescript-eslint"],
"rules": {
"prettier/prettier": "error",
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
]
},
"settings": {
"react": {
"version": "detect"
}
}
}
33 changes: 15 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
# Distribution / packaging
.Python
env/
build/

develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
venv/
.venv/
env/
.env
*.egg-info/
.installed.cfg
*.egg
*__pycache__*
lambdas/layers/**/*.zip

# Serverless
.aws-sam
.serverless/
node_modules/
.pytest_cache/

# IDE
.idea
Expand All @@ -33,5 +20,15 @@ node_modules/

# Environment files
*.log
/lambdas/layers/python/
/cdk.out/
**/layers/python/
**/layers/**/*.zip

*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out/
cdk.context.json
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
17 changes: 17 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://prettier.io/docs/en/ignore.html

# Ignore artifacts:
build
coverage
local_ignore
bams
vcfs

# Ignore all HTML files:
*.html

.pre-commit-config.yaml
buildspec.yml
docker-compose.yml
README.md
start.sh
12 changes: 12 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"bracketSameLine": true,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.PHONY: test

install:
@yarn install
@find ./lib -name 'requirements.txt' -exec pip install -r {} \;
@pip install -r requirements-dev.txt
@pre-commit install

check:
@pre-commit run --all-files

run:
sam local invoke

build:
for dir in $(shell find ./lambdas/layers -maxdepth 1 -mindepth 1 -type d -exec basename {} \;); do ./lambdas/layers/create_layer_package.sh $$dir; done
cdk synth
for dir in $(shell find ./lib/workload/stateless/layers -maxdepth 1 -mindepth 1 -type d -exec basename {} \;); do ./lib/workload/stateless/layers/create_layer_package.sh $$dir; done

deploy: build
cdk deploy OrcaBus
cdk deploy OrcaBusSchemaStack
test:
@yarn test
@pytest
92 changes: 8 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,19 @@

UMCCR Orchestration Bus that leverage AWS EventBridge as Event Bus to automate the BioInformatics Workflows Pipeline.

## Quickstart

### Pre-requisites

```
brew tap aws/tap
brew install aws-sam-cli
sam --version
SAM CLI, version 1.43.0
npm install -g aws-cdk
cdk version
2.19.0 (build e0d3e62)
```

### Pre-commit hooks

We are using pre-commit hooks to check for any secret-key leaks and for linting purposes.
Check [UMCCR wiki](https://github.com/umccr/wiki/blob/master/computing/dev-environment/git-hooks.md) for details.

```
brew install pre-commit detect-secrets
pre-commit --version
pre-commit 2.18.1
detect-secrets --version
1.2.0
```

### Development

- Create Python environment; we recommend conda or mamba.
## Development

```
conda create -n orcabus python=3.9
conda activate orcabus
python -V
Python 3.9.12
make install
make check
make run
```
make test
### Build & Deploy

```
make build
cdk diff
make deploy
npx cdk list
npx cdk synth OrcaBusStatefulStack
npx cdk synth
npx cdk diff
npx cdk deploy OrcaBusStatefulStack
npx cdk deploy --all
```

## Current mock event handling

The mock setup consists of two stacks:
- oen to configure the event bus and event schemas used by the application
- the other to manage the application itself

The application is a series of Lambda function that produce/consume events from the event bus. Two Lambdas have a special role, as they provide the interface with external services (ICA ENS/WES).

### Lambdas
Functions to prepare WES workflow executions. These functions normally receive events from the orchestrator, signaling a specific state has been reached and further actions can be triggered
- bcl_convert (prepare BCL Convert WES workflow)
- dragen_wgs_qc (prepare DRAGEN WGS QC WES workflow)
- dragen_wgs_somatic (prepare DRAGEN WGS SOMATIC WES workflow)

Functions as interface to external services
- ens_event_manager (manage events received by ICA ENS via SQS. Its job is to translate external events into internal ones, check event consistency/duplication and persist the current state)
- wes_launcher (send WES execution requests to ICA. Its job to interface with the ICA WES service and launch requested WES workflows) NOTE: the mock version will instead send SQS formatted events directly to the ens_event_manager

- orchestrator (manage and distribute events as needed, based on external triggers and internal state. Its job is to react to external events and decide which, if any, action to take)
- gds_manager {file level event monitor; may not be needed if functionality is covered by ens_event_manager}

Schemas:
- SequenceRunStateChange (internal version of ENS `bssh.runs` events; represents a change in sequencing state; emitted by ens_event_manager)
- WorkflowRunStateChange (internal version of ENS `wes.runs` events; represents a change in workflow state; emitted by ens_event_manager)
- WesLaunchRequest (event to request a WES workflow launch; usually emitted by workflow prep lambdas)
- WorkflowRequest (event to trigger a workflow prep lambda, may/may not result in WES workflow request)


#### Layers
Lambda layers are used to make common libs (like utils and schema) available to all Lambdas.


## Possible next steps

1. Ask illumina to have a partner event source integration for ICA with AWS EventBridge. It would cleanup the microservices integration, for instance: instead of connecting SQS queues between accounts, providing an API abstraction that can be consumed/reused in multiple ways.
1. Add an extra target that dumps the GDS event in DynamoDB, perhaps a first step to get rid of the heavy Django ORM abstraction.
45 changes: 0 additions & 45 deletions app.py

This file was deleted.

15 changes: 15 additions & 0 deletions bin/orcabus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { OrcaBusStatelessStack } from '../lib/workload/orcabus-stateless-stack';
import { OrcaBusStatefulStack } from '../lib/workload/orcabus-stateful-stack';

const app = new cdk.App();

new OrcaBusStatefulStack(app, 'OrcaBusStatefulStack', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
});

new OrcaBusStatelessStack(app, 'OrcaBusStatelessStack', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
});
1 change: 1 addition & 0 deletions bin/pipeline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO impl
Loading

0 comments on commit 3cae7ad

Please sign in to comment.