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

TASK-6757 - Deployment: Add Jupyter Notebooks feature #2539

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
149577b
Prepare new development version 3.0.0.2-SNAPSHOT
juanfeSanahuja May 29, 2024
baa1717
app: initial jupyter python notebook
imedina Sep 5, 2024
d435ec3
catalog: create cohort does not increment sample version, #TASK-6754
pfurio Sep 23, 2024
e3c6837
Merge branch 'release-3.x.x' into TASK-6754
pfurio Oct 11, 2024
4536689
Prepare next release 3.4.0-SNAPSHOT
juanfeSanahuja Oct 15, 2024
911091a
Merge branch 'release-3.x.x' into TASK-6754
pfurio Oct 17, 2024
bebdccb
catalog: check vsets can be created by study admins, #TASK-7004
pfurio Oct 17, 2024
27f5906
app: allow changing the organization id during main migration,#TASK-7118
pfurio Oct 21, 2024
abd6428
Merge branch 'release-3.0.0.x' into TASK-7118
pfurio Oct 21, 2024
1f25e7a
Adapt pom to the new SDLC #TASK-7118
juanfeSanahuja Oct 21, 2024
4a0618f
Merge branch 'release-3.0.x' into TASK-7118
juanfeSanahuja Oct 21, 2024
acac916
app: store old fqn in attributes before migration, #TASK-7118
pfurio Oct 22, 2024
d42fd7f
Merge pull request #2517 from opencb/TASK-6754
pfurio Oct 22, 2024
d2c8073
app: Ensure project.internal.datastores.variant is defined when chang…
j-coll Oct 23, 2024
bfe1925
app: Fix NPE. Add appHome to OrganizationMigration. #TASK-7118
j-coll Oct 24, 2024
85671b9
app: Rename StudyMetadata.name to match the new fqn. #TASK-7118
j-coll Oct 25, 2024
f73fbc1
app: Fix rename storage studyFqn #TASK-7118
j-coll Oct 28, 2024
d796b3d
app: Ensure OrganizationMigration is marked as "manual" to avoid auto…
j-coll Oct 28, 2024
23ff61c
Merge pull request #2523 from opencb/TASK-7118
pfurio Oct 29, 2024
f45c223
Prepare release 3.0.1
juanfeSanahuja Oct 30, 2024
e2c1261
Prepare new development version 3.0.2-SNAPSHOT
juanfeSanahuja Oct 30, 2024
345a6f2
Prepare release 3.0.2
juanfeSanahuja Oct 30, 2024
3863e5e
Prepare release 3.0.1
juanfeSanahuja Oct 30, 2024
1269834
Prepare release 3.0.1
juanfeSanahuja Oct 30, 2024
40484f0
Prepare release 3.0.1
juanfeSanahuja Oct 30, 2024
20423c3
Prepare release 3.0.2
juanfeSanahuja Oct 30, 2024
909cd78
Merge branch 'release-3.x.x' into TASK-7004
pfurio Nov 4, 2024
feedb60
Merge pull request #2520 from opencb/TASK-7004
pfurio Nov 4, 2024
80943c3
catalog: fix sync user functionality, #TASK-7187
pfurio Nov 8, 2024
be61b15
app: ensure all jobs have an attributes field, #TASK-7207
pfurio Nov 15, 2024
d30dac9
app: Always rename studies from storage when changing organization id…
j-coll Nov 15, 2024
160fccc
Merge pull request #2531 from opencb/TASK-7207
pfurio Nov 18, 2024
3e7089a
Prepare release 3.0.2
juanfeSanahuja Nov 21, 2024
76ff1e9
Prepare Port Patch 3.0.2 -> 3.4.0 Xetabase 2.0.2 -> 2.4.0 #TASK-7213
juanfeSanahuja Nov 27, 2024
f5ad886
Conflicts in opencga-app/src/main/java/org/opencb/opencga/app/migrati…
juanfeSanahuja Nov 27, 2024
3b39feb
app: fix OrgMigration merge issues, #TASK-7213
pfurio Nov 27, 2024
b4b431c
Merge pull request #2528 from opencb/TASK-7187
pfurio Dec 4, 2024
317e356
Merge branch 'release-3.x.x' into TASK-7213
juanfeSanahuja Dec 16, 2024
e2b0541
Merge pull request #2533 from opencb/TASK-7213
juanfeSanahuja Dec 16, 2024
aafd345
Added deploy-docker-python-notebook #TASK-5914
juanfeSanahuja Dec 18, 2024
3d1dfac
Added deploy-docker-python-notebook #TASK-5914
juanfeSanahuja Dec 18, 2024
a504309
Added Version to python-notebook dockerfile #TASK-6757
juanfeSanahuja Dec 18, 2024
e72ac3c
Added --no-transfer-progress in build dockers #TASK-6757
juanfeSanahuja Dec 19, 2024
fb6c37e
Merge branch 'release-3.x.x' into TASK-6757
juanfeSanahuja Dec 19, 2024
a5c25ae
Added --build-arg in deploy-docker-python-notebook #TASK-6757
juanfeSanahuja Dec 19, 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
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} ${{ inputs.hadoop }}
fi
- name: Maven Build (skip tests)
run: mvn -T 2 clean install -DskipTests -P${{ inputs.hadoop }} -Dopencga.war.name=opencga -Dcheckstyle.skip
run: mvn -T 2 clean install -DskipTests -P${{ inputs.hadoop }} -Dopencga.war.name=opencga -Dcheckstyle.skip --no-transfer-progress
- uses: actions/upload-artifact@v4
with:
name: build-folder
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-ext-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} ${{ inputs.hadoop }}
fi
- name: Maven Build (skip tests)
run: mvn -T 2 clean install -DskipTests
run: mvn -T 2 clean install -DskipTests --no-transfer-progress
- uses: actions/upload-artifact@v4
with:
name: build-folder
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/manual-deploy-python-notebook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Reusable deploy Docker python-notebook
run-name: 'Run deploy Docker python-notebook ${{ inputs.branch }} by @${{ github.actor }}'
on:
workflow_dispatch:
inputs:
branch:
description: "The branch, tag or SHA of the source code to build docker."
type: string
required: true
tag:
description: "The tag for the new docker."
type: string
required: true
hadoop:
type: string
description: 'Hadoop flavour. Any of: [hdp3.1, hdi5.1, emr6.1, emr6.13]'
required: false
default: "hdp3.1"
pyopencga_version:
type: string
description: 'PyOpenCGA version.'
required: true

