Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout d'un binding Python pour Transit Model #962

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# This file is autogenerated by maturin v1.7.4
# To update, run
#
# maturin generate-ci github
#
name: Python package

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- name: Install Python dev
run: |
sudo apt-get update
sudo apt-get install -y python3-dev
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter --manifest-path transit_model_python/Cargo.toml
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
steps:
- uses: actions/checkout@v4
- name: Install Python dev
run: |
sudo apt-get update
sudo apt-get install -y python3-dev
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter --manifest-path transit_model_python/Cargo.toml
sccache: 'true'
manylinux: musllinux_1_2
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter --manifest-path transit_model_python/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter --manifest-path transit_model_python/Cargo.toml
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python dev
run: |
sudo apt-get update
sudo apt-get install -y python3-dev
- uses: actions/setup-python@v5
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path transit_model_python/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

# release:
# name: Release
# runs-on: ubuntu-latest
# if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
# needs: [linux, musllinux, windows, macos, sdist]
# permissions:
# # Use to sign the release artifacts
# id-token: write
# # Used to upload release artifacts
# contents: write
# # Used to generate artifact attestation
# attestations: write
# steps:
# - uses: actions/download-artifact@v4
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-path: 'wheels-*/*'
# - name: Publish to PyPI
# if: ${{startsWith(github.ref, 'refs/tags/')}}
# uses: PyO3/maturin-action@v1
# with:
# command: upload
# args: --non-interactive --skip-existing wheels-*/*
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ members = [
"ntfs2netexfr",
"ntfs2ntfs",
"restrict-validity-period",
"transit_model_python"
]

[features]
xmllint = ["proj"]
gtfs = []
parser = []
downloadable = []

[dependencies]
anyhow = "1"
Expand Down Expand Up @@ -67,6 +69,8 @@ walkdir = "2"
wkt = "0.10"
zip = { version = "2", default-features = false, features = ["deflate"] }
git-version = "0.3"
reqwest = { version = "0.12.12", default-features = false, features = ["json"] }
tokio = "1.43.0"

[[test]]
name = "write_netex_france"
Expand All @@ -78,3 +82,6 @@ approx = "0.5"
log = "0.4"
rust_decimal_macros = "1"
testing_logger = "0.1"
mockito = "0.31"
tokio = { version = "1.0", features = ["full", "test-util"] }
futures = "0.3"
51 changes: 51 additions & 0 deletions downloadable_model_graph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
```mermaid
graph TD
A[DownloadableTransitModel] --> B[ModelConfig]
A --> C[NavitiaConfig]
A --> D[Downloader]
A --> E[Arc<RwLock<Model>>]
A --> F[Arc<Mutex<String>>]

subgraph Initialization
G[Start] --> H[initialize_model]
H --> I[get_remote_version]
I --> J[Navitia API]
H --> K[run_download]
K --> L[Downloader]
H --> M[ntfs::read]
end

subgraph Background Updater
N[start_background_updater] --> O[check_and_update]
O --> P[get_remote_version]
O --> Q{Version Newer?}
Q -->|Yes| R[run_download]
Q -->|No| S[Return false]
R --> T[ntfs::read]
T --> U[Atomic Model Swap]
U --> V[Version Update]
end

subgraph External Components
J -->|HTTP GET| W((Navitia Server))
L -->|Storage| X[(S3/File System)]
M --> Y[NTFS Parser]
end

subgraph Concurrency
E -.->|RwLock| Z[Thread-safe Reads]
E -.->|Write Lock| AA[Atomic Updates]
F -.->|Mutex| AB[Version Safety]
N --> AC[Tokio Spawn]
end

style A fill:#f9f,stroke:#333
style B fill:#ccf,stroke:#333
style C fill:#ccf,stroke:#333
style D fill:#cfc,stroke:#333
style J fill:#fcc,stroke:#333
style L fill:#fcc,stroke:#333
style W fill:#cff,stroke:#333
style X fill:#cff,stroke:#333
style Y fill:#cff,stroke:#333
```
Loading
Loading