diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 6430cdc..b490bb2 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -6,7 +6,7 @@ on: - '*' env: - GCR_IMAGE: ghcr.io/rayemelyanova/diffcalc-api + GCR_IMAGE: ghcr.io/diamondlightsource/diffcalc-api HELM_VERSION: 0.1.0 jobs: diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml index 6ffecdc..cf30b32 100644 --- a/.github/workflows/openapi.yml +++ b/.github/workflows/openapi.yml @@ -28,7 +28,7 @@ jobs: - name: Make openapi.json run: | - python src/diffcalc_API/openapi.py + python src/diffcalc_api/openapi.py - name: Upload uses: actions/upload-artifact@v2 diff --git a/.gitremotes b/.gitremotes index 728fc73..78bb28d 100644 --- a/.gitremotes +++ b/.gitremotes @@ -1 +1 @@ -github git@github.com:dls-controls/diffcalc_API.git +github git@github.com:DiamondLightSource/diffcalc-api.git diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 721132e..d499c29 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -7,15 +7,15 @@ filing a new one. If you have a great idea but it involves big changes, please file a ticket before making a pull request! We want to make sure you don't spend your time coding something that might not fit the scope of the project. -.. _GitHub: https://github.com/dls-controls/diffcalc_API/issues +.. _GitHub: git@github.com:DiamondLightSource/diffcalc-api.git Running the tests ----------------- To get the source source code and run the unit tests, run:: - $ git clone git://github.com/dls-controls/diffcalc_API.git - $ cd diffcalc_API + $ git clone git@github.com:DiamondLightSource/diffcalc-api.git + $ cd diffcalc-api $ pip install -e .[dev] $ pytest @@ -102,7 +102,7 @@ To make a new release, please follow this checklist: - Push to internal gitlab and do a dls-release.py of the tag - Check and edit for clarity the autogenerated GitHub release_ -.. _release: https://github.com/dls-controls/diffcalc_API/releases +.. _release: https://github.com/DiamondLightSource/diffcalc-api/releases Updating the tools ------------------ diff --git a/Dockerfile b/Dockerfile index ac99dc1..ed6e903 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #Install python and copy over repo files FROM python:3.8 -ENV ENV_DIR /diffcalc_API +ENV ENV_DIR /diffcalc_api WORKDIR ${ENV_DIR} COPY . ${ENV_DIR} @@ -11,4 +11,4 @@ RUN pip install . -c requirements.txt #Run the API -CMD ["uvicorn", "src.diffcalc_API.server:app", "--host", "0.0.0.0"] \ No newline at end of file +CMD ["uvicorn", "src.diffcalc_api.server:app", "--host", "0.0.0.0"] \ No newline at end of file diff --git a/README.rst b/README.rst index 8a4da71..7c9223c 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -diffcalc_API +diffcalc-api =========================== |code_ci| |docs_ci| |coverage| |pypi_version| |license| @@ -6,10 +6,9 @@ diffcalc_API An API which exposes the methods in diffcalc-core using FastAPI. ============== ============================================================== -PyPI ``pip install diffcalc_API`` -Source code https://github.com/dls-controls/diffcalc_API -Documentation https://dls-controls.github.io/diffcalc_API -Releases https://github.com/dls-controls/diffcalc_API/releases +Source code https://github.com/DiamondLightSource/diffcalc-api +Documentation https://github.com/DiamondLightSource/diffcalc-api +Releases https://github.com/DiamondLightSource/diffcalc-api/releases ============== ============================================================== This is where you should put some images/code snippets that illustrate @@ -18,31 +17,31 @@ introductory code here: .. code:: python - from diffcalc_API.hello import HelloClass + from diffcalc_api.hello import HelloClass hello = HelloClass("me") print(hello.format_greeting()) Or if it is a commandline tool then you might put some example commands here:: - diffcalc_API person --times=2 + diffcalc_api person --times=2 No other features yet. -.. |code_ci| image:: https://github.com/dls-controls/diffcalc_API/workflows/Code%20CI/badge.svg?branch=master - :target: https://github.com/dls-controls/diffcalc_API/actions?query=workflow%3A%22Code+CI%22 +.. |code_ci| image:: https://github.com/dls-controls/diffcalc_api/workflows/Code%20CI/badge.svg?branch=master + :target: https://github.com/dls-controls/diffcalc_api/actions?query=workflow%3A%22Code+CI%22 :alt: Code CI -.. |docs_ci| image:: https://github.com/dls-controls/diffcalc_API/workflows/Docs%20CI/badge.svg?branch=master - :target: https://github.com/dls-controls/diffcalc_API/actions?query=workflow%3A%22Docs+CI%22 +.. |docs_ci| image:: https://github.com/dls-controls/diffcalc_api/workflows/Docs%20CI/badge.svg?branch=master + :target: https://github.com/dls-controls/diffcalc_api/actions?query=workflow%3A%22Docs+CI%22 :alt: Docs CI -.. |coverage| image:: https://codecov.io/gh/dls-controls/diffcalc_API/branch/master/graph/badge.svg - :target: https://codecov.io/gh/dls-controls/diffcalc_API +.. |coverage| image:: https://codecov.io/gh/dls-controls/diffcalc_api/branch/master/graph/badge.svg + :target: https://codecov.io/gh/dls-controls/diffcalc_api :alt: Test Coverage -.. |pypi_version| image:: https://img.shields.io/pypi/v/diffcalc_API.svg - :target: https://pypi.org/project/diffcalc_API +.. |pypi_version| image:: https://img.shields.io/pypi/v/diffcalc_api.svg + :target: https://pypi.org/project/diffcalc_api :alt: Latest PyPI version .. |license| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg @@ -53,4 +52,4 @@ No other features yet. Anything below this line is used when viewing README.rst and will be replaced when included in index.rst -See https://dls-controls.github.io/diffcalc_API for more detailed documentation. +See https://dls-controls.github.io/diffcalc_api for more detailed documentation. diff --git a/docs/conf.py b/docs/conf.py index ed185cb..23e582a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,15 +4,15 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -import diffcalc_API +import diffcalc_api # -- General configuration ------------------------------------------------ # General information about the project. -project = "diffcalc_API" +project = "diffcalc_api" # The full version, including alpha/beta/rc tags. -release = diffcalc_API.__version__ +release = diffcalc_api.__version__ # The short X.Y version. if "+" in release: diff --git a/docs/explanations/test.rst b/docs/explanations/test.rst index 7e7a3d1..3d20cdc 100644 --- a/docs/explanations/test.rst +++ b/docs/explanations/test.rst @@ -3,7 +3,7 @@ Why is something the way it is Often, reading the code will not explain *why* it is written that way. These explanations should be grouped together in articles here. They might include -history of diffcalc_API, architectural decisions, or the -real world tests that influenced the design of diffcalc_API. +history of diffcalc_api, architectural decisions, or the +real world tests that influenced the design of diffcalc_api. Nothing yet to explain. \ No newline at end of file diff --git a/docs/how-to/test.rst b/docs/how-to/test.rst index d8ff976..a03755e 100644 --- a/docs/how-to/test.rst +++ b/docs/how-to/test.rst @@ -1,7 +1,7 @@ How to accomplish a task ======================== -Here you would explain how to use diffcalc_API to accomplish +Here you would explain how to use diffcalc_api to accomplish a particular task. It doesn't have to be an exhaustive guide like the tutorials, just enough information to show someone who knows what they want to do, how to accomplish that task. diff --git a/docs/reference.rst b/docs/reference.rst index 314a265..74ebb74 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -10,7 +10,7 @@ Practical step-by-step guides for the more experienced user. reference/api reference/contributing - Releases + Releases Index .. diff --git a/docs/reference/api.rst b/docs/reference/api.rst index ed8eea3..5cd3ac2 100644 --- a/docs/reference/api.rst +++ b/docs/reference/api.rst @@ -1,26 +1,26 @@ API === -.. automodule:: diffcalc_API +.. automodule:: diffcalc_api - ``diffcalc_API`` + ``diffcalc_api`` ----------------------------------- -Internal API reference for diffcalc_API +Internal API reference for diffcalc_api Mix verbose text with docstring and signature extraction by using ``autoclass`` and ``autofunction`` directives instead of ``automodule`` below. -.. data:: diffcalc_API.__version__ +.. data:: diffcalc_api.__version__ :type: str Version number as calculated by https://github.com/dls-controls/versiongit -.. .. automodule:: diffcalc_API.hello +.. .. automodule:: diffcalc_api.hello .. :members: -.. ``diffcalc_API.hello`` +.. ``diffcalc_api.hello`` .. ----------------------------------------- No other modules yet. \ No newline at end of file diff --git a/docs/tutorials/installation.rst b/docs/tutorials/installation.rst index 417034b..b906422 100644 --- a/docs/tutorials/installation.rst +++ b/docs/tutorials/installation.rst @@ -35,16 +35,16 @@ Installing the library You can now use ``pip`` to install the library:: - python3 -m pip install diffcalc_API + python3 -m pip install diffcalc_api If you require a feature that is not currently released you can also install from github:: - python3 -m pip install git+git://github.com/dls-controls/diffcalc_API.git + python3 -m pip install git+git://github.com/dls-controls/diffcalc_api.git The library should now be installed and the commandline interface on your path. -You can check diffcalc_API has been correctly installed by typing:: +You can check diffcalc_api has been correctly installed by typing:: - python -c "import diffcalc_API" + python -c "import diffcalc_api" If you observe any output, repeat the steps above and observe the outputs. \ No newline at end of file diff --git a/helm/diffcalc-api/values.yaml b/helm/diffcalc-api/values.yaml index 82aae9d..3403bb1 100644 --- a/helm/diffcalc-api/values.yaml +++ b/helm/diffcalc-api/values.yaml @@ -5,7 +5,7 @@ replicaCount: 1 image: - repository: ghcr.io/rayemelyanova/diffcalc_api + repository: ghcr.io/diamondlightsource/diffcalc-api pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: latest @@ -43,18 +43,20 @@ service: port: 80 ingress: - enabled: false + enabled: true className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - - host: chart-example.local + - host: diffcalc.diamond.ac.uk paths: - path: / pathType: ImplementationSpecific - tls: [] + tls: + - hosts: + - diffcalc.diamond.ac.uk # - secretName: chart-example-tls # hosts: # - chart-example.local diff --git a/setup.cfg b/setup.cfg index bed392a..ab6ff16 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] -name = diffcalc_API +name = diffcalc-api description = API for diffcalc-core python 3 package developed by Irakli Sikharulidze -url = https://github.com/dls-controls/diffcalc_API +url = https://github.com/DiamondLightSource/diffcalc-api author = Rose Yemelyanova author_email = rose.yemelyanova@diamond.ac.uk license = Apache License 2.0 @@ -52,7 +52,7 @@ where = src # Specify any package data to be included in the wheel below. # [options.package_data] -# diffcalc_API = +# diffcalc-api = # subpackage/*.yaml [mypy] @@ -74,7 +74,7 @@ extend-ignore = # Run pytest with all our checkers, and don't spam us with massive tracebacks on error addopts = --tb=native -vv --doctest-modules --doctest-glob="*.rst" - --cov=diffcalc_API --cov-report term --cov-report xml:cov.xml + --cov=diffcalc_api --cov-report term --cov-report xml:cov.xml # https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings # filterwarnings = error #Uncomment later. # Doctest python code in docs, python code in src docstrings, test functions in tests @@ -84,7 +84,7 @@ testpaths = [coverage:run] # This is covered in the versiongit test suite so exclude it here omit = */_version_git.py -data_file = /tmp/diffcalc_API.coverage +data_file = /tmp/diffcalc_api.coverage [coverage:paths] # Tests are run from installed location, map back to the src directory diff --git a/src/diffcalc_API/__init__.py b/src/diffcalc_api/__init__.py similarity index 100% rename from src/diffcalc_API/__init__.py rename to src/diffcalc_api/__init__.py diff --git a/src/diffcalc_API/_version_git.py b/src/diffcalc_api/_version_git.py similarity index 100% rename from src/diffcalc_API/_version_git.py rename to src/diffcalc_api/_version_git.py diff --git a/src/diffcalc_API/config.py b/src/diffcalc_api/config.py similarity index 100% rename from src/diffcalc_API/config.py rename to src/diffcalc_api/config.py diff --git a/src/diffcalc_API/database.py b/src/diffcalc_api/database.py similarity index 88% rename from src/diffcalc_API/database.py rename to src/diffcalc_api/database.py index bd95e7a..9694b87 100644 --- a/src/diffcalc_API/database.py +++ b/src/diffcalc_api/database.py @@ -3,7 +3,7 @@ import motor.motor_asyncio from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase -from diffcalc_API.config import Settings +from diffcalc_api.config import Settings settings = Settings() diff --git a/src/diffcalc_API/errors/__init__.py b/src/diffcalc_api/errors/__init__.py similarity index 66% rename from src/diffcalc_API/errors/__init__.py rename to src/diffcalc_api/errors/__init__.py index c64b1d5..17d25ce 100644 --- a/src/diffcalc_API/errors/__init__.py +++ b/src/diffcalc_api/errors/__init__.py @@ -2,9 +2,9 @@ Defines all errors that can be raised when accessing almost all endpoints. Because some errors arise from persistence retrieval, those are defined in -structures within diffcalc_API.stores instead. +structures within diffcalc_api.stores instead. """ -from diffcalc_API.errors import constraints, hkl, ub +from diffcalc_api.errors import constraints, hkl, ub __all__ = ["hkl", "ub", "constraints"] diff --git a/src/diffcalc_API/errors/constraints.py b/src/diffcalc_api/errors/constraints.py similarity index 89% rename from src/diffcalc_API/errors/constraints.py rename to src/diffcalc_api/errors/constraints.py index b5f6265..f7d017e 100644 --- a/src/diffcalc_API/errors/constraints.py +++ b/src/diffcalc_api/errors/constraints.py @@ -1,8 +1,8 @@ """Errors that can be raised when accessing constraints endpoints.""" import numpy as np -from diffcalc_API.config import ALL_CONSTRAINTS -from diffcalc_API.errors.definitions import ( +from diffcalc_api.config import ALL_CONSTRAINTS +from diffcalc_api.errors.definitions import ( ALL_RESPONSES, DiffcalcAPIException, ErrorCodesBase, diff --git a/src/diffcalc_API/errors/definitions.py b/src/diffcalc_api/errors/definitions.py similarity index 100% rename from src/diffcalc_API/errors/definitions.py rename to src/diffcalc_api/errors/definitions.py diff --git a/src/diffcalc_API/errors/hkl.py b/src/diffcalc_api/errors/hkl.py similarity index 97% rename from src/diffcalc_API/errors/hkl.py rename to src/diffcalc_api/errors/hkl.py index 04f42f0..eba057a 100644 --- a/src/diffcalc_API/errors/hkl.py +++ b/src/diffcalc_api/errors/hkl.py @@ -3,7 +3,7 @@ import numpy as np -from diffcalc_API.errors.definitions import ( +from diffcalc_api.errors.definitions import ( ALL_RESPONSES, DiffcalcAPIException, ErrorCodesBase, diff --git a/src/diffcalc_API/errors/ub.py b/src/diffcalc_api/errors/ub.py similarity index 97% rename from src/diffcalc_API/errors/ub.py rename to src/diffcalc_api/errors/ub.py index 5d17068..1cb0515 100644 --- a/src/diffcalc_API/errors/ub.py +++ b/src/diffcalc_api/errors/ub.py @@ -4,8 +4,8 @@ import numpy as np -from diffcalc_API.config import VECTOR_PROPERTIES -from diffcalc_API.errors.definitions import ( +from diffcalc_api.config import VECTOR_PROPERTIES +from diffcalc_api.errors.definitions import ( ALL_RESPONSES, DiffcalcAPIException, ErrorCodesBase, diff --git a/src/diffcalc_API/examples/__init__.py b/src/diffcalc_api/examples/__init__.py similarity index 72% rename from src/diffcalc_API/examples/__init__.py rename to src/diffcalc_api/examples/__init__.py index de30da2..268ee84 100644 --- a/src/diffcalc_API/examples/__init__.py +++ b/src/diffcalc_api/examples/__init__.py @@ -1,5 +1,5 @@ """Examples to use in endpoints for fastAPI docs, to make it easier to read.""" -from diffcalc_API.examples import ub +from diffcalc_api.examples import ub __all__ = ["ub"] diff --git a/src/diffcalc_API/examples/ub.py b/src/diffcalc_api/examples/ub.py similarity index 90% rename from src/diffcalc_API/examples/ub.py rename to src/diffcalc_api/examples/ub.py index 1ce6407..516c5db 100644 --- a/src/diffcalc_API/examples/ub.py +++ b/src/diffcalc_api/examples/ub.py @@ -1,7 +1,7 @@ -"""API examples used in diffcalc_API.routes.ub.""" +"""API examples used in diffcalc_api.routes.ub.""" -from diffcalc_API.models.ub import ( +from diffcalc_api.models.ub import ( AddOrientationParams, AddReflectionParams, EditOrientationParams, diff --git a/src/diffcalc_API/models/__init__.py b/src/diffcalc_api/models/__init__.py similarity index 58% rename from src/diffcalc_API/models/__init__.py rename to src/diffcalc_api/models/__init__.py index a56b8b8..7c6e189 100644 --- a/src/diffcalc_API/models/__init__.py +++ b/src/diffcalc_api/models/__init__.py @@ -1,12 +1,12 @@ """Defines all pydantic models used for endpoint requests and responses. Ub and Hkl endpoints have specific pydantic models for their request bodies, defined in -modules diffcalc_API.models.ub and diffcalc_API.models.hkl respectively. +modules diffcalc_api.models.ub and diffcalc_api.models.hkl respectively. -Module diffcalc_API.models.response defines general endpoint response models used by +Module diffcalc_api.models.response defines general endpoint response models used by all routes. """ -from diffcalc_API.models import hkl, response, ub +from diffcalc_api.models import hkl, response, ub __all__ = ["ub", "hkl", "response"] diff --git a/src/diffcalc_API/models/hkl.py b/src/diffcalc_api/models/hkl.py similarity index 100% rename from src/diffcalc_API/models/hkl.py rename to src/diffcalc_api/models/hkl.py diff --git a/src/diffcalc_API/models/response.py b/src/diffcalc_api/models/response.py similarity index 96% rename from src/diffcalc_API/models/response.py rename to src/diffcalc_api/models/response.py index 9ba0da0..dfdff4b 100644 --- a/src/diffcalc_API/models/response.py +++ b/src/diffcalc_api/models/response.py @@ -3,7 +3,7 @@ from pydantic import BaseModel -from diffcalc_API.models.ub import HklModel +from diffcalc_api.models.ub import HklModel class InfoResponse(BaseModel): diff --git a/src/diffcalc_API/models/ub.py b/src/diffcalc_api/models/ub.py similarity index 96% rename from src/diffcalc_API/models/ub.py rename to src/diffcalc_api/models/ub.py index f678ae7..1f349f9 100644 --- a/src/diffcalc_API/models/ub.py +++ b/src/diffcalc_api/models/ub.py @@ -82,6 +82,6 @@ class EditOrientationParams(BaseModel): def select_idx_or_tag_str(idx: Optional[int], tag: Optional[str]) -> str: """Select an index or tag, and generate a string from it. - Return a string for diffcalc_API.models.response.InfoResponse endpoint responses. + Return a string for diffcalc_api.models.response.InfoResponse endpoint responses. """ return f"index {idx}" if idx is not None else f"tag {tag}" diff --git a/src/diffcalc_API/openapi.py b/src/diffcalc_api/openapi.py similarity index 92% rename from src/diffcalc_API/openapi.py rename to src/diffcalc_api/openapi.py index cc4f5a5..ec58202 100644 --- a/src/diffcalc_API/openapi.py +++ b/src/diffcalc_api/openapi.py @@ -4,7 +4,7 @@ from fastapi.openapi.utils import get_openapi -from diffcalc_API.server import app +from diffcalc_api.server import app if __name__ == "__main__": with open("openapi.json", "w") as f: diff --git a/src/diffcalc_API/routes/__init__.py b/src/diffcalc_api/routes/__init__.py similarity index 60% rename from src/diffcalc_API/routes/__init__.py rename to src/diffcalc_api/routes/__init__.py index da7ab89..e8d6f27 100644 --- a/src/diffcalc_API/routes/__init__.py +++ b/src/diffcalc_api/routes/__init__.py @@ -1,5 +1,5 @@ """Defines all endpoints for the API.""" -from diffcalc_API.routes import constraints, hkl, ub +from diffcalc_api.routes import constraints, hkl, ub __all__ = ["ub", "hkl", "constraints"] diff --git a/src/diffcalc_API/routes/constraints.py b/src/diffcalc_api/routes/constraints.py similarity index 94% rename from src/diffcalc_API/routes/constraints.py rename to src/diffcalc_api/routes/constraints.py index e97cb7b..d13457b 100644 --- a/src/diffcalc_API/routes/constraints.py +++ b/src/diffcalc_api/routes/constraints.py @@ -4,9 +4,9 @@ from fastapi import APIRouter, Body, Depends, Query -from diffcalc_API.models.response import InfoResponse, StringResponse -from diffcalc_API.services import constraints as service -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.models.response import InfoResponse, StringResponse +from diffcalc_api.services import constraints as service +from diffcalc_api.stores.protocol import HklCalcStore, get_store router = APIRouter(prefix="/constraints", tags=["constraints"]) diff --git a/src/diffcalc_API/routes/hkl.py b/src/diffcalc_api/routes/hkl.py similarity index 96% rename from src/diffcalc_API/routes/hkl.py rename to src/diffcalc_api/routes/hkl.py index da5cffa..e098a26 100644 --- a/src/diffcalc_API/routes/hkl.py +++ b/src/diffcalc_api/routes/hkl.py @@ -4,17 +4,17 @@ from fastapi import APIRouter, Depends, Query -from diffcalc_API.errors.hkl import InvalidSolutionBoundsError -from diffcalc_API.models.hkl import SolutionConstraints -from diffcalc_API.models.response import ( +from diffcalc_api.errors.hkl import InvalidSolutionBoundsError +from diffcalc_api.models.hkl import SolutionConstraints +from diffcalc_api.models.response import ( ArrayResponse, DiffractorAnglesResponse, MillerIndicesResponse, ScanResponse, ) -from diffcalc_API.models.ub import HklModel, PositionModel -from diffcalc_API.services import hkl as service -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.models.ub import HklModel, PositionModel +from diffcalc_api.services import hkl as service +from diffcalc_api.stores.protocol import HklCalcStore, get_store router = APIRouter(prefix="/hkl", tags=["hkl"]) diff --git a/src/diffcalc_API/routes/ub.py b/src/diffcalc_api/routes/ub.py similarity index 96% rename from src/diffcalc_API/routes/ub.py rename to src/diffcalc_api/routes/ub.py index 76bc33e..b305020 100644 --- a/src/diffcalc_API/routes/ub.py +++ b/src/diffcalc_api/routes/ub.py @@ -4,16 +4,16 @@ from fastapi import APIRouter, Body, Depends, Query -from diffcalc_API.config import VECTOR_PROPERTIES -from diffcalc_API.errors.ub import ( +from diffcalc_api.config import VECTOR_PROPERTIES +from diffcalc_api.errors.ub import ( BothTagAndIdxProvidedError, InvalidPropertyError, InvalidSetLatticeParamsError, NoTagOrIdxProvidedError, ) -from diffcalc_API.examples import ub as examples -from diffcalc_API.models.response import InfoResponse, StringResponse -from diffcalc_API.models.ub import ( +from diffcalc_api.examples import ub as examples +from diffcalc_api.models.response import InfoResponse, StringResponse +from diffcalc_api.models.ub import ( AddOrientationParams, AddReflectionParams, EditOrientationParams, @@ -22,8 +22,8 @@ SetLatticeParams, select_idx_or_tag_str, ) -from diffcalc_API.services import ub as service -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.services import ub as service +from diffcalc_api.stores.protocol import HklCalcStore, get_store router = APIRouter(prefix="/ub", tags=["ub"]) diff --git a/src/diffcalc_API/server.py b/src/diffcalc_api/server.py similarity index 86% rename from src/diffcalc_API/server.py rename to src/diffcalc_api/server.py index c6e2039..e141c99 100644 --- a/src/diffcalc_API/server.py +++ b/src/diffcalc_api/server.py @@ -6,18 +6,18 @@ from diffcalc.util import DiffcalcException from fastapi import Depends, FastAPI, Query, Request, responses -from diffcalc_API import routes -from diffcalc_API.config import Settings -from diffcalc_API.errors.constraints import responses as constraints_responses -from diffcalc_API.errors.definitions import DiffcalcAPIException -from diffcalc_API.errors.hkl import responses as hkl_responses -from diffcalc_API.errors.ub import responses as ub_responses -from diffcalc_API.models.response import InfoResponse -from diffcalc_API.stores.protocol import get_store, setup_store +from diffcalc_api import routes +from diffcalc_api.config import Settings +from diffcalc_api.errors.constraints import responses as constraints_responses +from diffcalc_api.errors.definitions import DiffcalcAPIException +from diffcalc_api.errors.hkl import responses as hkl_responses +from diffcalc_api.errors.ub import responses as ub_responses +from diffcalc_api.models.response import InfoResponse +from diffcalc_api.stores.protocol import get_store, setup_store logger = logging.getLogger(__name__) config = Settings() -setup_store("diffcalc_API.stores.mongo.MongoHklCalcStore") +setup_store("diffcalc_api.stores.mongo.MongoHklCalcStore") app = FastAPI( responses=get_store().responses, title="diffcalc", version=config.api_version diff --git a/src/diffcalc_API/services/__init__.py b/src/diffcalc_api/services/__init__.py similarity index 68% rename from src/diffcalc_API/services/__init__.py rename to src/diffcalc_api/services/__init__.py index 5e5f3bb..7ea6d0b 100644 --- a/src/diffcalc_API/services/__init__.py +++ b/src/diffcalc_api/services/__init__.py @@ -1,5 +1,5 @@ """Defines business logic for all endpoints, separately from the API logic.""" -from diffcalc_API.services import constraints, hkl, ub +from diffcalc_api.services import constraints, hkl, ub __all__ = ["ub", "hkl", "constraints"] diff --git a/src/diffcalc_API/services/constraints.py b/src/diffcalc_api/services/constraints.py similarity index 94% rename from src/diffcalc_API/services/constraints.py rename to src/diffcalc_api/services/constraints.py index 82e659c..ed1783c 100644 --- a/src/diffcalc_API/services/constraints.py +++ b/src/diffcalc_api/services/constraints.py @@ -4,9 +4,9 @@ from diffcalc.hkl.constraints import Constraints -from diffcalc_API.config import ALL_CONSTRAINTS, CONSTRAINTS_WITH_NO_VALUE -from diffcalc_API.errors.constraints import InvalidConstraintError -from diffcalc_API.stores.protocol import HklCalcStore +from diffcalc_api.config import ALL_CONSTRAINTS, CONSTRAINTS_WITH_NO_VALUE +from diffcalc_api.errors.constraints import InvalidConstraintError +from diffcalc_api.stores.protocol import HklCalcStore async def get_constraints( diff --git a/src/diffcalc_API/services/hkl.py b/src/diffcalc_api/services/hkl.py similarity index 97% rename from src/diffcalc_API/services/hkl.py rename to src/diffcalc_api/services/hkl.py index 46c2e9b..3661cab 100644 --- a/src/diffcalc_API/services/hkl.py +++ b/src/diffcalc_api/services/hkl.py @@ -6,10 +6,10 @@ import numpy as np from diffcalc.hkl.geometry import Position -from diffcalc_API.errors.hkl import InvalidMillerIndicesError, InvalidScanBoundsError -from diffcalc_API.models.hkl import SolutionConstraints -from diffcalc_API.models.ub import HklModel, PositionModel -from diffcalc_API.stores.protocol import HklCalcStore +from diffcalc_api.errors.hkl import InvalidMillerIndicesError, InvalidScanBoundsError +from diffcalc_api.models.hkl import SolutionConstraints +from diffcalc_api.models.ub import HklModel, PositionModel +from diffcalc_api.stores.protocol import HklCalcStore async def lab_position_from_miller_indices( diff --git a/src/diffcalc_API/services/ub.py b/src/diffcalc_api/services/ub.py similarity index 98% rename from src/diffcalc_API/services/ub.py rename to src/diffcalc_api/services/ub.py index 7a30285..ed85aa9 100644 --- a/src/diffcalc_API/services/ub.py +++ b/src/diffcalc_api/services/ub.py @@ -4,8 +4,8 @@ from diffcalc.hkl.geometry import Position -from diffcalc_API.errors.ub import ReferenceRetrievalError -from diffcalc_API.models.ub import ( +from diffcalc_api.errors.ub import ReferenceRetrievalError +from diffcalc_api.models.ub import ( AddOrientationParams, AddReflectionParams, EditOrientationParams, @@ -13,7 +13,7 @@ HklModel, SetLatticeParams, ) -from diffcalc_API.stores.protocol import HklCalcStore +from diffcalc_api.stores.protocol import HklCalcStore async def get_ub(name: str, store: HklCalcStore, collection: Optional[str]) -> str: diff --git a/src/diffcalc_API/stores/__init__.py b/src/diffcalc_api/stores/__init__.py similarity index 64% rename from src/diffcalc_API/stores/__init__.py rename to src/diffcalc_api/stores/__init__.py index 8433adf..beb7c58 100644 --- a/src/diffcalc_API/stores/__init__.py +++ b/src/diffcalc_api/stores/__init__.py @@ -3,11 +3,11 @@ Diffraction calculations can only be performed on HklCalculation objects, which must be persisted. -diffcalc_API.stores.pickling defines a class for persisting them on-file, -diffcalc_API.stores.mongo defines a class for persisting them on mongodb. +diffcalc_api.stores.pickling defines a class for persisting them on-file, +diffcalc_api.stores.mongo defines a class for persisting them on mongodb. This can be extended to any database or persistence model, so long as it follows -the protocol defined in diffcalc_API.stores.protocol. +the protocol defined in diffcalc_api.stores.protocol. """ from . import pickling, protocol diff --git a/src/diffcalc_API/stores/mongo.py b/src/diffcalc_api/stores/mongo.py similarity index 97% rename from src/diffcalc_API/stores/mongo.py rename to src/diffcalc_api/stores/mongo.py index 264d933..ff8197b 100644 --- a/src/diffcalc_API/stores/mongo.py +++ b/src/diffcalc_api/stores/mongo.py @@ -9,8 +9,8 @@ from motor.motor_asyncio import AsyncIOMotorCollection as Collection from pymongo.results import DeleteResult -from diffcalc_API.database import database -from diffcalc_API.errors.definitions import ( +from diffcalc_api.database import database +from diffcalc_api.errors.definitions import ( ALL_RESPONSES, DiffcalcAPIException, ErrorCodesBase, diff --git a/src/diffcalc_API/stores/pickling.py b/src/diffcalc_api/stores/pickling.py similarity index 97% rename from src/diffcalc_API/stores/pickling.py rename to src/diffcalc_api/stores/pickling.py index e91ea4c..394cbe2 100644 --- a/src/diffcalc_API/stores/pickling.py +++ b/src/diffcalc_api/stores/pickling.py @@ -9,8 +9,8 @@ from diffcalc.hkl.constraints import Constraints from diffcalc.ub.calc import UBCalculation -from diffcalc_API.config import SAVE_PICKLES_FOLDER -from diffcalc_API.errors.definitions import ( +from diffcalc_api.config import SAVE_PICKLES_FOLDER +from diffcalc_api.errors.definitions import ( ALL_RESPONSES, DiffcalcAPIException, ErrorCodesBase, diff --git a/src/diffcalc_API/stores/protocol.py b/src/diffcalc_api/stores/protocol.py similarity index 100% rename from src/diffcalc_API/stores/protocol.py rename to src/diffcalc_api/stores/protocol.py diff --git a/tests/test_constraints.py b/tests/test_constraints.py index 29bda4c..91c7d23 100644 --- a/tests/test_constraints.py +++ b/tests/test_constraints.py @@ -6,9 +6,9 @@ from diffcalc.ub.calc import UBCalculation from fastapi.testclient import TestClient -from diffcalc_API.errors.constraints import ErrorCodes -from diffcalc_API.server import app -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.errors.constraints import ErrorCodes +from diffcalc_api.server import app +from diffcalc_api.stores.protocol import HklCalcStore, get_store from tests.conftest import FakeHklCalcStore dummy_hkl = HklCalculation(UBCalculation(name="dummy"), Constraints()) diff --git a/tests/test_create_delete.py b/tests/test_create_delete.py index e6a5635..a8b9ad1 100644 --- a/tests/test_create_delete.py +++ b/tests/test_create_delete.py @@ -4,8 +4,8 @@ from diffcalc.ub.calc import UBCalculation from fastapi.testclient import TestClient -from diffcalc_API.server import app -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.server import app +from diffcalc_api.stores.protocol import HklCalcStore, get_store from tests.conftest import FakeHklCalcStore dummy_hkl = HklCalculation(UBCalculation(name="dummy"), Constraints()) diff --git a/tests/test_hklcalc.py b/tests/test_hklcalc.py index ffa9e85..bca6258 100644 --- a/tests/test_hklcalc.py +++ b/tests/test_hklcalc.py @@ -8,9 +8,9 @@ from diffcalc.ub.calc import UBCalculation from fastapi.testclient import TestClient -from diffcalc_API.errors.hkl import ErrorCodes -from diffcalc_API.server import app -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.errors.hkl import ErrorCodes +from diffcalc_api.server import app +from diffcalc_api.stores.protocol import HklCalcStore, get_store from tests.conftest import FakeHklCalcStore dummy_hkl = HklCalculation(UBCalculation(name="dummy"), Constraints()) @@ -114,7 +114,7 @@ def test_scan_hkl_raises_invalid_solution_bounds_error_for_wrong_inputs( assert lab_positions.status_code == ErrorCodes.INVALID_SOLUTION_BOUNDS assert ( ast.literal_eval(lab_positions.content.decode())["type"] - == "" + == "" ) @@ -158,7 +158,7 @@ def test_scan_hkl_raises_invalid_miller_indices_error_for_wrong_inputs( assert ( ast.literal_eval(lab_positions.content.decode())["type"] - == "" + == "" ) diff --git a/tests/test_ubcalc.py b/tests/test_ubcalc.py index caeaabd..57399ed 100644 --- a/tests/test_ubcalc.py +++ b/tests/test_ubcalc.py @@ -8,9 +8,9 @@ from diffcalc.ub.calc import UBCalculation from fastapi.testclient import TestClient -from diffcalc_API.errors.ub import ErrorCodes -from diffcalc_API.server import app -from diffcalc_API.stores.protocol import HklCalcStore, get_store +from diffcalc_api.errors.ub import ErrorCodes +from diffcalc_api.server import app +from diffcalc_api.stores.protocol import HklCalcStore, get_store from tests.conftest import FakeHklCalcStore dummy_hkl = HklCalculation(UBCalculation(name="dummy"), Constraints())