Git Product home page Git Product logo

atmoseer-app-backend's Introduction

Atmoseer app backend

This project is powered by FastAPI and developed using Python 3.12.

Get Started

Clone the repository

git clone https://github.com/NietoCurcio/atmoseer-app-backend.git
cd atmoseer-app-backend

Initialize atmoseer submodule

git submodule update --init --progress

Setup with poetry (recommended)

Install poetry dependency manager.

  • Linux and macOS

    curl -sSL https://install.python-poetry.org | python3 -
  • Windows Powershell

    (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

Install project dependencies. A virtual environment in {cache-dir}/virtualenvs is automatically created by poetry:

poetry install

# Creating virtualenv atmoseer-app-backend-...
# Installing dependencies from lock file
# ...
# Installing the current project: atmoseer-app-backend (0.1.0)

Setup with python venv or virtualenv (optional)

It's also possible to install the application with pip using poetry build backend, please see Writing your pyproject.toml. Setup the application using the python venv standard library or virtualenv tool:

python -m venv .venv
source .venv/bin/activate # use ".venv\Scripts\activate.ps1" in Windows Powershell
pip install -e .
# You can execute "deactivate" to deactivate the virtual environment

Setup with conda (optional)

TODO

Start a local instance of PostgreSQL with Docker:

docker compose up
# pg-admin is running at http://localhost:5050

Running the application

Note, if you setup the application without poetry, just run the commands without poetry run. For example, for the alembic command below it should be alembic upgrade head since the CLIs are installed in the activated virtual environment. Since poetry also creates a virtual environment, it's also possible to run commands directly (without poetry run) with poetry by running poetry shell to create a nested shell (enter exit to deactivate and exit), please see using your virtual environment

Run alembic database migrations:

poetry run alembic upgrade head

# INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
# INFO  [alembic.runtime.migration] Will assume transactional DDL.
# INFO  [alembic.runtime.migration] Running upgrade  -> 76213b2e56df, create hero table

# to undo all migrations run 'poetry run alembic downgrade base'

Start the server:

  • Using Poetry:
    poetry run start
    # INFO:     Uvicorn running on http://127.0.0.1:3333 (Press CTRL+C to quit)
    # ...
    # INFO:     Application startup complete.
  • Using a virtual environment:
    python -m atmoseer_app_backend.main

Documentation

Project structure

atmoseer-app-backend/
├── .env.example
├── .gitmodules
├── alembic.ini
├── docker-compose.yml
├── poetry.lock
├── pyproject.toml
├── README.md
├── atmoseer
└── atmoseer_app_backend
    ├── main.py
    ├── app.py
    ├── config.py
    ├── helpers
    │   ├── Logger.py
    │   ├── PathHelper.py
    │   ├── AsyncExecutor.py
    │   ├── GeoStationReader.py
    │   ├── GeoStations.py
    │   ├── GreatCircleDistance.py
    │   ├── WeatherStations.csv
    │   └── models
    │       └── Station.py
    ├── migrations
    │   └── alembic
    │       ├── env.py
    │       └── versions
    ├── models
    │   └── Hero.py
    ├── repositories
    │   ├── HeroRepository.py
    │   ├── database
    │   │   └── database.py
    │   └── interfaces
    │       └── Repository.py
    ├── services
    │   ├── ForecastService.py
    │   ├── HeroService.py
    │   ├── exceptions
    │   │   └── exceptions.py
    │   └── interfaces
    │       ├── AtmoseerService.py
    │       └── Service.py
    └── api
        ├── router.py
        └── routes
            ├── forecast.py
            └── heros.py

The source code of the backend is in the atmoseer_app_backend folder. The atmoseer folder is a submodule, it has its own git repostiory at NietoCurcio/atmoseer Github. The atmoseer submodule is necessary to use the machine learning algorithms developed by the CEFET-RJ Machine Learning Research Group.

  • Endpoints

  • Services

Technologies

Docker

Removing all containers:

docker rm -f $(docker ps -a -q)

Removing all volumes:

docker volume rm $(docker volume ls -q)

Ruff

Ruff linter and code formatter. Ruff is used by major projects like pandas, Jupyter, PyTorch, SciPy etc.

Run ruff linter:

poetry run ruff check atmoseer_app_backend --fix 

Run ruff formatter:

poetry run ruff format atmoseer_app_backend

We can use Ruff vscode extension. After installing the extension, we can configure Ruff extension to lint and format code on vscode settings.json.

{
  "[python]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.fixAll": "explicit"
    },
    "editor.defaultFormatter": "charliermarsh.ruff"
  }
}

atmoseer-app-backend's People

Contributors

nietocurcio avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.