Skip to content

Commit

Permalink
squashme: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Oct 24, 2024
1 parent ed2325a commit ae494a1
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: schemas tests test_setup main_tests schemathesis_tests collect_coverage style_checks pre_commit_checks run download_avro check_avro avro_models update_avro k3d_cluster install_amaltheas all

AMALTHEA_JS_VERSION ?= 0.12.2
AMALTHEA_SESSIONS_VERSION ?= 0.0.10-new-operator-chart
AMALTHEA_JS_VERSION ?= 0.13.0
AMALTHEA_SESSIONS_VERSION ?= 0.13.0
codegen_params = --input-file-type openapi --output-model-type pydantic_v2.BaseModel --use-double-quotes --target-python-version 3.12 --collapse-root-models --field-constraints --strict-nullable --set-default-enum-member --openapi-scopes schemas paths parameters --set-default-enum-member --use-one-literal-as-default --use-default

define test_apispec_up_to_date
Expand Down Expand Up @@ -163,5 +163,5 @@ install_amaltheas: ## Installs both version of amalthea in the. NOTE: It uses t

# TODO: Add the version variables from the top of the file here when the charts are fully published
amalthea_schema: ## Updates generates pydantic classes from CRDs
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/feat-add-cloud-storage/config/crd/bases/amalthea.dev_amaltheasessions.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --input-file-type jsonschema --output-model-type pydantic_v2.BaseModel --output components/renku_data_services/notebooks/cr_amalthea_session.py --use-double-quotes --target-python-version 3.12 --collapse-root-models --field-constraints --strict-nullable --base-class renku_data_services.notebooks.cr_base.BaseCRD --allow-extra-fields --use-default-kwarg
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/main/config/crd/bases/amalthea.dev_amaltheasessions.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --input-file-type jsonschema --output-model-type pydantic_v2.BaseModel --output components/renku_data_services/notebooks/cr_amalthea_session.py --use-double-quotes --target-python-version 3.12 --collapse-root-models --field-constraints --strict-nullable --base-class renku_data_services.notebooks.cr_base.BaseCRD --allow-extra-fields --use-default-kwarg
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/main/controller/crds/jupyter_server.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --input-file-type jsonschema --output-model-type pydantic_v2.BaseModel --output components/renku_data_services/notebooks/cr_jupyter_server.py --use-double-quotes --target-python-version 3.12 --collapse-root-models --field-constraints --strict-nullable --base-class renku_data_services.notebooks.cr_base.BaseCRD --allow-extra-fields --use-default-kwarg
23 changes: 16 additions & 7 deletions components/renku_data_services/notebooks/blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
)
from renku_data_services.notebooks.config import NotebooksConfig
from renku_data_services.notebooks.crs import (
Affinity,
AmaltheaSessionSpec,
AmaltheaSessionV1Alpha1,
Authentication,
Expand All @@ -62,6 +63,7 @@
State,
Storage,
TlsSecret,
Toleration,
)
from renku_data_services.notebooks.errors.intermittent import AnonymousUserPatchError
from renku_data_services.notebooks.util.kubernetes_ import (
Expand Down Expand Up @@ -317,18 +319,19 @@ async def _handler(
)
if csr.target_path is not None and not PurePosixPath(csr.target_path).is_absolute():
csr.target_path = (work_dir / csr.target_path).as_posix()
if csr_id in dcs_secrets and csr.configuration is not None:
raise errors.ValidationError(
message=f"Overriding the storage configuration for storage with ID {csr_id} "
"is not allowed because the storage has an associated saved secret.",
)
# TODO: The UI always does this check if it is acceptable/safe
# if csr_id in dcs_secrets and csr.configuration is not None:
# raise errors.ValidationError(
# message=f"Overriding the storage configuration for storage with ID {csr_id} "
# "is not allowed because the storage has an associated saved secret.",
# )
dcs[csr_id] = dcs[csr_id].with_override(csr)
repositories = [Repository(url=i) for i in project.repositories]
secrets_to_create: list[V1Secret] = []
# Generate the cloud starge secrets
data_sources: list[DataSource] = []
for cs_id, cs in dcs.items():
secret_name = f"{server_name}-ds-{cs_id}"
secret_name = f"{server_name}-ds-{cs_id.lower()}"
secrets_to_create.append(cs.secret(secret_name, self.nb_config.k8s_client.preferred_namespace))
data_sources.append(
DataSource(mountPath=cs.mount_folder, secretRef=SecretRefWhole(name=secret_name, adopt=True))
Expand Down Expand Up @@ -433,6 +436,12 @@ async def _handler(
else [],
),
dataSources=data_sources,
tolerations=[
Toleration.model_validate(toleration) for toleration in self.nb_config.sessions.tolerations
],
affinity=Affinity.model_validate(self.nb_config.sessions.affinity)
if len(self.nb_config.sessions.affinity.keys()) > 0
else None,
),
)
parsed_proxy_url = urlparse(urljoin(base_server_url + "/", "oauth2"))
Expand Down Expand Up @@ -483,7 +492,7 @@ async def _handler(
headers = {"Authorization": f"bearer {user.access_token}"}
for s_id, secrets in dcs_secrets.items():
request_data = {
"name": f"{server_name}-ds-{s_id}-secrets",
"name": f"{server_name}-ds-{s_id.lower()}-secrets",
"namespace": self.nb_config.k8s_v2_client.preferred_namespace,
"secret_ids": [str(secret.secret_id) for secret in secrets],
"owner_references": [owner_reference],
Expand Down
Loading

0 comments on commit ae494a1

Please sign in to comment.