Skip to content

Commit

Permalink
🛂 Migrates poetry to pdm (#12)
Browse files Browse the repository at this point in the history
* Migrates poetry to pdm

* Migrates to shared .github/workflows

* Fixes pytest args, lint errors

* Fixes docker build steps
  • Loading branch information
mrharpo authored Aug 3, 2023
1 parent 4991b7d commit d41d3ed
Show file tree
Hide file tree
Showing 13 changed files with 985 additions and 2,123 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: 🧪 Integration Tests

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
tests:
name: ⚗️ Application Tests
uses: ./.github/workflows/pytest.yml
uses: WGBH-MLA/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
pdm_args: -G test
pytest_args: -v

lint:
name: 👕 Lint
uses: ./.github/workflows/lint.yml
uses: WGBH-MLA/.github/.github/workflows/lint.yml@main

black:
name: 🖤 Black
uses: ./.github/workflows/black.yml
uses: WGBH-MLA/.github/.github/workflows/black.yml@main
30 changes: 0 additions & 30 deletions .github/workflows/lint.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .github/workflows/pytest.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RUN pip install -U pip uvicorn

WORKDIR /app

COPY pyproject.toml poetry.lock README.md ./
COPY pyproject.toml pdm.lock README.md ./
COPY fastclam fastclam

RUN pip install .
Expand Down
3 changes: 3 additions & 0 deletions fastclam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[localhost:8000/docs](http://localhost:8000/docs)
"""
from ._version import __version__

__all__ = ['__version__']
1 change: 1 addition & 0 deletions fastclam/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.2.0'
14 changes: 7 additions & 7 deletions fastclam/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
from xml.etree.ElementTree import ParseError

import requests
from clams.source import generate_source_mmif
from clams.source import generate_source_mmif_from_file
from fastapi import FastAPI, HTTPException
from fastapi.responses import PlainTextResponse
from starlette.exceptions import HTTPException as StarletteHTTPException

from ._version import __version__
from .log import log
from .models import Inputs, Pipeline
from .version import __VERSION__


class MMIFException(HTTPException):
pass


app = FastAPI(title='FastCLAM')
app = FastAPI(title='FastCLAM', version=__version__)


@app.exception_handler(StarletteHTTPException)
Expand All @@ -29,14 +29,14 @@ async def http_exception_handler(request, exc):
@app.get('/')
def home() -> dict:
"""Return version info"""
return {'FastCLAM': __VERSION__}
return {'FastCLAM': __version__}


@app.post('/source')
def generate_source(files: Inputs) -> dict:
"""Generate a new source MMIF from multiple input files"""
log.info(f'sourcing media {files.files}')
mmif = generate_source_mmif(files.files)
mmif = generate_source_mmif_from_file(files.files)
json_value = loads(str(mmif))
log.debug(f'sourced: {json_value}')
return json_value
Expand Down Expand Up @@ -76,7 +76,7 @@ def run_pipeline(pipeline: Pipeline) -> list | dict | str:
log.debug(response.content)
raise HTTPException(
status_code=response.status_code,
detail=f'Unsuccessful response from {app}: {response.status_code} - {response.content}',
detail=f'Unsuccessful response from {app}: {response.status_code} - {response.content}', # noqa E501
)
content_type = response.headers.get('Content-Type')
if 'application/json' in content_type:
Expand All @@ -95,7 +95,7 @@ def run_pipeline(pipeline: Pipeline) -> list | dict | str:
log.debug(response.content)
raise MMIFException(
status_code=499,
detail=f'Failed to parse XML from {app}: {response.status_code} - {response.content}',
detail=f'Failed to parse XML from {app}: {response.status_code} - {response.content}', # noqa E501
)

log.info(f'Ran {len(pipeline.files)} files through {len(pipeline.apps)} apps')
Expand Down
2 changes: 1 addition & 1 deletion fastclam/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
handlers=[
{
"sink": RichHandler(),
"format": "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
"format": "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>", # noqa E501
}
]
)
1 change: 0 additions & 1 deletion fastclam/version.py

This file was deleted.

Loading

0 comments on commit d41d3ed

Please sign in to comment.