Skip to content

Commit

Permalink
use uv for dependencies/environment setup
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Feb 12, 2025
1 parent 28572d9 commit c97f26d
Show file tree
Hide file tree
Showing 25 changed files with 923 additions and 242 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: ci

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
run: uv run pytest tests
- uses: k1LoW/octocov-action@v1

check:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --all-extras --dev
- name: Run ruff check
run: uv run ruff check --output-format github
- name: Run pyright
run: uv run pyright

format:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --all-extras --dev
- name: Run ruff format
run: uv run ruff format --diff
20 changes: 12 additions & 8 deletions .github/workflows/data-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ jobs:
- name: checkout repo content
uses: actions/checkout@v2

- name: setup python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.11"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install the project
run: uv sync --all-extras

- name: check data
run: python src/check_data.py
run: uv run loa_check
25 changes: 14 additions & 11 deletions .github/workflows/data-combine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,27 @@ jobs:
- name: checkout repo content
uses: actions/checkout@v2

- name: setup python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.11"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --all-extras

- name: build data
run: python src/combine_data.py
run: uv run loa_combine

- name: Archive generated files as artifact
uses: actions/upload-artifact@v4
with:
name: generated-files
path: ./api
path: ./dist

- name: Checkout production branch
uses: actions/checkout@v2
Expand All @@ -41,11 +44,11 @@ jobs:
uses: actions/download-artifact@v4
with:
name: generated-files
path: ./api
path: ./dist

- name: Apply changes to production branch
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git diff-index --quiet HEAD || (git commit -a -m "Add generated files from main branch" --allow-empty && git push origin production)
git diff-index --quiet HEAD || (git commit -a -m "Add generated files from main branch" --allow-empty && git push origin production)
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.pyc
.vscode/*
.vscode/*
.direnv
cov.xml
dist
92 changes: 78 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# VATGER Letters of Agreement

This repository includes the data VATSIM Germany uses to display agreements in
its information system [ATCISS](https://github.com/vatger/atciss). The aim is to
also use this to generate PDFs and be exportable for use in GNG (for EuroScope .ese).
This data is licensed under CC-BY-SA and included in the subfolder `data`.

Additionally a small library using pydantic is included to consume and validate the
data. See [Library Usage] below for further information. The code is licensed under
the MIT license.

## Data Format

Each agreement is defined by the following properties on a list of `agreements`
in a directory structure of `transferring_fir/receiving_fir/any_file_name.toml`,
i.e. `EDMM/EDUU/south.toml` and `EDMM/EDUU/east.toml` both defining parts of the
Expand Down Expand Up @@ -27,46 +38,46 @@ from_sector = string
to_sector = string
```

## `adep`
### `adep`

ICAO identifier of departure airports, one of which must match for the agreement
to apply. If `adep` and `ades` are specified one of each must match.

## `ades`
### `ades`

ICAO identifier of destination airports, one of which must match for the agreement
to apply. If `adep` and `ades` are specified one of each must match.

## `runway`
### `runway`

Active runway of one of the airports in `ades` or `adep`.

## `cop`
### `cop`

Coordination point of the agreement, `null` if the agreement shall apply to any
traffic from `from_sector` to `to_sector`.

## `route_before`/`route_after`
### `route_before`/`route_after`

Route elements prior to or after the `cop`. This can be an airway or IFPS compatible
route elements: i.e. `"T161"`, `"KOSIX L986 MAG"`

## `level`
### `level`

Flight level at which the traffic is to be transferred. `null` for traffic that
needs individual coordination.

## `transfer_type`
### `transfer_type`

`"C"` for transfer of traffic climbing to the specified `level`, `"D"` for descending,
`ǹull` for traffic to be at `level`.

## `sfl`
### `sfl`

Supplementary flight level, the level out of which the traffic has to be climbing,
descending. (`transfer_type`)

## `level_at`
### `level_at`

Additional specification for the location where the traffic has to meet the transfer
conditions:
Expand All @@ -76,7 +87,7 @@ conditions:
- `[15, "MAH"]`: latest 15 nm after `MAH`
- `[0, "RUDNO"]`: latest at or abeam `RUDNO`

## `qnh`
### `qnh`

For agreements where traffic is transferred at an altitude, the value of this property
is the ICAO code of the reference QNH, i.e. 8000ft on EDDM QNH:
Expand All @@ -93,7 +104,7 @@ from_sector = "ed/DMSL"
to_sector = "lo/LOWS_APP"
```

## `releases`
### `releases`

If traffic is:

Expand All @@ -103,15 +114,68 @@ If traffic is:
- `"F"`: fully released
- `null`: not released

## `remarks`
### `remarks`

Further remarks for more specific releases or conditions.

## `vertical`
### `vertical`

Boolean value if the agreement specifies a silent vertical transfer.

## `from_sector`/`to_sector`
### `from_sector`/`to_sector`

Sectors from and to which traffic is transferred, identified by vatglasses file
and key `"file/ID"`, i.e. `"ed/ZUG"`.

## Library Usage

The code uses [uv](https://docs.astral.sh/uv) for dependency management and to easily
facilitate the use of scripts to check and combine data.

### Setup

To install dependencies and setup your environment:

```bash
uv sync --all-extras
```

### Data Checks

To run checks on data:

```bash
uv run loa_check
```

### Combining Data

To run the data combiner:

```bash
uv run loa_combine
```

### Tests

To run tests:

```bash
uv run pytest tests
```

### Lints

To run lints:

```bash
uv run ruff check
```

### Formatter

To run formatter:

```bash
uv run ruff format
```
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[project]
name = "loa"
version = "0.1.0"
description = "Library for interacting with VATSIM LoA data"
authors = [{ name = "Robin Gloster", email = "[email protected]" }, { name = "Leon Kleinschmidt" }]
license = { file = "LICENSE-code" }
readme = "README.md"
requires-python = ">=3.12"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Games/Entertainment :: Simulation",
"Topic :: Software Development :: Libraries :: Python Modules",
]

dependencies = ["pydantic>=2.10.2", "regex>=2024.11.6", "requests>=2.32.3"]

[project.scripts]
loa_combine = "loa:combine"
loa_check = "loa:check"

[dependency-groups]
dev = ["pyright>=1.1.389", "pytest>=8.3.3", "pytest-cov>=6.0.0", "ruff>=0.8.0"]

[tool.pytest.ini_options]
addopts = ["--cov-report=term", "--cov-report=xml:cov.xml", "--cov=loa"]
testpaths = ["tests"]

[tool.ruff]
line-length = 100
target-version = "py312"
preview = true

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"C90", # mccabe
"I", # isort
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"PYI", # flake8-pyi
"Q", # flake8-quotes
"SIM", # flake8-simplify
"TCH", # flake8-typechecking
"PTH", # flake8-use-pathlib
"UP", # pyupgrade
"RUF", # ruff-specific
"TRY", # tryceratops
"FURB", # refurb
]
ignore = ["COM812"]

[tool.pyright]
include = ["src/loa", "tests"]
pythonVersion = "3.12"
typeCheckingMode = "strict"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Loading

0 comments on commit c97f26d

Please sign in to comment.