Skip to content

Commit

Permalink
remove gcp/cloudstorage, sentry fixes, tox changes, github build changes
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Apr 28, 2024
1 parent 427a1dc commit 7f85101
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
python-version: ["3.8", "3.9", "3.10", "3.11"]

env:
USING_COVERAGE: "3.9"
Expand All @@ -35,7 +35,7 @@ jobs:
make tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
if: contains(env.USING_COVERAGE, matrix.python-version)
with:
fail_ci_if_error: true
fail_ci_if_error: false
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ coverage: ## Run tests with coverage
pytest --cov fractal --cov-report=xml

deps: ## Install dependencies
python -m pip install --upgrade pip
python -m pip install autoflake black coverage django fastapi flake8 flit fractal-repositories fractal-roles fractal-specifications fractal-tokens httpx isort mccabe mypy pre-commit pylint pytest pytest-cov pytest-asyncio pytest-lazy-fixture python-dotenv python-jose requests 'sqlalchemy<2.0' tox tox-gh-actions
python -m pip install cryptography
python -m pip install -U pip
python -m pip install -U autoflake black coverage cryptography django fastapi flake8 flit fractal-repositories fractal-roles fractal-specifications fractal-tokens httpx isort mccabe mypy pre-commit pylint 'pytest<7' pytest-cov pytest-asyncio pytest-lazy-fixture python-dotenv python-jose requests 'sqlalchemy<2.0' tox tox-gh-actions

lint: ## Lint and static-check
pre-commit run --all-files
Expand Down
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."""

__version__ = "4.1.3"
__version__ = "5.0.0"

from abc import ABC

Expand Down
25 changes: 16 additions & 9 deletions fractal/contrib/fastapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def install_fastapi(settings: Settings):
title=getattr(settings, "APP_NAME", "Fractal service"),
version=getattr(settings, "APP_VERSION", "0.1.0"),
root_path=getattr(settings, "OPENAPI_PREFIX_PATH", ""),
openapi_url="/openapi.json"
if str(getattr(settings, "APIDOCS_ENABLED", "true")).lower()
in ["1", "yes", "true"]
else None,
openapi_url=(
"/openapi.json"
if str(getattr(settings, "APIDOCS_ENABLED", "true")).lower()
in ["1", "yes", "true"]
else None
),
)

app.add_middleware(
Expand All @@ -38,7 +40,12 @@ def install_fastapi(settings: Settings):

if sentry:
if sentry_dsn := getattr(settings, "SENTRY_DSN", ""):
sentry_sdk.init(dsn=sentry_dsn)
sentry_sdk.init(
dsn=sentry_dsn,
traces_sample_rate=getattr(settings, "SENTRY_TRACES_SAMPLE_RATE", 0.1),
send_default_pii=True,
enable_tracing=True,
)

@app.exception_handler(DomainException)
def unicorn_domain_exception_handler(request: Request, exc: DomainException):
Expand All @@ -48,8 +55,8 @@ def unicorn_domain_exception_handler(request: Request, exc: DomainException):
else:
logger.error(f"{exc.code} - {exc.message}")

if sentry:
sentry_sdk.capture_exception(exc)
# if sentry:
# sentry_sdk.capture_exception(exc)

return JSONResponse(
status_code=exc.status_code,
Expand All @@ -64,8 +71,8 @@ def unicorn_domain_exception_handler(request: Request, exc: DomainException):
def unicorn_exception_handler(request: Request, exc: Exception):
logging.error(exc)

if sentry:
sentry_sdk.capture_exception(exc)
# if sentry:
# sentry_sdk.capture_exception(exc)

return JSONResponse(
status_code=500,
Expand Down
8 changes: 5 additions & 3 deletions fractal/contrib/fastapi/routers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ def inject_default_routes(fractal: Fractal):
@router.get(Routes.ROOT)
def read_root():
return {
"FastAPI": fractal.settings.APP_NAME
if fractal.settings and hasattr(fractal.settings, "APP_NAME")
else "Fractal Service",
"FastAPI": (
fractal.settings.APP_NAME
if fractal.settings and hasattr(fractal.settings, "APP_NAME")
else "Fractal Service"
),
}

@router.get(Routes.INFO, responses={200: {"model": Info}})
Expand Down
2 changes: 1 addition & 1 deletion fractal/contrib/fastapi/routers/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@dataclass
class TokenPayload(Model, BaseTokenPayload):
...
pass


@dataclass
Expand Down
Empty file.
64 changes: 0 additions & 64 deletions fractal/contrib/gcp/cloudstorage/repositories.py

This file was deleted.

1 change: 0 additions & 1 deletion fractal/contrib/gcp/cloudstorage/requirements.txt

This file was deleted.

32 changes: 20 additions & 12 deletions fractal/core/utils/application_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ def load_internal_services(self):
"""Load services for internal use of the domain."""
for name, service in self.registered_internal_services:
_service = self.install_service(
service(self.settings)
if isinstance(service, FunctionType)
else service,
(
service(self.settings)
if isinstance(service, FunctionType)
else service
),
name=name,
)
setattr(self, name, _service())
Expand All @@ -108,9 +110,11 @@ def load_repositories(self):
self,
name,
self.install_repository(
repository(self.settings)
if isinstance(repository, FunctionType)
else repository,
(
repository(self.settings)
if isinstance(repository, FunctionType)
else repository
),
name=name,
),
)
Expand Down Expand Up @@ -172,9 +176,11 @@ def load_egress_services(self):
"""Load services to external interfaces that are initiated by this service (outbound)"""
for name, service in self.registered_egress_services:
_service = self.install_service(
service(self.settings)
if isinstance(service, FunctionType)
else service,
(
service(self.settings)
if isinstance(service, FunctionType)
else service
),
name=name,
)
setattr(self, name, _service())
Expand Down Expand Up @@ -238,9 +244,11 @@ def load_ingress_services(self):
"""Load services to external interfaces that are initiated by the external services (inbound)"""
for name, service in self.registered_ingress_services:
_service = self.install_service(
service(self.settings)
if isinstance(service, FunctionType)
else service,
(
service(self.settings)
if isinstance(service, FunctionType)
else service
),
name=name,
)
setattr(self, name, _service())
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fractal-toolkit"
version = "4.1.3"
version = "5.0.0"
description = "Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."
authors = ["Douwe van der Meij <[email protected]>"]

Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[tox]
isolated_build = True
Expand All @@ -23,7 +26,7 @@ deps =
mccabe
mypy
pylint
pytest
pytest<7
pytest-asyncio
pytest-lazy-fixture
python-jose
Expand Down

0 comments on commit 7f85101

Please sign in to comment.