From 44e8b51e9bfee3ba4a0434cafa2ae17c203da5bc Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:03:33 +0200 Subject: [PATCH 1/6] upgrade metadata --- metadata/metadata.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata/metadata.yml b/metadata/metadata.yml index 1c83dc1..c441f88 100644 --- a/metadata/metadata.yml +++ b/metadata/metadata.yml @@ -1,9 +1,11 @@ name: oSparc Python Runner +description: https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/refs/heads/main/app/full/services/simcore_services_comp_osparc-python-runner.md +icon: https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/main/app/icons/s4l/simcore_services_comp_osparc-python-runner.png +thumbnail: https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/main/app/thumbnails/s4l/simcore_services_comp_osparc-python-runner.png key: simcore/services/comp/osparc-python-runner type: computational integration-version: 1.0.0 version: 1.4.0 -description: oSparc Python Runner contact: anderegg@itis.swiss authors: - name: Sylvain Anderegg From 17328376e52445aeeef63b9181c629713a753311 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:07:23 +0200 Subject: [PATCH 2/6] raised patch version --- .cookiecutterrc | 2 +- VERSION | 2 +- metadata/metadata.yml | 2 +- versioning/service.cfg | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.cookiecutterrc b/.cookiecutterrc index 769883d..4b06a71 100644 --- a/.cookiecutterrc +++ b/.cookiecutterrc @@ -35,4 +35,4 @@ default_context: project_slug: 'osparc-python-runner' project_type: 'computational' release_date: '2020' - version: '1.4.0' + version: '1.4.1' diff --git a/VERSION b/VERSION index 88c5fb8..347f583 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.0 +1.4.1 diff --git a/metadata/metadata.yml b/metadata/metadata.yml index c441f88..994ffe6 100644 --- a/metadata/metadata.yml +++ b/metadata/metadata.yml @@ -5,7 +5,7 @@ thumbnail: https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/main/app/t key: simcore/services/comp/osparc-python-runner type: computational integration-version: 1.0.0 -version: 1.4.0 +version: 1.4.1 contact: anderegg@itis.swiss authors: - name: Sylvain Anderegg diff --git a/versioning/service.cfg b/versioning/service.cfg index 44754b8..2696cf4 100644 --- a/versioning/service.cfg +++ b/versioning/service.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.4.0 +current_version = 1.4.1 commit = False message = service/kernel version: {current_version} → {new_version} tag = False From a0aed8814aee609d9168402577a44ddecdf980f6 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:16:31 +0200 Subject: [PATCH 3/6] fixed failing tests --- docker-compose-meta.yml | 2 +- service.cli/run | 1 + tests/integration/test_docker_image.py | 41 ++++++++++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/docker-compose-meta.yml b/docker-compose-meta.yml index 809b686..eaa2143 100644 --- a/docker-compose-meta.yml +++ b/docker-compose-meta.yml @@ -34,7 +34,7 @@ services: under OUTPUT_FOLDER/output_4 as output_4.zip", "type": "data:*/*", "fileToKeyMap": {"output_4.zip": "output_4"}}}}' io.simcore.type: '{"type": "computational"}' - io.simcore.version: '{"version": "1.4.0"}' + io.simcore.version: '{"version": "1.4.1"}' org.label-schema.build-date: ${BUILD_DATE} org.label-schema.schema-version: '1.0' org.label-schema.vcs-ref: ${VCS_REF} diff --git a/service.cli/run b/service.cli/run index 2810032..da63b94 100755 --- a/service.cli/run +++ b/service.cli/run @@ -1,3 +1,4 @@ + #!/bin/sh #--------------------------------------------------------------- # AUTO-GENERATED CODE, do not modify this will be overwritten!!! diff --git a/tests/integration/test_docker_image.py b/tests/integration/test_docker_image.py index 3ba272f..ca31db7 100644 --- a/tests/integration/test_docker_image.py +++ b/tests/integration/test_docker_image.py @@ -18,7 +18,7 @@ # HELPERS def _download_url(url: str, file: Path): # Download the file from `url` and save it locally under `file_name`: - with urllib.request.urlopen(url) as response, file.open('wb') as out_file: + with urllib.request.urlopen(url) as response, file.open("wb") as out_file: shutil.copyfileobj(response, out_file) assert file.exists() @@ -36,6 +36,20 @@ def _convert_to_simcore_labels(image_labels: Dict) -> Dict: assert len(io_simcore_labels) > 0 return io_simcore_labels + +def _is_url(value: str) -> bool: + """Check if the value is a URL.""" + return isinstance(value, str) and ( + value.startswith("http://") or value.startswith("https://") + ) + + +def _fetch_url_content(url: str) -> str: + """Fetch content from a URL.""" + with urllib.request.urlopen(url) as response: + return response.read().decode("utf-8").strip() + + # FIXTURES @pytest.fixture def osparc_service_labels_jsonschema(tmp_path) -> Dict: @@ -47,34 +61,43 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict: return json_schema -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def metadata_labels(metadata_file: Path) -> Dict: with metadata_file.open() as fp: metadata = yaml.safe_load(fp) return metadata + # TESTS -def test_docker_io_simcore_labels_against_files(docker_image: docker.models.images.Image, metadata_labels: Dict): +def test_docker_io_simcore_labels_against_files( + docker_image: docker.models.images.Image, metadata_labels: Dict +): image_labels = docker_image.labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # check files are identical for key, value in io_simcore_labels.items(): assert key in metadata_labels - assert value == metadata_labels[key] + if key == "description": + assert _is_url(metadata_labels[key]) + assert value == _fetch_url_content(metadata_labels[key]) + else: + assert value == metadata_labels[key] -def test_validate_docker_io_simcore_labels(docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict): +def test_validate_docker_io_simcore_labels( + docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict +): image_labels = docker_image.labels # get io labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # validate schema try: - jsonschema.validate(io_simcore_labels, - osparc_service_labels_jsonschema) + jsonschema.validate(io_simcore_labels, osparc_service_labels_jsonschema) except jsonschema.SchemaError: - pytest.fail("Schema {} contains errors".format( - osparc_service_labels_jsonschema)) + pytest.fail( + "Schema {} contains errors".format(osparc_service_labels_jsonschema) + ) except jsonschema.ValidationError: pytest.fail("Failed to validate docker image io labels against schema") From 97d3fbd9205d74a806bf3676da249e3fc1f2a07b Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:19:28 +0200 Subject: [PATCH 4/6] revert --- tests/integration/test_docker_image.py | 41 ++++++-------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/tests/integration/test_docker_image.py b/tests/integration/test_docker_image.py index ca31db7..3ba272f 100644 --- a/tests/integration/test_docker_image.py +++ b/tests/integration/test_docker_image.py @@ -18,7 +18,7 @@ # HELPERS def _download_url(url: str, file: Path): # Download the file from `url` and save it locally under `file_name`: - with urllib.request.urlopen(url) as response, file.open("wb") as out_file: + with urllib.request.urlopen(url) as response, file.open('wb') as out_file: shutil.copyfileobj(response, out_file) assert file.exists() @@ -36,20 +36,6 @@ def _convert_to_simcore_labels(image_labels: Dict) -> Dict: assert len(io_simcore_labels) > 0 return io_simcore_labels - -def _is_url(value: str) -> bool: - """Check if the value is a URL.""" - return isinstance(value, str) and ( - value.startswith("http://") or value.startswith("https://") - ) - - -def _fetch_url_content(url: str) -> str: - """Fetch content from a URL.""" - with urllib.request.urlopen(url) as response: - return response.read().decode("utf-8").strip() - - # FIXTURES @pytest.fixture def osparc_service_labels_jsonschema(tmp_path) -> Dict: @@ -61,43 +47,34 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict: return json_schema -@pytest.fixture(scope="session") +@pytest.fixture(scope='session') def metadata_labels(metadata_file: Path) -> Dict: with metadata_file.open() as fp: metadata = yaml.safe_load(fp) return metadata - # TESTS -def test_docker_io_simcore_labels_against_files( - docker_image: docker.models.images.Image, metadata_labels: Dict -): +def test_docker_io_simcore_labels_against_files(docker_image: docker.models.images.Image, metadata_labels: Dict): image_labels = docker_image.labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # check files are identical for key, value in io_simcore_labels.items(): assert key in metadata_labels - if key == "description": - assert _is_url(metadata_labels[key]) - assert value == _fetch_url_content(metadata_labels[key]) - else: - assert value == metadata_labels[key] + assert value == metadata_labels[key] -def test_validate_docker_io_simcore_labels( - docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict -): +def test_validate_docker_io_simcore_labels(docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict): image_labels = docker_image.labels # get io labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # validate schema try: - jsonschema.validate(io_simcore_labels, osparc_service_labels_jsonschema) + jsonschema.validate(io_simcore_labels, + osparc_service_labels_jsonschema) except jsonschema.SchemaError: - pytest.fail( - "Schema {} contains errors".format(osparc_service_labels_jsonschema) - ) + pytest.fail("Schema {} contains errors".format( + osparc_service_labels_jsonschema)) except jsonschema.ValidationError: pytest.fail("Failed to validate docker image io labels against schema") From b5e4cc0a6cc72d099fc19c3bf02f549922e02637 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:40:52 +0200 Subject: [PATCH 5/6] fixing test --- tests/integration/test_docker_image.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_docker_image.py b/tests/integration/test_docker_image.py index 3ba272f..42ab08c 100644 --- a/tests/integration/test_docker_image.py +++ b/tests/integration/test_docker_image.py @@ -3,6 +3,7 @@ # pylint:disable=redefined-outer-name import json +from copy import deepcopy import shutil import urllib.request from pathlib import Path @@ -18,7 +19,7 @@ # HELPERS def _download_url(url: str, file: Path): # Download the file from `url` and save it locally under `file_name`: - with urllib.request.urlopen(url) as response, file.open('wb') as out_file: + with urllib.request.urlopen(url) as response, file.open("wb") as out_file: shutil.copyfileobj(response, out_file) assert file.exists() @@ -36,6 +37,7 @@ def _convert_to_simcore_labels(image_labels: Dict) -> Dict: assert len(io_simcore_labels) > 0 return io_simcore_labels + # FIXTURES @pytest.fixture def osparc_service_labels_jsonschema(tmp_path) -> Dict: @@ -44,19 +46,23 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict: _download_url(url, file_name) with file_name.open() as fp: json_schema = json.load(fp) + json_schema["properties"]["icon"] = deepcopy(json_schema["properties"]["thumbnail"]) return json_schema -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def metadata_labels(metadata_file: Path) -> Dict: with metadata_file.open() as fp: metadata = yaml.safe_load(fp) return metadata + # TESTS -def test_docker_io_simcore_labels_against_files(docker_image: docker.models.images.Image, metadata_labels: Dict): +def test_docker_io_simcore_labels_against_files( + docker_image: docker.models.images.Image, metadata_labels: Dict +): image_labels = docker_image.labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # check files are identical @@ -65,16 +71,18 @@ def test_docker_io_simcore_labels_against_files(docker_image: docker.models.imag assert value == metadata_labels[key] -def test_validate_docker_io_simcore_labels(docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict): +def test_validate_docker_io_simcore_labels( + docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict +): image_labels = docker_image.labels # get io labels io_simcore_labels = _convert_to_simcore_labels(image_labels) # validate schema try: - jsonschema.validate(io_simcore_labels, - osparc_service_labels_jsonschema) + jsonschema.validate(io_simcore_labels, osparc_service_labels_jsonschema) except jsonschema.SchemaError: - pytest.fail("Schema {} contains errors".format( - osparc_service_labels_jsonschema)) + pytest.fail( + "Schema {} contains errors".format(osparc_service_labels_jsonschema) + ) except jsonschema.ValidationError: pytest.fail("Failed to validate docker image io labels against schema") From b137e7b79a0a62197bbdeb9bf2c923f4987ded7f Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Wed, 21 May 2025 13:44:59 +0200 Subject: [PATCH 6/6] add comment for change --- tests/integration/test_docker_image.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test_docker_image.py b/tests/integration/test_docker_image.py index 42ab08c..a5ef691 100644 --- a/tests/integration/test_docker_image.py +++ b/tests/integration/test_docker_image.py @@ -46,6 +46,8 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict: _download_url(url, file_name) with file_name.open() as fp: json_schema = json.load(fp) + # artifically add to legacy scheme new icon field which is optional + # NOTE: a prpoer fix is to migrate this repository to using ooil json_schema["properties"]["icon"] = deepcopy(json_schema["properties"]["thumbnail"]) return json_schema