jobs:
build:
name: Build Java app
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_project_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '10'
ref: "${{ inputs.branch }}"
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Install dependencies branches
run: |
if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then
chmod +x ./.github/workflows/scripts/get_same_branch.sh
./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} ${{ inputs.hadoop }}
fi
- name: Maven Build (skip tests)
run: mvn -T 2 clean install -DskipTests -Dmaven.test.skip=true --no-transfer-progress
- uses: actions/upload-artifact@v4
with:
name: build-folder
path: build

deploy-docker-python-notebook:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: build
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images python-notebook --tag ${{ inputs.tag }} --docker-build-args "--build-arg VERSION=${{ inputs.pyopencga_version }}"
secrets: inherit

9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ jobs:
artifact: build-folder
secrets: inherit

deploy-docker-python-notebook:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: [build-hdp, deploy-python]
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images python-notebook --tag ${{ needs.build-hdp.outputs.version }} --docker-build-args "--build-arg VERSION=${{ needs.build-hdp.outputs.version }}"
secrets: inherit

# Add the release job that depends on all the previous jobs
release:
uses: opencb/java-common-libs/.github/workflows/release-github-workflow.yml@develop
needs: [ build-hdp, deploy-docker-hdp, deploy-maven, deploy-python]
needs: [ build-hdp, deploy-docker-hdp, deploy-maven, deploy-python, deploy-docker-python-notebook]
with:
artifact: build-folder
file: |
Expand Down
2 changes: 1 addition & 1 deletion opencga-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.opencga</groupId>
<artifactId>opencga</artifactId>
<version>3.3.0</version>
<version>3.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,8 +1757,7 @@ public static DataStore defaultDataStore(CatalogManager catalogManager, Project
return defaultDataStore(catalogManager.getConfiguration().getDatabasePrefix(), project.getFqn());
}

