Commit 83d866fa authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

dev base project

update README
parent 2d5b2c07
.vscode
.env
# MacOS
.DS_Store
# Python
__pycache__
*.egg-info/
MIT License
Copyright (c) 2021 Institut Pasteur
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -4,3 +4,18 @@ From experiences acquired developing https://gitlab.pasteur.fr/metagenomics/meta
* [FastAPI](https://fastapi.tiangolo.com/)
* [SQLModel](https://sqlmodel.tiangolo.com/)
## Run the project for DEV
To run the application you need:
* `Docker` : [Install instructions](https://docs.docker.com/install/)
* `Docker Compose` : [Install instructions](https://docs.docker.com/compose/install/)
From the root directory of the repository:
```bash
docker-compose up
```
Then you can visit the [documentation](http://localhost/docs) of the project.
FROM python:3.9
WORKDIR /app/
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./app/pyproject.toml ./app/poetry.lock* /app/
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
COPY ./app /app
ENV PYTHONPATH=/app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
__version__ = '0.1.0'
from fastapi import APIRouter
router = APIRouter()
@router.get("/")
async def genes():
"""
"""
return {
'data': {"genes": [1, 2, 3]}
}
@router.get("/{gene_id}")
async def gene(gene_id: str):
"""
"""
return {
'data': {"gene_id": gene_id}
}
from fastapi import APIRouter
from app.api.endpoints import genes
api_router = APIRouter()
api_router.include_router(genes.router, prefix="/genes", tags=["Genes"])
from pydantic import BaseSettings
class Settings(BaseSettings):
API_STR: str = "/api"
settings = Settings()
import logging
from fastapi import FastAPI
from app.version import __version__
from app.api.router import api_router
from app.core.config import settings
app = FastAPI(
title="FastGenes",
description="API for genes database.",
version=__version__,
docs_url="/docs",
openapi_url=f"{settings.API_STR}/openapi.json",
)
logger = logging.getLogger(__name__)
app.include_router(
api_router,
prefix=settings.API_STR,
)
\ No newline at end of file
from typing import Optional
from sqlmodel import Field, SQLModel
class Gene(SQLModel, table=True):
gene_id: str = Field(primary_key=True)
sequence: str
length: int
version_info = (0, 1, 0)
__version__ = '.'.join(str(c) for c in version_info)
This diff is collapsed.
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["Kenzo-Hugo Hillion <hillion.kenzo@posteo.net>"]
[tool.poetry.dependencies]
python = "^3.8"
fastapi = "^0.70.0"
sqlmodel = "^0.0.4"
uvicorn = "^0.15.0"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
from app import __version__
def test_version():
assert __version__ == '0.1.0'
version: '3'
services:
backend:
container_name: fastgenes-backend
build:
context: ./backend
args:
INSTALL_DEV: ${INSTALL_DEV-true}
volumes:
- ./backend/app:/app
ports:
- "8888:8888"
command: uvicorn --reload --host 0.0.0.0 --port 8888 app.main:app
networks:
- main
nginx:
image: nginx:1.13.12-alpine
ports:
- "80:80"
depends_on:
- backend
volumes:
- ./nginx/dev/nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- main
networks:
main:
driver: bridge
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment