Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ena-submission): Create insdc submission service #2186

Merged
merged 56 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1ab1029
Add an ena submission pod
anna-parker Jun 26, 2024
4551811
Add to ena-submission image to build-arm-images.
anna-parker Jun 27, 2024
2b4a9a5
docs(submission): stub
corneliusroemer Oct 5, 2023
b5dc0b3
Add metadata model
corneliusroemer Oct 5, 2023
220113b
How to register a study programatically
corneliusroemer Oct 5, 2023
42eed3c
Add ENA sample submission details
corneliusroemer Oct 5, 2023
de64dcf
Add assembly submission details
corneliusroemer Oct 6, 2023
f4be0cb
Merge ena submission docs
anna-parker Jun 28, 2024
c3f888f
Change user name to ExternalMetadataUpdater.
anna-parker Jul 8, 2024
11d009c
Update create_project_xml.py
anna-parker Jul 8, 2024
0bf88ad
Add center_name to create_project_xml.py
anna-parker Jul 8, 2024
deca3f6
Update ena-submission-deployment.yaml
theosanderson Jul 8, 2024
a73cc9d
Update ena-submission-deployment.yaml
theosanderson Jul 8, 2024
6a859bb
Update ena-submission-deployment.yaml
theosanderson Jul 8, 2024
0e8d936
Add flyway with conf and sql into its own docker image and add to git…
anna-parker Jul 10, 2024
7285d97
Check if adding to build-arm-images helps
anna-parker Jul 10, 2024
d013f39
Fix config indentation.
anna-parker Jul 10, 2024
f5d0f6b
Create a kubernetes config for the ena-submission pod.
anna-parker Jul 10, 2024
ccd11a4
Update README.md
anna-parker Jul 10, 2024
26ee134
Merge branch 'main' into ena_submission_pod
anna-parker Jul 11, 2024
cb156ab
Small test - do not use flyway in a separate pod.
anna-parker Jul 11, 2024
196404d
Add flway to ena-submission docker image instead
anna-parker Jul 11, 2024
c44414b
Small fix
anna-parker Jul 11, 2024
1c02a92
Add java to image.
anna-parker Jul 11, 2024
4ca348e
Do not remove files (avoid permissions issue)
anna-parker Jul 11, 2024
25f2b49
Try again with separate flyway image.
anna-parker Jul 11, 2024
915338a
One more try.
anna-parker Jul 11, 2024
2283c1e
Add a message
anna-parker Jul 11, 2024
9c98210
one more time
anna-parker Jul 11, 2024
a262163
more logs
anna-parker Jul 11, 2024
b717437
Add logging to docker as I can check this actually works locally.
anna-parker Jul 11, 2024
4046490
Fix permission issues.
anna-parker Jul 11, 2024
82ac4a6
Only have 1 submission pod
anna-parker Jul 11, 2024
f960a97
Fix auth issue
anna-parker Jul 11, 2024
85b6c77
Fix kotlin tests
anna-parker Jul 11, 2024
8accc57
Modify get_ena_submission_list to get data for all organisms.
anna-parker Jul 11, 2024
082c7d1
Fix formatting
anna-parker Jul 12, 2024
7c7f896
Use externalMetadata in en-submission-pod.
anna-parker Jul 12, 2024
49fde3a
Fix submit-externa-metadata function.
anna-parker Jul 12, 2024
d46ce73
Change permissions in config not backend
anna-parker Jul 12, 2024
219ba21
Make pod sleep to stop kubernetes constantly restarting the job
anna-parker Jul 12, 2024
7f69539
Trial 2
anna-parker Jul 12, 2024
eab2de8
trial 3
anna-parker Jul 12, 2024
0adfa05
trial 4
anna-parker Jul 12, 2024
b38506d
Sleep in snakefile.
anna-parker Jul 12, 2024
484241d
Merge branch 'main' into ena_submission_pod
anna-parker Jul 12, 2024
32e20e1
Remove project creation related scripts -> these will be added in a l…
anna-parker Jul 12, 2024
abb7835
Add suggestions
anna-parker Jul 15, 2024
18203ce
Check that data is also open.
anna-parker Jul 16, 2024
340564e
Change print to log
anna-parker Jul 16, 2024
66ed3c0
Make helper functions clearer
anna-parker Jul 22, 2024
ad4a614
Merge branch 'main' into ena_submission_pod
anna-parker Jul 22, 2024
a20080f
Refactor
anna-parker Jul 23, 2024
09c91b9
Fix configs
anna-parker Jul 23, 2024
438103a
Fix order
anna-parker Jul 23, 2024
ee0ffe4
Merge remote-tracking branch 'origin/ena_submission_pod' into ena_sub…
anna-parker Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build-arm-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
uses: ./.github/workflows/ingest-image.yml
with:
build_arm: true
trigger-ena-submission:
uses: ./.github/workflows/ena-submission-image.yml
with:
build_arm: true
trigger-ena-submission-flyway:
uses: ./.github/workflows/ena-submission-flyway-image.yml
with:
build_arm: true
trigger-keycloakify:
uses: ./.github/workflows/keycloakify-image.yml
with:
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/ena-submission-flyway-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: ena-submission-flyway-image
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
build_arm:
type: boolean
description: "Build for ARM as well"
default: false
required: true
workflow_call:
inputs:
build_arm:
type: string
description: "Build for ARM as well"
default: "false"
required: true
env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/ena-submission-flyway
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BUILD_ARM: ${{ github.event.inputs.build_arm || inputs.build_arm || github.ref == 'refs/heads/main' }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
defaults:
run:
working-directory: ./ena-submission/flyway
concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-ena-submission-flyway-${{github.event.inputs.build_arm}}
cancel-in-progress: true
jobs:
ena-submission-flyway-image:
name: Build ena-submission-flyway Docker Image # Don't change: Referenced by .github/workflows/update-argocd-metadata.yml
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: write
checks: read
steps:
- uses: actions/checkout@v4
- name: Shorten sha
run: echo "sha=${sha::7}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=${{ env.BRANCH_NAME }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=commit-${{ env.sha }}
type=raw,value=${{ env.BRANCH_NAME }}-arm,enable=${{ env.BUILD_ARM }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: ./ena-submission/flyway
push: true
tags: ${{ steps.dockerMetadata.outputs.tags }}
platforms: ${{ env.BUILD_ARM == 'true' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
87 changes: 87 additions & 0 deletions .github/workflows/ena-submission-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: ena-submission-image
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
build_arm:
type: boolean
description: "Build for ARM as well"
default: false
required: false
workflow_call:
inputs:
build_arm:
type: boolean
description: "Build for ARM as well"
default: false
required: false
env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/ena-submission
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BUILD_ARM: ${{ github.event.inputs.build_arm || inputs.build_arm || github.ref == 'refs/heads/main' }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-ena-submission-${{github.event.inputs.build_arm}}
cancel-in-progress: true
jobs:
ena-submission-image:
name: Build ena-submission Docker Image # Don't change: Referenced by .github/workflows/update-argocd-metadata.yml
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: write
checks: read
steps:
- name: Shorten sha
run: echo "sha=${sha::7}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Generate files hash
id: files-hash
run: |
DIR_HASH=$(echo -n ${{ hashFiles('ena-submission/**', '.github/workflows/ena-submission-image.yml') }})
echo "DIR_HASH=$DIR_HASH${{ env.BUILD_ARM == 'true' && '-arm' || '' }}" >> $GITHUB_ENV
- name: Setup Docker metadata
id: dockerMetadata
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=${{ env.DIR_HASH }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=${{ env.BRANCH_NAME }}
type=raw,value=commit-${{ env.sha }}
type=raw,value=${{ env.BRANCH_NAME }}-arm,enable=${{ env.BUILD_ARM }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if image exists
id: check-image
run: |
EXISTS=$(docker manifest inspect ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false")
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image if input files changed
if: env.CACHE_HIT == 'false'
uses: docker/build-push-action@v6
with:
context: ./ena-submission
push: true
tags: ${{ steps.dockerMetadata.outputs.tags }}
cache-from: type=gha,scope=ena-submission-${{ github.ref }}
cache-to: type=gha,mode=max,scope=ena-submission-${{ github.ref }}
platforms: ${{ env.BUILD_ARM == 'true' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
- name: Retag and push existing image if cache hit
if: env.CACHE_HIT == 'true'
run: |
TAGS=(${{ steps.dockerMetadata.outputs.tags }})
for TAG in "${TAGS[@]}"; do
docker buildx imagetools create --tag $TAG ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DIR_HASH }}
done
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class SecurityConfig {

private val endpointsForExternalMetadataUpdater = arrayOf(
"/*/submit-external-metadata",
"/*/get-released-data",
)

private val getEndpointsThatArePublic = arrayOf(
Expand Down Expand Up @@ -87,8 +86,10 @@ class SecurityConfig {
auth.requestMatchers(HttpMethod.GET, *getEndpointsThatArePublic).permitAll()
auth.requestMatchers(HttpMethod.OPTIONS).permitAll()
auth.requestMatchers(*endpointsForPreprocessingPipeline).hasAuthority(PREPROCESSING_PIPELINE)
auth.requestMatchers(
*endpointsForExternalMetadataUpdater,
).hasAuthority(EXTERNAL_METADATA_UPDATER)
auth.requestMatchers(*endpointsForGettingReleasedData).hasAuthority(GET_RELEASED_DATA)
auth.requestMatchers(*endpointsForExternalMetadataUpdater).hasAuthority(EXTERNAL_METADATA_UPDATER)
auth.requestMatchers(*debugEndpoints).hasAuthority(SUPER_USER)
auth.anyRequest().authenticated()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val jwtForDefaultUser = generateJwtFor(DEFAULT_USER_NAME)
val jwtForProcessingPipeline = generateJwtFor("preprocessing_pipeline", listOf(PREPROCESSING_PIPELINE))
val jwtForGetReleasedData = generateJwtFor("silo_import_job", listOf(GET_RELEASED_DATA))
val jwtForExternalMetadataUpdatePipeline =
generateJwtFor("external_metadata_updater", listOf(EXTERNAL_METADATA_UPDATER))
generateJwtFor("external_metadata_updater", listOf(EXTERNAL_METADATA_UPDATER, GET_RELEASED_DATA))
val jwtForSuperUser = generateJwtFor(SUPER_USER_NAME, listOf(SUPER_USER))

fun generateJwtFor(username: String, roles: List<String> = emptyList()): String = Jwts.builder()
Expand Down
10 changes: 9 additions & 1 deletion deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
helm_parser.add_argument(
"--enableIngest", action="store_true", help="Include deployment of ingest pipelines"
)
helm_parser.add_argument(
"--enableEnaSubmission",
action="store_true",
help="Include deployment of ena submission pipelines",
anna-parker marked this conversation as resolved.
Show resolved Hide resolved
)
helm_parser.add_argument(
"--values", help="Values file for helm chart", default=HELM_VALUES_FILE
)
Expand Down Expand Up @@ -234,6 +239,9 @@ def handle_helm():
if not args.enableIngest:
parameters += ["--set", "disableIngest=true"]

if not args.enableEnaSubmission:
parameters += ["--set", "disableEnaSubmission=true"]

if get_codespace_name():
parameters += ["--set", "codespaceName=" + get_codespace_name()]

Expand Down Expand Up @@ -306,7 +314,7 @@ def generate_configs(from_live=False):
from_live,
ingest_configout_path,
)

prepro_configmap_path = TEMP_DIR / "preprocessing-config.yaml"
prepro_template_path = "templates/loculus-preprocessing-config.yaml"
prepro_configout_path = TEMP_DIR / "preprocessing-config.yaml"
Expand Down
2 changes: 2 additions & 0 deletions ena-submission/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.snakemake/
results/
6 changes: 6 additions & 0 deletions ena-submission/.mambarc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
channels:
- conda-forge
- bioconda
repodata_use_zst: true
channel_priority: strict
download_threads: 20
15 changes: 15 additions & 0 deletions ena-submission/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mambaorg/micromamba:1.5.8

COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/env.yaml
COPY --chown=$MAMBA_USER:$MAMBA_USER .mambarc /tmp/.mambarc

RUN micromamba config set extract_threads 1 \
&& micromamba install -y -n base -f /tmp/env.yaml --rc-file /tmp/.mambarc \
&& micromamba clean --all --yes

# Set the environment variable to activate the conda environment
ARG MAMBA_DOCKERFILE_ACTIVATE=1

COPY --chown=$MAMBA_USER:$MAMBA_USER . /package

WORKDIR /package
Loading
Loading