-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from AustralianSynchrotron/SCOMPMX-627-deploy-…
…core-mx3-services-to-kubernetes Scompmx 627 deploy core mx3 services to kubernetes
- Loading branch information
Showing
14 changed files
with
760 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,136 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Deployment | ||
/deployment/*secret* | ||
|
||
# IDE | ||
/.venv/ | ||
/.poetry_env/ | ||
.vscode/ | ||
.idea/ | ||
|
||
|
||
*.h5 | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from ._version import __version__ | ||
|
||
__all__ = ("__version__",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from importlib.metadata import PackageNotFoundError, version | ||
|
||
__version__: str | ||
try: | ||
__version__ = version(__package__ or __name__) | ||
except PackageNotFoundError: | ||
# Could fail to find package when developing locally. | ||
# Try reading from pyproject.toml as a backup. | ||
|
||
from pathlib import Path | ||
from tomllib import load as load_toml | ||
|
||
try: | ||
with open(Path(__file__).resolve().parents[1] / "pyproject.toml", "rb") as f: | ||
pyproject = load_toml(f) | ||
__version__ = pyproject["tool"]["poetry"]["version"] | ||
except OSError: | ||
# File IO error | ||
__version__ = "local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
from functools import lru_cache | ||
from os.path import dirname as os_dirname, join as os_joinpath, realpath as os_realpath | ||
from pathlib import Path | ||
from typing import Annotated, Self | ||
|
||
from pydantic import Field, FilePath, GetPydanticSchema, SecretStr | ||
from pydantic_settings import ( | ||
BaseSettings, | ||
PydanticBaseSettingsSource, | ||
SettingsConfigDict, | ||
) | ||
|
||
__all__ = ("Settings", "get_settings") | ||
|
||
CUR_DIR = os_dirname(os_realpath(__file__)) | ||
|
||
|
||
class APISettings(BaseSettings): | ||
"""API Settings""" | ||
|
||
API_APP_NAME: str = Field( | ||
title="App Name", | ||
default="Simulated Simplon API", | ||
) | ||
API_DOCS_URL: str | None = Field( | ||
title="OpenAPI Docs Path", | ||
default=None, | ||
) | ||
API_REDOC_URL: str | None = Field( | ||
title="ReDocs Path", | ||
default=None, | ||
) | ||
API_OPENAPI_URL: str | None = Field( | ||
title="OpenAPI Path", | ||
default=None, | ||
) | ||
API_FAVICON: FilePath = Field( | ||
title="Favicon Image", | ||
default=os_realpath(os_joinpath(CUR_DIR, "./favicon.ico")), | ||
) | ||
API_KEY: SecretStr | None = Field( | ||
title="Service API-Key", | ||
default=None, | ||
) | ||
|
||
|
||
class ZMQStreamSettings(BaseSettings): | ||
"""ZMQ Stream Settings""" | ||
|
||
ZMQ_ADDRESS: str = Field( | ||
title="ZMQ Address", | ||
default="tcp://*:5555", | ||
) | ||
HDF5_MASTER_FILE: Annotated[ | ||
str, | ||
GetPydanticSchema(lambda _, _h: _h.generate_schema(FilePath)), | ||
] = Field( | ||
title="HDF5 Master File", | ||
) | ||
DELAY_BETWEEN_FRAMES: float = Field( | ||
title="Delay Between Frames", | ||
default=0.01, | ||
) | ||
NUMBER_OF_DATA_FILES: int = Field( | ||
title="Number of Data Files", | ||
default=1, | ||
) | ||
|
||
|
||
class Settings(APISettings, ZMQStreamSettings): | ||
README: FilePath = Field( | ||
title="ReadMe", | ||
default=os_realpath(os_joinpath(CUR_DIR, "../README.md")), | ||
validate_default=True, | ||
) | ||
PYPROJECT: FilePath = Field( | ||
title="PyProject", | ||
default=os_realpath(os_joinpath(CUR_DIR, "../pyproject.toml")), | ||
validate_default=True, | ||
) | ||
BUILD_INFO: Path = Field( | ||
title="Build Info", | ||
default=os_realpath(os_joinpath(CUR_DIR, "../.build_info.json")), | ||
validate_default=True, | ||
) | ||
|
||
model_config = SettingsConfigDict( | ||
str_strip_whitespace=True, | ||
env_prefix="AS_", | ||
env_file=".env", | ||
validate_assignment=True, | ||
) | ||
|
||
@classmethod | ||
def settings_customise_sources( | ||
cls: type[Self], | ||
settings_cls: type[BaseSettings], | ||
init_settings: PydanticBaseSettingsSource, | ||
env_settings: PydanticBaseSettingsSource, | ||
dotenv_settings: PydanticBaseSettingsSource, | ||
file_secret_settings: PydanticBaseSettingsSource, | ||
) -> tuple[PydanticBaseSettingsSource, ...]: | ||
# Restrict settings sources to environment variables only | ||
return (env_settings, dotenv_settings) | ||
|
||
|
||
@lru_cache() | ||
def get_settings() -> Settings: | ||
"""Cache the settings, this allows the settings to be used in dependencies and | ||
for overwriting in tests | ||
""" | ||
return Settings() # pyright: ignore[reportCallIssue] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.