public static DataStore defaultDataStore(String databasePrefix, String projectFqnStr)
throws CatalogException {
public static DataStore defaultDataStore(String databasePrefix, String projectFqnStr) {
CatalogFqn projectFqn = CatalogFqn.extractFqnFromProjectFqn(projectFqnStr);

String dbName = buildDatabaseName(databasePrefix, projectFqn.getOrganizationId(), projectFqn.getProjectId());
Expand Down
4 changes: 2 additions & 2 deletions opencga-app/app/cloud/docker/docker-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('action', help="Action to execute", choices=["build", "push", "delete"], default="build")
parser.add_argument('--images',
help="comma separated list of images to be made, e.g. base,init,ext-tools,r-builder")
help="comma separated list of images to be made, e.g. base,init,ext-tools,python-notebook,r-builder")
parser.add_argument('--tag', help="the tag for this code, e.g. v2.0.0-hdp3.1")
parser.add_argument('--build-folder', help="the location of the build folder, if not default location")
parser.add_argument('--org', help="Docker organization", default="opencb")
Expand Down Expand Up @@ -201,7 +201,7 @@ def delete():

# 5. Get a list with all images
if args.images is None:
images = ["base", "init", "demo", "r", "samtools", "ext-tools"]
images = ["base", "init", "demo", "r", "samtools", "python-notebook", "ext-tools"]
else:
imagesUnsorted = args.images.split(",")
images = []
Expand Down
13 changes: 13 additions & 0 deletions opencga-app/app/cloud/docker/opencga-python-notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Start from the Jupyter scipy-notebook image
FROM quay.io/jupyter/scipy-notebook:ubuntu-24.04
ARG VERSION
USER root

RUN apt-get update && apt-get -y upgrade && \
## Install pyopencga ${VERSION}
pip install pyopencga==${VERSION} && \
## Clean downloaded packages to make images smaller
apt-get clean && rm -rf /var/lib/apt/lists/*

## Run Docker images as non root
USER ${NB_UID}
2 changes: 1 addition & 1 deletion opencga-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.opencb.opencga</groupId>
<artifactId>opencga</artifactId>
<version>3.3.0</version>
<version>3.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void runMigrationToV3() throws Exception {
setCatalogDatabaseCredentials(options, options.commonOptions);

OrganizationMigration organizationMigration = new OrganizationMigration(configuration, options.commonOptions.adminPassword,
options.user);
options.user, options.organizationId, Paths.get(appHome));
organizationMigration.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class OrganizationMigrationCommandOptions extends AdminCliOptionsParser.C
@Parameter(names = {"--user"}, description = "User whose data is going to be migrated. If more than one user of type FULL contains"
+ " projects and studies, only the one provided will keep the data and will be fully migrated.")
public String user;

@Parameter(names = {"--organization-id"}, description = "Optional parameter to specify how the new organization will be named." +
" By default, if not provided, the organization id will match the user id that is currently owning the data.")
public String organizationId;
}

@Parameters(commandNames = {"summary"}, commandDescription = "Obtain migrations status summary")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import org.opencb.opencga.catalog.migration.MigrationTool;
import org.opencb.opencga.core.config.Configuration;

import java.nio.file.Path;

@Migration(id = "add_organizations", description = "Add new Organization layer #TASK-4389", version = "3.0.0",
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20231212,
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20231212, manual = true,
deprecatedSince = "3.1.0")

public class OrganizationMigration extends MigrationTool {

public OrganizationMigration(Configuration configuration, String adminPassword, String userId) {
public OrganizationMigration(Configuration configuration, String adminPassword, String userId, String organizationId, Path appHome) {
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion opencga-catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.opencb.opencga</groupId>
<artifactId>opencga</artifactId>
<version>3.3.0</version>
<version>3.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public void checkCanAssignOrSeePermissions(String organizationId, long studyId,

@Override
public void checkCanCreateUpdateDeleteVariableSets(String organizationId, long studyId, String userId) throws CatalogException {
if (!isAtLeastOrganizationOwnerOrAdmin(organizationId, userId)) {
throw CatalogAuthorizationException.notOrganizationOwnerOrAdmin("create, update or delete variable sets.");
if (!isAtLeastStudyAdministrator(organizationId, studyId, userId)) {
throw CatalogAuthorizationException.notStudyAdmin("create, update or delete variable sets.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ public abstract class AnnotationMongoDBAdaptor<T> extends CatalogMongoDBAdaptor

protected abstract MongoDBCollection getCollection();

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
return transactionalUpdate(clientSession, entry, parameters, variableSetList, queryOptions, true);
}

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, T entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions, boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException;

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
return transactionalUpdate(clientSession, studyUid, query, updateDocument, true);
}

abstract OpenCGAResult<T> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException;

public enum AnnotationSetParams implements QueryParam {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,21 @@ OpenCGAResult transactionalUpdate(ClientSession clientSession, ClinicalAnalysis

@Override
OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession, ClinicalAnalysis entry, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
List<VariableSet> variableSetList, QueryOptions queryOptions,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
throw new NotImplementedException("Please call to the other transactionalUpdate method passing the ClinicalAudit list");
}

@Override
OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query,
UpdateDocument updateDocument)
UpdateDocument updateDocument, boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
long tmpStartTime = startQuery();

Document updateOperation = updateDocument.toFinalUpdateDocument();
if (!updateOperation.isEmpty()) {
return versionedMongoDBAdaptor.update(clientSession, query, entryList -> {
SnapshotVersionedMongoDBAdaptor.FunctionWithException<ClinicalAnalysis> updateClinicalReferences = (clinicalList) -> {
logger.debug("Update clinical analysis. Query: {}, Update: {}", query.toBsonDocument(), updateDocument);
DataResult<?> update = clinicalCollection.update(clientSession, query, updateOperation, null);

Expand All @@ -385,7 +386,12 @@ OpenCGAResult<ClinicalAnalysis> transactionalUpdate(ClientSession clientSession,

logger.debug("{} clinical analyses successfully updated", update.getNumUpdated());
return endWrite(tmpStartTime, update.getNumMatches(), update.getNumUpdated(), Collections.emptyList());
}, null, null);
};
if (incrementVersion) {
return versionedMongoDBAdaptor.update(clientSession, query, null, updateClinicalReferences, null, null);
} else {
return versionedMongoDBAdaptor.updateWithoutVersionIncrement(clientSession, query, null, updateClinicalReferences);
}
} else {
throw new CatalogDBException("Nothing to update");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public OpenCGAResult update(Query query, ObjectMap parameters, List<VariableSet>

@Override
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, Cohort cohort, ObjectMap parameters,
List<VariableSet> variableSetList, QueryOptions queryOptions)
List<VariableSet> variableSetList, QueryOptions queryOptions, boolean incrementVersion)
throws CatalogDBException, CatalogParameterException, CatalogAuthorizationException {
long tmpStartTime = startQuery();
Query tmpQuery = new Query()
Expand Down Expand Up @@ -341,7 +341,8 @@ OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, Cohort co
}

@Override
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument)
OpenCGAResult<Cohort> transactionalUpdate(ClientSession clientSession, long studyUid, Bson query, UpdateDocument updateDocument,
boolean incrementVersion)
throws CatalogParameterException, CatalogDBException, CatalogAuthorizationException {
long tmpStartTime = startQuery();

Expand Down
Loading