Skip to content

Commit d68a9be

Browse files
authored
✨Comp backend: allow to change to s3 links on on demand clusters (⚠️ devops) (#4740)
1 parent 300dae0 commit d68a9be

File tree

15 files changed

+62
-16
lines changed

15 files changed

+62
-16
lines changed

.env-devel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ DIRECTOR_REGISTRY_CACHING_TTL=900
4444
DIRECTOR_REGISTRY_CACHING=True
4545

4646
COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_URL=tcp://dask-scheduler:8786
47+
COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_FILE_LINK_TYPE=S3
48+
COMPUTATIONAL_BACKEND_DEFAULT_FILE_LINK_TYPE=PRESIGNED
49+
COMPUTATIONAL_BACKEND_ON_DEMAND_CLUSTERS_FILE_LINK_TYPE=PRESIGNED
4750
DIRECTOR_V2_DEV_FEATURES_ENABLED=0
4851

4952
DYNAMIC_SIDECAR_IMAGE=${DOCKER_REGISTRY:-itisfoundation}/dynamic-sidecar:${DOCKER_IMAGE_TAG:-latest}

ci/github/integration-testing/director-v2.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test() {
2121
# shellcheck source=/dev/null
2222
source .venv/bin/activate
2323
pushd services/director-v2
24-
make test-ci-integration test-subfolder="$1"
24+
make test-ci-integration test-path="$1"
2525
popd
2626
}
2727

ci/github/integration-testing/webserver.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test() {
2121
# shellcheck source=/dev/null
2222
source .venv/bin/activate
2323
pushd services/web/server
24-
make test-ci-integration test-subfolder="$1"
24+
make test-ci-integration test-path="$1"
2525
popd
2626
}
2727

ci/github/unit-testing/director-v2.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test() {
2323
pushd services/director-v2
2424
make test-ci-unit pytest-parameters="--numprocesses=auto --ignore-glob=**/with_dbs/**"
2525
# these tests cannot be run in parallel
26-
make test-ci-unit test-subfolder=with_dbs
26+
make test-ci-unit test-path=with_dbs
2727
popd
2828
}
2929

ci/github/unit-testing/webserver.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_isolated() {
2727
# shellcheck source=/dev/null
2828
source .venv/bin/activate
2929
pushd services/web/server
30-
make test-ci-unit test-subfolder=isolated pytest-parameters="--numprocesses=auto"
30+
make test-ci-unit test-path=isolated pytest-parameters="--numprocesses=auto"
3131
popd
3232
}
3333

@@ -36,7 +36,7 @@ test_with_db() {
3636
source .venv/bin/activate
3737
pushd services/web/server
3838
echo "testing in services/web/server/tests/unit/with_dbs/$1"
39-
make test-ci-unit test-subfolder="with_dbs/$1"
39+
make test-ci-unit test-path="with_dbs/$1"
4040
popd
4141
}
4242

packages/models-library/src/models_library/api_schemas_directorv2/clusters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def set_default_thumbnail_if_empty(cls, v, values):
126126
default_thumbnails = {
127127
ClusterTypeInModel.AWS.value: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Amazon_Web_Services_Logo.svg/250px-Amazon_Web_Services_Logo.svg.png",
128128
ClusterTypeInModel.ON_PREMISE.value: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Crystal_Clear_app_network_local.png/120px-Crystal_Clear_app_network_local.png",
129+
ClusterTypeInModel.ON_DEMAND.value: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Amazon_Web_Services_Logo.svg/250px-Amazon_Web_Services_Logo.svg.png",
129130
}
130131
return default_thumbnails[cluster_type]
131132
return v

packages/models-library/src/models_library/clusters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020

2121
class ClusterTypeInModel(StrAutoEnum):
22-
# This enum is equivalent to `simcore_postgres_database.models.clusters.ClusterType`
22+
# This enum contains more types than its equivalent to `simcore_postgres_database.models.clusters.ClusterType`
2323
# SEE models-library/tests/test__pydantic_models_and_enums.py
2424
AWS = auto()
2525
ON_PREMISE = auto()
26+
ON_DEMAND = auto()
2627

2728

2829
class ClusterAccessRights(BaseModel):

packages/models-library/tests/test_clusters.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
CLUSTER_USER_RIGHTS,
1010
DEFAULT_CLUSTER_ID,
1111
Cluster,
12+
ClusterTypeInModel,
1213
)
1314
from pydantic import BaseModel, ValidationError
15+
from simcore_postgres_database.models.clusters import ClusterType
1416

1517

