From 5f6aabb498a783088c4627b24096b100ded3caeb Mon Sep 17 00:00:00 2001 From: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:24:47 +0100 Subject: [PATCH] Use the more concise 'Entities Service' name throughout (#70) Remove mention of the service pertaining only to DLite. Remove SOFT mention where not applicable Rename package folder. Rename 'entity_service_' -> 'entities_service_'. This is the environment variable prefix for setting configurations. Rename all cases 'CasperWA' -> 'SINTEF' where applicable. --- .github/workflows/cd_onto-ns.yml | 4 +-- .github/workflows/ci_cd_updated_main.yml | 2 +- .github/workflows/ci_tests.yml | 28 ++++++++-------- Dockerfile | 8 ++--- README.md | 32 +++++++++---------- docker-compose.yml | 22 ++++++------- docs/example/dlite_example.ipynb | 4 +-- .../__init__.py | 2 +- .../cli/__init__.py | 2 +- .../cli/_utils/__init__.py | 0 .../cli/_utils/generics.py | 6 ++-- .../cli/_utils/global_settings.py | 10 +++--- .../cli/config.py | 10 +++--- .../cli/main.py | 24 +++++++------- .../main.py | 16 +++++----- .../models/__init__.py | 0 .../models/soft5.py | 7 ++-- .../models/soft7.py | 7 ++-- .../service/__init__.py | 0 .../service/backend.py | 4 +-- .../service/config.py | 2 +- .../service/exceptions.py | 0 .../service/logger.py | 6 ++-- .../uvicorn.py | 2 +- pyproject.toml | 23 +++++++------ tests/cli/_utils/test_global_settings.py | 6 ++-- tests/cli/conftest.py | 16 +++++----- tests/cli/test_config.py | 18 +++++------ tests/cli/test_upload.py | 32 +++++++++---------- tests/conftest.py | 20 ++++++------ tests/models/test_init.py | 20 ++++++------ tests/static/invalid_entities/README.md | 8 ++--- tests/test_route.py | 4 +-- tests/utils.py | 2 +- 34 files changed, 172 insertions(+), 175 deletions(-) rename {dlite_entities_service => entities_service}/__init__.py (76%) rename {dlite_entities_service => entities_service}/cli/__init__.py (61%) rename {dlite_entities_service => entities_service}/cli/_utils/__init__.py (100%) rename {dlite_entities_service => entities_service}/cli/_utils/generics.py (87%) rename {dlite_entities_service => entities_service}/cli/_utils/global_settings.py (84%) rename {dlite_entities_service => entities_service}/cli/config.py (94%) rename {dlite_entities_service => entities_service}/cli/main.py (94%) rename {dlite_entities_service => entities_service}/main.py (86%) rename {dlite_entities_service => entities_service}/models/__init__.py (100%) rename {dlite_entities_service => entities_service}/models/soft5.py (96%) rename {dlite_entities_service => entities_service}/models/soft7.py (96%) rename {dlite_entities_service => entities_service}/service/__init__.py (100%) rename {dlite_entities_service => entities_service}/service/backend.py (90%) rename {dlite_entities_service => entities_service}/service/config.py (95%) rename {dlite_entities_service => entities_service}/service/exceptions.py (100%) rename {dlite_entities_service => entities_service}/service/logger.py (90%) rename {dlite_entities_service => entities_service}/uvicorn.py (89%) diff --git a/.github/workflows/cd_onto-ns.yml b/.github/workflows/cd_onto-ns.yml index bc32b27..a96f61a 100644 --- a/.github/workflows/cd_onto-ns.yml +++ b/.github/workflows/cd_onto-ns.yml @@ -27,7 +27,7 @@ jobs: - name: Deploy updated main run: | - curl -o response.json --silent -m 30 http://api.onto-ns.com/dlite/?service=dlite-entities-service + curl -o response.json --silent -m 30 http://api.onto-ns.com/deploy?service=entities-service cat << EOF | python import json @@ -35,7 +35,7 @@ jobs: import sys response = json.loads(Path('response.json').read_bytes()) - if response["service"] != "dlite-entities-service": + if response["service"] != "entities-service": sys.exit( "ERROR: Did not deploy the correct service\n" f" service: {response['service']}\n" diff --git a/.github/workflows/ci_cd_updated_main.yml b/.github/workflows/ci_cd_updated_main.yml index b368c74..6c9822e 100644 --- a/.github/workflows/ci_cd_updated_main.yml +++ b/.github/workflows/ci_cd_updated_main.yml @@ -22,7 +22,7 @@ jobs: update_docs: false # update_python_api_ref: true # update_docs_landing_page: true - # package_dirs: dlite_entities_service + # package_dirs: entities_service # python_version: "3.10" # doc_extras: "[doc]" # changelog_exclude_labels: "skip_changelog,duplicate,question,invalid,wontfix" diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index f4ea945..bc74162 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -49,11 +49,11 @@ jobs: MONGO_INITDB_ROOT_PASSWORD: root env: - ENTITY_SERVICE_MONGO_URI: mongodb://localhost:27017 - ENTITY_SERVICE_MONGO_USER: root - ENTITY_SERVICE_MONGO_PASSWORD: root - ENTITY_SERVICE_HOST: localhost - ENTITY_SERVICE_PORT: 8000 + ENTITIES_SERVICE_MONGO_URI: mongodb://localhost:27017 + ENTITIES_SERVICE_MONGO_USER: root + ENTITIES_SERVICE_MONGO_PASSWORD: root + ENTITIES_SERVICE_HOST: localhost + ENTITIES_SERVICE_PORT: 8000 steps: - name: Checkout ${{ github.repository }} @@ -68,22 +68,22 @@ jobs: run: | docker build \ --pull \ - --tag entity-service \ + --tag entities-service \ --target ${{ matrix.docker_target }} \ . - name: Run Docker container run: | docker run --rm -d \ - --env ENTITY_SERVICE_MONGO_URI \ - --env ENTITY_SERVICE_MONGO_USER \ - --env ENTITY_SERVICE_MONGO_PASSWORD \ - --env PORT=${ENTITY_SERVICE_PORT} \ - --name "entity-service" \ + --env ENTITIES_SERVICE_MONGO_URI \ + --env ENTITIES_SERVICE_MONGO_USER \ + --env ENTITIES_SERVICE_MONGO_PASSWORD \ + --env PORT=${ENTITIES_SERVICE_PORT} \ + --name "entities-service" \ --network "host" \ --volume "${PWD}:/app" \ --user "$(id -u):$(id -g)" \ - entity-service + entities-service sleep 5 - name: Install test dependencies @@ -98,10 +98,10 @@ jobs: pytest -vv --live-backend --cov-report=xml } || { echo "Failed! Here's the Docker logs for the service:" && - docker logs entity-service && + docker logs entities-service && echo -e "\nAnd the service log:" && - cat logs/dlite_entities_service.log && + cat logs/entities_service.log && exit 1 } diff --git a/Dockerfile b/Dockerfile index e264bf8..60e5e73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.10-slim as base WORKDIR /app -COPY dlite_entities_service dlite_entities_service/ +COPY entities_service entities_service/ COPY pyproject.toml LICENSE README.md ./ # Install dependencies @@ -12,14 +12,14 @@ RUN python -m pip install -U pip && \ pip install -U -e . && \ # Create log directory and file (if not existing already) mkdir -p logs && \ - touch -a logs/dlite_entities_service.log + touch -a logs/entities_service.log FROM base as development ENV PORT=80 EXPOSE ${PORT} -ENTRYPOINT uvicorn --host 0.0.0.0 --port ${PORT} --log-level debug --no-server-header --header "Server:DLiteEntitiesService" --reload dlite_entities_service.main:APP +ENTRYPOINT uvicorn --host 0.0.0.0 --port ${PORT} --log-level debug --no-server-header --header "Server:EntitiesService" --reload entities_service.main:APP FROM base as production @@ -28,4 +28,4 @@ RUN pip install gunicorn ENV PORT=80 EXPOSE ${PORT} -ENTRYPOINT gunicorn --bind "0.0.0.0:${PORT}" --workers 1 --worker-class dlite_entities_service.uvicorn.UvicornWorker dlite_entities_service.main:APP +ENTRYPOINT gunicorn --bind "0.0.0.0:${PORT}" --workers 1 --worker-class entities_service.uvicorn.UvicornWorker entities_service.main:APP diff --git a/README.md b/README.md index e1e0cb8..a59229f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Service for serving DLite entities +# Service for serving entities This is a FastAPI-based REST API service running on onto-ns.com. -It's purpose is to serve DLite entities from an underlying database. +It's purpose is to serve entities from an underlying database. ## Run the service @@ -9,8 +9,8 @@ First, download and install the Python package from GitHub: ```shell # Download (git clone) -git clone https://github.com/CasperWA/dlite-entities-service.git -cd dlite-entities-service +git clone https://github.com/SINTEF/entities-service.git +cd entities-service # Install (using pip) python -m pip install -U pip @@ -25,24 +25,24 @@ For development, start a local MongoDB server, e.g., through another Docker imag docker run -d --name "mongodb" -p "27017:27017" mongo:6 ``` -Then build and run the DLite Entities Service Docker image: +Then build and run the Entities Service Docker image: ```shell -docker build --pull -t entity-service --target development . +docker build --pull -t entities-service --target development . docker run --rm -d \ - --env "entity_service_mongo_uri=mongodb://localhost:27017" \ - --name "entity-service" \ + --env "entities_service_mongo_uri=mongodb://localhost:27017" \ + --name "entities-service" \ -p "8000:80" \ - entity-service + entities-service ``` -Now, fill up the MongoDB with valid DLite entities at the `dlite` database in the `entities` collection. +Now, fill up the MongoDB with valid entities at the `entities_service` database in the `entities` collection. -Then go to [localhost:8000/docs](http://localhost:8000/docs) and try out retrieving a DLite entity. +Then go to [localhost:8000/docs](http://localhost:8000/docs) and try out retrieving an entity. --- -For production, use a public MongoDB, and follow the same instructions above for building and running the DLite Entities Service Docker image, but exchange the `--target` value with `production`, put in the proper value for the `entity_service_mongo_uri` environment value, possibly add the `entity_service_mongo_user` and `entity_service_mongo_password` environment variables as well, if needed. +For production, use a public MongoDB, and follow the same instructions above for building and running the Entities Service Docker image, but exchange the `--target` value with `production`, put in the proper value for the `entities_service_mongo_uri` environment value, possibly add the `entities_service_mongo_user` and `entities_service_mongo_password` environment variables as well, if needed. ### Using Docker Compose @@ -53,10 +53,10 @@ docker compose pull docker compose up --build ``` -By default the `development` target will be built, to change this, set the `entity_service_docker_target` environment variable accordingly, e.g.: +By default the `development` target will be built, to change this, set the `entities_service_docker_target` environment variable accordingly, e.g.: ```shell -entity_service_docker_target=production docker compose up --build +entities_service_docker_target=production docker compose up --build ``` Furthermore, the used `localhost` port can be changed via the `PORT` environment variable. @@ -75,10 +75,10 @@ Then run it according to your desires. For example, in development, it might be nice to have the server reload if any files are changed, as well as the server logging debug messages: ```shell -uvicorn dlite_entities_service.main:APP --reload --host localhost --port 8000 --log-level debug --debug --no-server-header --header "Server:DLiteEntitiesService" +uvicorn entities_service.main:APP --reload --host localhost --port 8000 --log-level debug --debug --no-server-header --header "Server:EntitiesService" ``` -Then go to [localhost:8000/docs](http://localhost:8000/docs) and try out retrieving a DLite entity. +Then go to [localhost:8000/docs](http://localhost:8000/docs) and try out retrieving an entity. ### Using a file for environment variables diff --git a/docker-compose.yml b/docker-compose.yml index cedc495..88b648d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,22 @@ version: "3" services: - dlite_entities_service: + entities_service: build: context: "." - target: "${ENTITY_SERVICE_DOCKER_TARGET:-development}" + target: "${ENTITIES_SERVICE_DOCKER_TARGET:-development}" ports: - - "${ENTITY_SERVICE_PORT:-8000}:80" + - "${ENTITIES_SERVICE_PORT:-8000}:80" environment: - PORT: ${ENTITY_SERVICE_PORT:-8000} - ENTITY_SERVICE_BASE_URL: "${ENTITY_SERVICE_HOST:-http://onto-ns.com/meta}" - ENTITY_SERVICE_MONGO_URI: "mongodb://mongodb:27017" - ENTITY_SERVICE_MONGO_USER: ${MONGO_USER:-root} - ENTITY_SERVICE_MONGO_PASSWORD: ${MONGO_PASSWORD:-root} + PORT: ${ENTITIES_SERVICE_PORT:-8000} + ENTITIES_SERVICE_BASE_URL: "${ENTITIES_SERVICE_HOST:-http://onto-ns.com/meta}" + ENTITIES_SERVICE_MONGO_URI: "mongodb://mongodb:27017" + ENTITIES_SERVICE_MONGO_USER: ${MONGO_USER:-root} + ENTITIES_SERVICE_MONGO_PASSWORD: ${MONGO_PASSWORD:-root} depends_on: - mongodb networks: - - dlite_entities_net + - entities_service_net volumes: - "${PWD}:/app" @@ -29,7 +29,7 @@ services: MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER:-root} MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-root} networks: - - dlite_entities_net + - entities_service_net networks: - dlite_entities_net: + entities_service_net: diff --git a/docs/example/dlite_example.ipynb b/docs/example/dlite_example.ipynb index 94293c3..8a7282f 100644 --- a/docs/example/dlite_example.ipynb +++ b/docs/example/dlite_example.ipynb @@ -10,10 +10,10 @@ "It is expected that one has the following:\n", "\n", "- Installed:\n", - " - Local `dlite_entities_service` package.\n", + " - Local `entities_service` package.\n", " - `requests`\n", " - `DLite-Python`\n", - "- Running DLite Entities service at `http://localhost:8000` setup to connect to SOFT Cluster on MongoDB Atlas." + "- Running Entities Service at `http://localhost:8000` setup to connect to SOFT Cluster on MongoDB Atlas." ] }, { diff --git a/dlite_entities_service/__init__.py b/entities_service/__init__.py similarity index 76% rename from dlite_entities_service/__init__.py rename to entities_service/__init__.py index 6381fdf..d6c466e 100644 --- a/dlite_entities_service/__init__.py +++ b/entities_service/__init__.py @@ -1,4 +1,4 @@ -"""DLite entities service.""" +"""Entities Service.""" from __future__ import annotations __version__ = "0.0.1" diff --git a/dlite_entities_service/cli/__init__.py b/entities_service/cli/__init__.py similarity index 61% rename from dlite_entities_service/cli/__init__.py rename to entities_service/cli/__init__.py index de7dcfd..8e7b0ea 100644 --- a/dlite_entities_service/cli/__init__.py +++ b/entities_service/cli/__init__.py @@ -1,5 +1,5 @@ """Utility CLI This module contains a CLI with utilities that may be useful when dealing with the -DLite entities service, it's data (backend), and possibly more. +Entities Service, it's data (backend), and possibly more. """ diff --git a/dlite_entities_service/cli/_utils/__init__.py b/entities_service/cli/_utils/__init__.py similarity index 100% rename from dlite_entities_service/cli/_utils/__init__.py rename to entities_service/cli/_utils/__init__.py diff --git a/dlite_entities_service/cli/_utils/generics.py b/entities_service/cli/_utils/generics.py similarity index 87% rename from dlite_entities_service/cli/_utils/generics.py rename to entities_service/cli/_utils/generics.py index d95858f..0afe661 100644 --- a/dlite_entities_service/cli/_utils/generics.py +++ b/entities_service/cli/_utils/generics.py @@ -11,7 +11,7 @@ from rich import print as rich_print except ImportError as exc: # pragma: no cover raise ImportError( - "Please install the DLite entities service utility CLI with 'pip install " + "Please install the entities service utility CLI with 'pip install " f"{Path(__file__).resolve().parent.parent.parent.parent.resolve()}[cli]'" ) from exc @@ -22,9 +22,9 @@ EXC_MSG_INSTALL_PACKAGE = ( - "Please install the DLite entities service utility CLI with " + "Please install the entities service utility CLI with " f"'pip install {Path(__file__).resolve().parent.parent.parent.parent.resolve()}" - "[cli]' or 'pip install dlite-entities-service[cli]'" + "[cli]' or 'pip install entities-service[cli]'" ) OUTPUT_CONSOLE = get_console() diff --git a/dlite_entities_service/cli/_utils/global_settings.py b/entities_service/cli/_utils/global_settings.py similarity index 84% rename from dlite_entities_service/cli/_utils/global_settings.py rename to entities_service/cli/_utils/global_settings.py index d431506..417a21f 100644 --- a/dlite_entities_service/cli/_utils/global_settings.py +++ b/entities_service/cli/_utils/global_settings.py @@ -8,13 +8,13 @@ import typer except ImportError as exc: # pragma: no cover raise ImportError( - "Please install the DLite entities service utility CLI with 'pip install " + "Please install the entities service utility CLI with 'pip install " f"{Path(__file__).resolve().parent.parent.parent.parent.resolve()}[cli]'" ) from exc -from dlite_entities_service import __version__ -from dlite_entities_service.cli._utils.generics import print -from dlite_entities_service.service.config import CONFIG +from entities_service import __version__ +from entities_service.cli._utils.generics import print +from entities_service.service.config import CONFIG if TYPE_CHECKING: # pragma: no cover from typing import TypedDict @@ -38,7 +38,7 @@ class ContextDict(TypedDict): def print_version(value: bool) -> None: """Print version and exit.""" if value: - print(f"dlite-entities-service version: {__version__}") + print(f"entities-service version: {__version__}") raise typer.Exit() diff --git a/dlite_entities_service/cli/config.py b/entities_service/cli/config.py similarity index 94% rename from dlite_entities_service/cli/config.py rename to entities_service/cli/config.py index d35e52e..0b162d2 100644 --- a/dlite_entities_service/cli/config.py +++ b/entities_service/cli/config.py @@ -1,4 +1,4 @@ -"""config subcommand for dlite-entities-service CLI.""" +"""config subcommand for entities-service CLI.""" from __future__ import annotations import sys @@ -17,15 +17,15 @@ class StrEnum(str, Enum): try: import typer except ImportError as exc: # pragma: no cover - from dlite_entities_service.cli._utils.generics import EXC_MSG_INSTALL_PACKAGE + from entities_service.cli._utils.generics import EXC_MSG_INSTALL_PACKAGE raise ImportError(EXC_MSG_INSTALL_PACKAGE) from exc from dotenv import dotenv_values, set_key, unset_key -from dlite_entities_service.cli._utils.generics import ERROR_CONSOLE, print -from dlite_entities_service.cli._utils.global_settings import CONTEXT -from dlite_entities_service.service.config import CONFIG +from entities_service.cli._utils.generics import ERROR_CONSOLE, print +from entities_service.cli._utils.global_settings import CONTEXT +from entities_service.service.config import CONFIG APP = typer.Typer( name=__file__.rsplit("/", 1)[-1].replace(".py", ""), diff --git a/dlite_entities_service/cli/main.py b/entities_service/cli/main.py similarity index 94% rename from dlite_entities_service/cli/main.py rename to entities_service/cli/main.py index 36538ea..f04e61f 100644 --- a/dlite_entities_service/cli/main.py +++ b/entities_service/cli/main.py @@ -1,4 +1,4 @@ -"""Typer CLI for doing SOFT entities service stuff.""" +"""Typer CLI for doing Entities Service stuff.""" from __future__ import annotations import json @@ -20,7 +20,7 @@ class StrEnum(str, Enum): try: import typer except ImportError as exc: # pragma: no cover - from dlite_entities_service.cli._utils.generics import EXC_MSG_INSTALL_PACKAGE + from entities_service.cli._utils.generics import EXC_MSG_INSTALL_PACKAGE raise ImportError(EXC_MSG_INSTALL_PACKAGE) from exc @@ -29,21 +29,21 @@ class StrEnum(str, Enum): from dotenv import dotenv_values from pydantic import AnyHttpUrl -from dlite_entities_service.cli._utils.generics import ( +from entities_service.cli._utils.generics import ( ERROR_CONSOLE, pretty_compare_dicts, print, ) -from dlite_entities_service.cli._utils.global_settings import CONTEXT, global_options -from dlite_entities_service.cli.config import APP as config_APP -from dlite_entities_service.models import ( +from entities_service.cli._utils.global_settings import CONTEXT, global_options +from entities_service.cli.config import APP as config_APP +from entities_service.models import ( URI_REGEX, get_updated_version, get_uri, get_version, soft_entity, ) -from dlite_entities_service.service.exceptions import BackendError +from entities_service.service.exceptions import BackendError if TYPE_CHECKING: # pragma: no cover from typing import Any @@ -68,7 +68,7 @@ class EntityFileFormats(StrEnum): APP = typer.Typer( name="entities-service", - help="SOFT entities service utility CLI", + help="Entities Service utility CLI", no_args_is_help=True, pretty_exceptions_show_locals=False, callback=global_options, @@ -78,7 +78,7 @@ class EntityFileFormats(StrEnum): def _get_backend() -> Collection: """Return the backend.""" - from dlite_entities_service.service.backend import ( + from entities_service.service.backend import ( ENTITIES_COLLECTION, get_collection, ) @@ -92,9 +92,9 @@ def _get_backend() -> Collection: config = {key.upper(): value for key, value in config.items()} backend_options = { - "uri": config.get("ENTITY_SERVICE_MONGO_URI"), - "username": config.get("ENTITY_SERVICE_MONGO_USER"), - "password": config.get("ENTITY_SERVICE_MONGO_PASSWORD"), + "uri": config.get("ENTITIES_SERVICE_MONGO_URI"), + "username": config.get("ENTITIES_SERVICE_MONGO_USER"), + "password": config.get("ENTITIES_SERVICE_MONGO_PASSWORD"), } if any(_ is not None for _ in backend_options.values()): diff --git a/dlite_entities_service/main.py b/entities_service/main.py similarity index 86% rename from dlite_entities_service/main.py rename to entities_service/main.py index dfcea25..b60b8b4 100644 --- a/dlite_entities_service/main.py +++ b/entities_service/main.py @@ -8,17 +8,17 @@ from fastapi import FastAPI, HTTPException, Path, status -from dlite_entities_service import __version__ -from dlite_entities_service.models import VersionedSOFTEntity -from dlite_entities_service.service.backend import ENTITIES_COLLECTION -from dlite_entities_service.service.config import CONFIG -from dlite_entities_service.service.logger import setup_logger +from entities_service import __version__ +from entities_service.models import VersionedSOFTEntity +from entities_service.service.backend import ENTITIES_COLLECTION +from entities_service.service.config import CONFIG +from entities_service.service.logger import setup_logger if TYPE_CHECKING: # pragma: no cover from typing import Any -LOGGER = logging.getLogger("dlite_entities_service") +LOGGER = logging.getLogger("entities_service") # Application lifespan function @@ -36,7 +36,7 @@ async def lifespan(_: FastAPI): # Setup application APP = FastAPI( - title="DLite Entities Service", + title="Entities Service", version=__version__, description=( sysPath(__file__).resolve().parent.parent.resolve() / "README.md" @@ -86,7 +86,7 @@ async def get_entity( ), ], ) -> dict[str, Any]: - """Get a DLite entity.""" + """Get an entity.""" query = { "$or": [ {"namespace": str(CONFIG.base_url), "version": version, "name": name}, diff --git a/dlite_entities_service/models/__init__.py b/entities_service/models/__init__.py similarity index 100% rename from dlite_entities_service/models/__init__.py rename to entities_service/models/__init__.py diff --git a/dlite_entities_service/models/soft5.py b/entities_service/models/soft5.py similarity index 96% rename from dlite_entities_service/models/soft5.py rename to entities_service/models/soft5.py index e16407c..7b47848 100644 --- a/dlite_entities_service/models/soft5.py +++ b/entities_service/models/soft5.py @@ -8,7 +8,7 @@ from pydantic import AliasChoices, BaseModel, Field, field_validator, model_validator from pydantic.networks import AnyHttpUrl -from dlite_entities_service.service.config import CONFIG +from entities_service.service.config import CONFIG URI_REGEX = re.compile( r"^(?Phttps?://.+)/(?P\d(?:\.\d+){0,2})/(?P[^/#?]+)$" @@ -118,8 +118,7 @@ def _validate_base_url(cls, value: AnyHttpUrl) -> AnyHttpUrl: """Validate `uri` starts with the current base URL for the service.""" if not str(value).startswith(str(CONFIG.base_url)): error_message = ( - "This service only works with DLite/SOFT entities at " - f"{CONFIG.base_url}.\n" + f"This service only works with entities at {CONFIG.base_url}.\n" ) raise ValueError(error_message) return value @@ -142,7 +141,7 @@ def _only_support_onto_ns(cls, value: AnyHttpUrl) -> AnyHttpUrl: """Validate `meta` only refers to onto-ns.com EntitySchema v0.3.""" if str(value) != "http://onto-ns.com/meta/0.3/EntitySchema": error_message = ( - "This service only works with DLite/SOFT entities using EntitySchema " + "This service only works with entities using EntitySchema " "v0.3 at onto-ns.com as the metadata entity.\n" ) raise ValueError(error_message) diff --git a/dlite_entities_service/models/soft7.py b/entities_service/models/soft7.py similarity index 96% rename from dlite_entities_service/models/soft7.py rename to entities_service/models/soft7.py index 9be221b..2e86198 100644 --- a/dlite_entities_service/models/soft7.py +++ b/entities_service/models/soft7.py @@ -8,7 +8,7 @@ from pydantic import AliasChoices, BaseModel, Field, field_validator, model_validator from pydantic.networks import AnyHttpUrl -from dlite_entities_service.service.config import CONFIG +from entities_service.service.config import CONFIG URI_REGEX = re.compile( r"^(?Phttps?://.+)/(?P\d(?:\.\d+){0,2})/(?P[^/#?]+)$" @@ -115,8 +115,7 @@ def _validate_base_url(cls, value: AnyHttpUrl) -> AnyHttpUrl: service.""" if not str(value).startswith(str(CONFIG.base_url)): error_message = ( - "This service only works with DLite/SOFT entities at " - f"{CONFIG.base_url}.\n" + f"This service only works with entities at {CONFIG.base_url}.\n" ) raise ValueError(error_message) return value @@ -139,7 +138,7 @@ def _only_support_onto_ns(cls, value: AnyHttpUrl) -> AnyHttpUrl: """Validate `meta` only refers to onto-ns.com EntitySchema v0.3.""" if str(value) != "http://onto-ns.com/meta/0.3/EntitySchema": error_message = ( - "This service only works with DLite/SOFT entities using EntitySchema " + "This service only works with entities using EntitySchema " "v0.3 at onto-ns.com as the metadata entity.\n" ) raise ValueError(error_message) diff --git a/dlite_entities_service/service/__init__.py b/entities_service/service/__init__.py similarity index 100% rename from dlite_entities_service/service/__init__.py rename to entities_service/service/__init__.py diff --git a/dlite_entities_service/service/backend.py b/entities_service/service/backend.py similarity index 90% rename from dlite_entities_service/service/backend.py rename to entities_service/service/backend.py index 4a2e80d..2405f2b 100644 --- a/dlite_entities_service/service/backend.py +++ b/entities_service/service/backend.py @@ -5,7 +5,7 @@ from pymongo import MongoClient -from dlite_entities_service.service.config import CONFIG +from entities_service.service.config import CONFIG if TYPE_CHECKING: # pragma: no cover from pymongo.collection import Collection @@ -32,7 +32,7 @@ def get_collection( uri or str(CONFIG.mongo_uri), **client_kwargs, ) - return mongo_client.dlite.entities + return mongo_client.entities_service.entities ENTITIES_COLLECTION = get_collection() diff --git a/dlite_entities_service/service/config.py b/entities_service/service/config.py similarity index 95% rename from dlite_entities_service/service/config.py rename to entities_service/service/config.py index 6294266..e527de0 100644 --- a/dlite_entities_service/service/config.py +++ b/entities_service/service/config.py @@ -42,7 +42,7 @@ def _strip_ending_slashes(cls, value: Any) -> AnyHttpUrl: return AnyHttpUrl(str(value).rstrip("/")) model_config = SettingsConfigDict( - env_prefix="entity_service_", env_file=".env", extra="ignore" + env_prefix="entities_service_", env_file=".env", extra="ignore" ) diff --git a/dlite_entities_service/service/exceptions.py b/entities_service/service/exceptions.py similarity index 100% rename from dlite_entities_service/service/exceptions.py rename to entities_service/service/exceptions.py diff --git a/dlite_entities_service/service/logger.py b/entities_service/service/logger.py similarity index 90% rename from dlite_entities_service/service/logger.py rename to entities_service/service/logger.py index 3260265..b79dd69 100644 --- a/dlite_entities_service/service/logger.py +++ b/entities_service/service/logger.py @@ -20,7 +20,7 @@ def disable_logging(): Usage: ```python - from dlite_entities_service.logger import disable_logging + from entities_service.logger import disable_logging # Do stuff, logging to all handlers. # ... @@ -50,7 +50,7 @@ def _get_service_logger_handlers() -> list[logging.Handler]: # Set handlers file_handler = logging.handlers.RotatingFileHandler( - logs_dir / "dlite_entities_service.log", maxBytes=1000000, backupCount=5 + logs_dir / "entities_service.log", maxBytes=1000000, backupCount=5 ) file_handler.setLevel(logging.DEBUG) @@ -72,7 +72,7 @@ def _get_service_logger_handlers() -> list[logging.Handler]: def setup_logger() -> None: """Return a logger with the given name.""" - logger = logging.getLogger("dlite_entities_service") + logger = logging.getLogger("entities_service") logger.setLevel(logging.DEBUG) for handler in _get_service_logger_handlers(): diff --git a/dlite_entities_service/uvicorn.py b/entities_service/uvicorn.py similarity index 89% rename from dlite_entities_service/uvicorn.py rename to entities_service/uvicorn.py index 38715db..e15628c 100644 --- a/dlite_entities_service/uvicorn.py +++ b/entities_service/uvicorn.py @@ -14,5 +14,5 @@ class UvicornWorker(OriginalUvicornWorker): CONFIG_KWARGS: ClassVar[dict[str, Any]] = { "server_header": False, - "headers": [("Server", "DLiteEntitiesService")], + "headers": [("Server", "EntitiesService")], } diff --git a/pyproject.toml b/pyproject.toml index 6b67d76..c1d589a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ requires = ["flit_core >=3.4,<4"] build-backend = "flit_core.buildapi" [tool.flit.module] -name = "dlite_entities_service" +name = "entities_service" [project] -name = "dlite-entities-service" +name = "entities-service" authors = [ {name = "Casper Welzel Andersen", email = "casper.w.andersen@sintef.no"}, ] @@ -22,7 +22,6 @@ classifiers = [ "Natural Language :: English", "Operating System :: OS Independent", ] -keywords = ["dlite", "mongodb"] requires-python = "~=3.10" dynamic = ["version", "description"] @@ -45,22 +44,22 @@ testing = [ "pytest ~=7.4", "pytest-cov ~=4.1", "pyyaml ~=6.0", - "dlite-entities-service[cli]", + "entities-service[cli]", ] dev = [ "pre-commit ~=3.6", - "dlite-entities-service[testing,cli]", + "entities-service[testing,cli]", ] [project.scripts] -entities-service = "dlite_entities_service.cli.main:APP" +entities-service = "entities_service.cli.main:APP" [project.urls] -Home = "https://github.com/CasperWA/dlite-entities-service" -Documentation = "https://CasperWA.github.io/dlite-entities-service" -Source = "https://github.com/CasperWA/dlite-entities-service" -"Issue Tracker" = "https://github.com/CasperWA/dlite-entities-service/issues" -Changelog = "https://CasperWA.github.io/dlite-entities-service/latest/CHANGELOG" +Home = "https://github.com/SINTEF/entities-service" +Documentation = "https://CasperWA.github.io/entities-service" +Source = "https://github.com/SINTEF/entities-service" +"Issue Tracker" = "https://github.com/SINTEF/entities-service/issues" +Changelog = "https://CasperWA.github.io/entities-service/latest/CHANGELOG" [tool.mypy] python_version = "3.10" @@ -110,7 +109,7 @@ isort.required-imports = ["from __future__ import annotations"] [tool.pytest.ini_options] minversion = "7.4" -addopts = "-rs --cov=dlite_entities_service --cov-report=term-missing:skip-covered --no-cov-on-fail" +addopts = "-rs --cov=entities_service --cov-report=term-missing:skip-covered --no-cov-on-fail" filterwarnings = [ # Treat all warnings as errors "error", diff --git a/tests/cli/_utils/test_global_settings.py b/tests/cli/_utils/test_global_settings.py index 61347de..eed1aa9 100644 --- a/tests/cli/_utils/test_global_settings.py +++ b/tests/cli/_utils/test_global_settings.py @@ -9,11 +9,11 @@ def test_version(cli: CliRunner) -> None: """Test that the version is printed.""" - from dlite_entities_service import __version__ - from dlite_entities_service.cli.main import APP + from entities_service import __version__ + from entities_service.cli.main import APP result = cli.invoke(APP, "--version") assert result.exit_code == 0, result.stderr - assert f"dlite-entities-service version: {__version__}" in result.stdout.replace( + assert f"entities-service version: {__version__}" in result.stdout.replace( "\n", " " ), result.stdout diff --git a/tests/cli/conftest.py b/tests/cli/conftest.py index 668ef6c..03673a4 100644 --- a/tests/cli/conftest.py +++ b/tests/cli/conftest.py @@ -28,11 +28,11 @@ def mock_entities_collection(monkeypatch: pytest.MonkeyPatch) -> Collection: """Return a mock entities collection.""" from mongomock import MongoClient - from dlite_entities_service.service import backend - from dlite_entities_service.service.config import CONFIG + from entities_service.service import backend + from entities_service.service.config import CONFIG mongo_client = MongoClient(str(CONFIG.mongo_uri)) - mock_entities_collection = mongo_client["dlite"]["entities"] + mock_entities_collection = mongo_client["entities_service"]["entities"] monkeypatch.setattr(backend, "ENTITIES_COLLECTION", mock_entities_collection) monkeypatch.setattr( @@ -47,8 +47,8 @@ def mock_entities_collection(monkeypatch: pytest.MonkeyPatch) -> Collection: @pytest.fixture(scope="session") def config_app() -> Typer: """Return the config APP.""" - from dlite_entities_service.cli._utils.global_settings import global_options - from dlite_entities_service.cli.config import APP + from entities_service.cli._utils.global_settings import global_options + from entities_service.cli.config import APP # Add global options to the APP # This is done by the "main" APP, and should hence be done here manually to ensure @@ -61,7 +61,7 @@ def config_app() -> Typer: @pytest.fixture() def dotenv_file(tmp_path: Path) -> Path: """Create a path to a dotenv file in a temporary test folder.""" - from dlite_entities_service.service.config import CONFIG + from entities_service.service.config import CONFIG env_file = CONFIG.model_config["env_file"] @@ -75,8 +75,8 @@ def _prefill_dotenv_config(dotenv_file: Path) -> None: """'Pre'-fill the monkeypatched dotenv config paths.""" from dotenv import set_key - from dlite_entities_service.cli.config import ConfigFields - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.config import ConfigFields + from entities_service.service.config import CONFIG env_prefix = CONFIG.model_config["env_prefix"] diff --git a/tests/cli/test_config.py b/tests/cli/test_config.py index a47c08b..9362d00 100644 --- a/tests/cli/test_config.py +++ b/tests/cli/test_config.py @@ -14,7 +14,7 @@ def test_config(cli: CliRunner) -> None: """Test `entities-service config` CLI command.""" - from dlite_entities_service.cli.config import APP + from entities_service.cli.config import APP result = cli.invoke(APP) assert result.exit_code == 0, result.stderr @@ -31,8 +31,8 @@ def test_set( dotenv_file: Path, ) -> None: """Test `entities-service config set` CLI command.""" - from dlite_entities_service.cli.config import ConfigFields - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.config import ConfigFields + from entities_service.service.config import CONFIG env_prefix = CONFIG.model_config["env_prefix"] @@ -76,8 +76,8 @@ def test_unset( """Test `entities-service config unset` CLI command.""" from dotenv import dotenv_values - from dlite_entities_service.cli.config import ConfigFields - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.config import ConfigFields + from entities_service.service.config import CONFIG env_prefix = CONFIG.model_config["env_prefix"] @@ -146,8 +146,8 @@ def test_show( """Test `entities-service config show` CLI command.""" from dotenv import dotenv_values - from dlite_entities_service.cli.config import ConfigFields - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.config import ConfigFields + from entities_service.service.config import CONFIG assert dotenv_file.exists() assert dotenv_file.read_text() != "", dotenv_file.read_text() @@ -195,8 +195,8 @@ def test_show_file_not_exist( def test_configfields_autocompletion() -> None: """Test the ConfigFields.autocomplete() method.""" - from dlite_entities_service.cli.config import ConfigFields - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.config import ConfigFields + from entities_service.service.config import CONFIG test_values = { "b": ["base_url"], diff --git a/tests/cli/test_upload.py b/tests/cli/test_upload.py index d3907d9..6a22d64 100644 --- a/tests/cli/test_upload.py +++ b/tests/cli/test_upload.py @@ -15,7 +15,7 @@ def test_upload_no_args(cli: CliRunner) -> None: """Test `entities-service upload` CLI command.""" - from dlite_entities_service.cli.main import APP, upload + from entities_service.cli.main import APP, upload result = cli.invoke(APP, "upload") assert result.exit_code == 0, result.stderr @@ -30,7 +30,7 @@ def test_upload_filepath( """Test upload with a filepath.""" import json - from dlite_entities_service.cli import main + from entities_service.cli import main result = cli.invoke( main.APP, f"upload --file {static_dir / 'valid_entities' / 'Person.json'}" @@ -52,7 +52,7 @@ def test_upload_filepath_invalid( cli: CliRunner, static_dir: Path, fail_fast: bool ) -> None: """Test upload with an invalid filepath.""" - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP result = cli.invoke( APP, @@ -78,7 +78,7 @@ def test_upload_filepath_invalid( def test_upload_filepath_invalid_format(cli: CliRunner, tmp_path: Path) -> None: """Test upload with an invalid file format.""" - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP (tmp_path / "Person.txt").touch() @@ -90,7 +90,7 @@ def test_upload_filepath_invalid_format(cli: CliRunner, tmp_path: Path) -> None: def test_upload_no_file_or_dir(cli: CliRunner) -> None: """Test error when no file or directory is provided.""" - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP result = cli.invoke(APP, "upload --format json") assert result.exit_code == 1, result.stdout @@ -104,7 +104,7 @@ def test_upload_directory( """Test upload with a directory.""" import json - from dlite_entities_service.cli import main + from entities_service.cli import main directory = static_dir / "valid_entities" @@ -152,7 +152,7 @@ def test_upload_empty_dir(cli: CliRunner, tmp_path: Path) -> None: The outcome here should be the same whether an empty directory is provided or a directory with only invalid files. """ - from dlite_entities_service.cli import main + from entities_service.cli import main empty_dir = tmp_path / "empty_dir" assert not empty_dir.exists() @@ -174,7 +174,7 @@ def test_upload_empty_dir(cli: CliRunner, tmp_path: Path) -> None: def test_upload_files_with_unchosen_format(cli: CliRunner, static_dir: Path) -> None: """Test upload several files with a format not chosen.""" - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP directory = static_dir / "valid_entities" file_inputs = " ".join( @@ -205,7 +205,7 @@ def test_upload_directory_invalid_entities( """Test uploading a directory full of invalid entities.""" import re - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP directory = static_dir / "invalid_entities" @@ -265,8 +265,8 @@ def test_get_backend( from dotenv import set_key - from dlite_entities_service.cli._utils.global_settings import CONTEXT - from dlite_entities_service.cli.main import APP + from entities_service.cli._utils.global_settings import CONTEXT + from entities_service.cli.main import APP # Create a temporary '.env' file if not dotenv_file.exists(): @@ -274,7 +274,7 @@ def test_get_backend( else: dotenv_file.unlink() dotenv_file.touch() - set_key(dotenv_file, "ENTITY_SERVICE_MONGO_URI", "mongodb://localhost:27017") + set_key(dotenv_file, "ENTITIES_SERVICE_MONGO_URI", "mongodb://localhost:27017") CONTEXT["dotenv_path"] = dotenv_file @@ -297,7 +297,7 @@ def test_existing_entity( cli: CliRunner, static_dir: Path, mock_entities_collection: Collection ) -> None: """Test that an existing entity is not overwritten.""" - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP result = cli.invoke( APP, f"upload --file {static_dir / 'valid_entities' / 'Person.json'}" @@ -330,8 +330,8 @@ def test_existing_entity_different_content( import json from copy import deepcopy - from dlite_entities_service.cli.main import APP - from dlite_entities_service.service.config import CONFIG + from entities_service.cli.main import APP + from entities_service.service.config import CONFIG raw_entity = (static_dir / "valid_entities" / "Person.json").read_text() parsed_entity: dict[str, Any] = json.loads(raw_entity) @@ -469,7 +469,7 @@ def test_existing_entity_errors( import json from copy import deepcopy - from dlite_entities_service.cli.main import APP + from entities_service.cli.main import APP raw_entity = (static_dir / "valid_entities" / "Person.json").read_text() parsed_entity: dict[str, Any] = json.loads(raw_entity) diff --git a/tests/conftest.py b/tests/conftest.py index a9c7bfc..e113261 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,8 +28,8 @@ def live_backend(request: pytest.FixtureRequest) -> bool: import os required_environment_variables = ( - "ENTITY_SERVICE_MONGO_USER", - "ENTITY_SERVICE_MONGO_PASSWORD", + "ENTITIES_SERVICE_MONGO_USER", + "ENTITIES_SERVICE_MONGO_PASSWORD", ) value = request.config.getoption("--live-backend") @@ -76,7 +76,7 @@ def mongo_test_collection(static_dir: Path, live_backend: bool) -> Collection | } if live_backend: - from dlite_entities_service.service.backend import ENTITIES_COLLECTION + from entities_service.service.backend import ENTITIES_COLLECTION # TODO: Handle authentication properly ENTITIES_COLLECTION.insert_many(entities) @@ -86,7 +86,7 @@ def mongo_test_collection(static_dir: Path, live_backend: bool) -> Collection | # else from mongomock import MongoClient - from dlite_entities_service.service.config import CONFIG + from entities_service.service.config import CONFIG client_kwargs = { "username": CONFIG.mongo_user, @@ -100,7 +100,7 @@ def mongo_test_collection(static_dir: Path, live_backend: bool) -> Collection | MOCK_ENTITIES_COLLECTION = MongoClient( str(CONFIG.mongo_uri), **client_kwargs - ).dlite.entities + ).entities_service.entities MOCK_ENTITIES_COLLECTION.insert_many(entities) @@ -114,7 +114,7 @@ def _mock_backend_entities_collection( if mongo_test_collection is None: return - from dlite_entities_service.service import backend + from entities_service.service import backend monkeypatch.setattr(backend, "ENTITIES_COLLECTION", mongo_test_collection) @@ -126,12 +126,12 @@ def client(live_backend: bool) -> TestClient: from fastapi.testclient import TestClient - from dlite_entities_service.main import APP - from dlite_entities_service.service.config import CONFIG + from entities_service.main import APP + from entities_service.service.config import CONFIG if live_backend: - host, port = os.getenv("ENTITY_SERVICE_HOST", "localhost"), os.getenv( - "ENTITY_SERVICE_PORT", "8000" + host, port = os.getenv("ENTITIES_SERVICE_HOST", "localhost"), os.getenv( + "ENTITIES_SERVICE_PORT", "8000" ) return TestClient( diff --git a/tests/models/test_init.py b/tests/models/test_init.py index cff5283..5dc8466 100644 --- a/tests/models/test_init.py +++ b/tests/models/test_init.py @@ -14,9 +14,9 @@ def test_soft_entity(static_dir: Path) -> None: """Test soft_entity function.""" import json - from dlite_entities_service.models import soft_entity - from dlite_entities_service.models.soft5 import SOFT5Entity - from dlite_entities_service.models.soft7 import SOFT7Entity + from entities_service.models import soft_entity + from entities_service.models.soft5 import SOFT5Entity + from entities_service.models.soft7 import SOFT7Entity # Test that the function returns the correct version of the entity soft5_model_file = static_dir / "valid_entities" / "Cat.json" @@ -35,9 +35,9 @@ def test_soft_entity_error(static_dir: Path) -> None: from pydantic import ValidationError - from dlite_entities_service.models import soft_entity - from dlite_entities_service.models.soft5 import SOFT5Entity - from dlite_entities_service.models.soft7 import SOFT7Entity + from entities_service.models import soft_entity + from entities_service.models.soft5 import SOFT5Entity + from entities_service.models.soft7 import SOFT7Entity # Test that the function returns the correct version of the entity invalid_model_file = static_dir / "invalid_entities" / "Cat.json" @@ -66,7 +66,7 @@ def test_get_uri(static_dir: Path) -> None: """Test get_uri function.""" import json - from dlite_entities_service.models import get_uri, soft_entity + from entities_service.models import get_uri, soft_entity # Test that the function returns the correct version of the entity model_file = static_dir / "valid_entities" / "Cat.json" @@ -101,7 +101,7 @@ def test_get_version(static_dir: Path) -> None: """Test get_version function.""" import json - from dlite_entities_service.models import URI_REGEX, get_version, soft_entity + from entities_service.models import URI_REGEX, get_version, soft_entity # Test that the function returns the correct version of the entity based on the URI model_file = static_dir / "valid_entities" / "Cat.json" @@ -156,7 +156,7 @@ def test_get_updated_version( """ import json - from dlite_entities_service.models import get_updated_version, soft_entity + from entities_service.models import get_updated_version, soft_entity model_file = static_dir / "valid_entities" / "Cat.json" model: dict[str, Any] = json.loads(model_file.read_text()) @@ -172,7 +172,7 @@ def test_get_updated_version_errors(static_dir: Path) -> None: """Test get_updated_version function errors as expected.""" import json - from dlite_entities_service.models import get_updated_version, soft_entity + from entities_service.models import get_updated_version, soft_entity model_file = static_dir / "valid_entities" / "Cat.json" model: dict[str, Any] = json.loads(model_file.read_text()) diff --git a/tests/static/invalid_entities/README.md b/tests/static/invalid_entities/README.md index 327e1d4..fe58e59 100644 --- a/tests/static/invalid_entities/README.md +++ b/tests/static/invalid_entities/README.md @@ -81,11 +81,11 @@ Error message from pydantic as of 19.12.2023 (pydantic==2.5.2): ```console 4 validation errors for SOFT7Entity uri - Value error, This service only works with DLite/SOFT entities at http://onto-ns.com/meta. + Value error, This service only works with entities at http://onto-ns.com/meta. [type=value_error, input_value='http://onto-ns.com/0.1/Cat', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/value_error meta - Value error, This service only works with DLite/SOFT entities using EntitySchema v0.3 at onto-ns.com as the metadata entity. + Value error, This service only works with entities using EntitySchema v0.3 at onto-ns.com as the metadata entity. [type=value_error, input_value='http://onto-ns.com/meta/0.4/EntitySchema', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/value_error dimensions @@ -97,11 +97,11 @@ properties 2 validation errors for SOFT5Entity uri - Value error, This service only works with DLite/SOFT entities at http://onto-ns.com/meta. + Value error, This service only works with entities at http://onto-ns.com/meta. [type=value_error, input_value='http://onto-ns.com/0.1/Cat', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/value_error meta - Value error, This service only works with DLite/SOFT entities using EntitySchema v0.3 at onto-ns.com as the metadata entity. + Value error, This service only works with entities using EntitySchema v0.3 at onto-ns.com as the metadata entity. [type=value_error, input_value='http://onto-ns.com/meta/0.4/EntitySchema', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/value_error ``` diff --git a/tests/test_route.py b/tests/test_route.py index d84e9cf..31438f5 100644 --- a/tests/test_route.py +++ b/tests/test_route.py @@ -1,4 +1,4 @@ -"""Test the service's only route to retrieve DLite/SOFT entities.""" +"""Test the service's only route to retrieve entities.""" from __future__ import annotations import sys @@ -25,7 +25,7 @@ def test_get_entity( name: str, client: TestClient, ) -> None: - """Test the route to retrieve a DLite/SOFT entity.""" + """Test the route to retrieve an entity.""" from fastapi import status with client as client: diff --git a/tests/utils.py b/tests/utils.py index 3166817..a50804c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -19,7 +19,7 @@ def get_version_name(uri: str) -> tuple[str, str]: """Return the version and name part of a uri.""" import re - from dlite_entities_service.service.config import CONFIG + from entities_service.service.config import CONFIG namespace = str(CONFIG.base_url).rstrip("/")