1618
@pytest.mark.parametrize(
1719
"model_cls",
18-
(Cluster,),
20+
[
21+
Cluster,
22+
],
1923
)
2024
def test_cluster_access_rights_correctly_created_when_owner_access_rights_not_present(
2125
model_cls: type[BaseModel], model_cls_examples: dict[str, dict[str, Any]]
@@ -35,7 +39,9 @@ def test_cluster_access_rights_correctly_created_when_owner_access_rights_not_pr
3539

3640
@pytest.mark.parametrize(
3741
"model_cls",
38-
(Cluster,),
42+
[
43+
Cluster,
44+
],
3945
)
4046
def test_cluster_fails_when_owner_has_no_admin_rights_unless_default_cluster(
4147
model_cls: type[BaseModel],
@@ -61,7 +67,9 @@ def test_cluster_fails_when_owner_has_no_admin_rights_unless_default_cluster(
6167

6268
@pytest.mark.parametrize(
6369
"model_cls",
64-
(Cluster,),
70+
[
71+
Cluster,
72+
],
6573
)
6674
def test_cluster_fails_when_owner_has_no_user_rights_if_default_cluster(
6775
model_cls: type[BaseModel],
@@ -82,3 +90,23 @@ def test_cluster_fails_when_owner_has_no_user_rights_if_default_cluster(
8290
modified_example["access_rights"][owner_gid] = CLUSTER_ADMIN_RIGHTS
8391
with pytest.raises(ValidationError):
8492
model_cls(**modified_example)
93+
94+
95+
def test_cluster_type_in_model_includes_postgres_database_model():
96+
models_library_cluster_types_names: set[str] = {
97+
t.name for t in set(ClusterTypeInModel)
98+
}
99+
postgres_library_cluster_types_names: set[str] = {t.name for t in set(ClusterType)}
100+
assert postgres_library_cluster_types_names.issubset(
101+
models_library_cluster_types_names
102+
)
103+
104+
models_library_cluster_types_values: set[str] = {
105+
t.value for t in set(ClusterTypeInModel)
106+
} # type: ignore
107+
postgres_library_cluster_types_values: set[str] = {
108+
t.value for t in set(ClusterType)
109+
}
110+
assert postgres_library_cluster_types_values.issubset(
111+
models_library_cluster_types_values
112+
)

scripts/common-service.Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ install-dev install-prod install-ci: _check_venv_active ## install app in develo
4242

4343
.PHONY: test-dev-unit test-ci-unit test-dev-integration test-ci-integration test-dev
4444

45-
TEST_SUBFOLDER := $(if $(test-subfolder),/$(test-subfolder),)
46-
test-dev-unit test-ci-unit: _check_venv_active
45+
TEST_PATH := $(if $(test-path),/$(patsubst tests/integration/%,%, $(patsubst tests/unit/%,%, $(patsubst %/,%,$(test-path)))),)
46+
test-dev-unit test-ci-unit: _check_venv_active ## run app unit tests (specifying test-path can restrict to a folder)
4747
# Targets tests/unit folder
48-
@make --no-print-directory _run-$(subst -unit,,$@) target=$(CURDIR)/tests/unit$(TEST_SUBFOLDER)
48+
@make --no-print-directory _run-$(subst -unit,,$@) target=$(CURDIR)/tests/unit$(TEST_PATH)
4949

50-
test-dev-integration test-ci-integration:
50+
test-dev-integration test-ci-integration: ## run app integration tests (specifying test-path can restrict to a folder)
5151
# Targets tests/integration folder using local/$(image-name):production images
5252
@export DOCKER_REGISTRY=local; \
5353
export DOCKER_IMAGE_TAG=production; \
54-
make --no-print-directory _run-$(subst -integration,,$@) target=$(CURDIR)/tests/integration$(TEST_SUBFOLDER)
54+
make --no-print-directory _run-$(subst -integration,,$@) target=$(CURDIR)/tests/integration$(TEST_PATH)
5555

5656

5757
test-dev: test-dev-unit test-dev-integration ## runs unit and integration tests for development (e.g. w/ pdb)

services/director-v2/src/simcore_service_director_v2/core/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ class ComputationalBackendSettings(BaseCustomSettings):
471471
FileLinkType.PRESIGNED,
472472
description=f"Default file link type to use with computational backend '{list(FileLinkType)}'",
473473
)
474+
COMPUTATIONAL_BACKEND_ON_DEMAND_CLUSTERS_FILE_LINK_TYPE: FileLinkType = Field(
475+
FileLinkType.PRESIGNED,
476+
description=f"Default file link type to use with computational backend on-demand clusters '{list(FileLinkType)}'",
477+
)
474478

475479
@cached_property
476480
def default_cluster(self) -> Cluster:

0 commit comments

Comments
 (0)