pyopensky 2.19__tar.gz → 2.20__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. pyopensky-2.20/.agents/skills/pyopensky/SKILL.md +32 -0
  2. pyopensky-2.20/.agents/skills/pyopensky/references/downloads.md +133 -0
  3. pyopensky-2.20/.agents/skills/pyopensky/references/querying.md +139 -0
  4. pyopensky-2.20/.agents/skills/pyopensky/references/sources.md +70 -0
  5. pyopensky-2.20/.agents/skills/pyopensky-dev/SKILL.md +24 -0
  6. pyopensky-2.20/.agents/skills/pyopensky-dev/references/development.md +75 -0
  7. pyopensky-2.20/.agents/skills/pyopensky-dev/references/validation.md +98 -0
  8. {pyopensky-2.19 → pyopensky-2.20}/.github/workflows/run_tests.yml +7 -16
  9. pyopensky-2.19/readme.md → pyopensky-2.20/PKG-INFO +73 -0
  10. pyopensky-2.20/agents.md +18 -0
  11. {pyopensky-2.19 → pyopensky-2.20}/docs/source/conf.py +5 -0
  12. {pyopensky-2.19 → pyopensky-2.20}/docs/source/rebuild.rst +1 -1
  13. pyopensky-2.20/docs/source/trino.rst +14 -0
  14. {pyopensky-2.19 → pyopensky-2.20}/docs/source/trino_advanced.rst +219 -1
  15. pyopensky-2.20/pyproject.toml +69 -0
  16. pyopensky-2.19/PKG-INFO → pyopensky-2.20/readme.md +43 -30
  17. {pyopensky-2.19 → pyopensky-2.20}/scripts/benchmark_trino_routes.py +5 -2
  18. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/api.py +50 -3
  19. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/config.py +5 -2
  20. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/decoders/pymodes.py +1 -1
  21. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/decoders/rs1090.py +1 -21
  22. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/rest.py +18 -23
  23. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/schema.py +265 -39
  24. pyopensky-2.20/src/pyopensky/schema_dev.py +66 -0
  25. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/time.py +2 -2
  26. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/trino.py +624 -107
  27. pyopensky-2.20/tests/data/readsb_schema.json +90 -0
  28. pyopensky-2.20/tests/test_config.py +39 -0
  29. pyopensky-2.20/tests/test_raw_schema.py +258 -0
  30. pyopensky-2.20/tests/test_readsb_schema.py +213 -0
  31. pyopensky-2.20/tests/test_rebuild_rs1090.py +55 -0
  32. pyopensky-2.20/tests/test_source_history.py +366 -0
  33. pyopensky-2.20/tests/test_trino_auth.py +268 -0
  34. pyopensky-2.20/tests/test_trino_cancellation.py +159 -0
  35. pyopensky-2.20/tests/test_trino_dev.py +103 -0
  36. {pyopensky-2.19 → pyopensky-2.20}/tests/test_trino_offline.py +410 -2
  37. pyopensky-2.20/tests/test_trino_progress.py +156 -0
  38. pyopensky-2.20/tests/test_typing_compat.py +216 -0
  39. pyopensky-2.20/uv.lock +3374 -0
  40. pyopensky-2.19/agents.md +0 -21
  41. pyopensky-2.19/docs/source/trino.rst +0 -8
  42. pyopensky-2.19/pyproject.toml +0 -81
  43. pyopensky-2.19/uv.lock +0 -4790
  44. {pyopensky-2.19 → pyopensky-2.20}/.gitattributes +0 -0
  45. {pyopensky-2.19 → pyopensky-2.20}/.github/dependabot.yml +0 -0
  46. {pyopensky-2.19 → pyopensky-2.20}/.github/renovate.json5 +0 -0
  47. {pyopensky-2.19 → pyopensky-2.20}/.github/workflows/build-docs.yml +0 -0
  48. {pyopensky-2.19 → pyopensky-2.20}/.github/workflows/pypi_publish.yml +0 -0
  49. {pyopensky-2.19 → pyopensky-2.20}/.gitignore +0 -0
  50. {pyopensky-2.19 → pyopensky-2.20}/docs/.gitignore +0 -0
  51. {pyopensky-2.19 → pyopensky-2.20}/docs/Makefile +0 -0
  52. {pyopensky-2.19 → pyopensky-2.20}/docs/make.bat +0 -0
  53. {pyopensky-2.19 → pyopensky-2.20}/docs/source/_static/main_stylesheet.css +0 -0
  54. {pyopensky-2.19 → pyopensky-2.20}/docs/source/credentials.rst +0 -0
  55. {pyopensky-2.19 → pyopensky-2.20}/docs/source/index.rst +0 -0
  56. {pyopensky-2.19 → pyopensky-2.20}/docs/source/installation.rst +0 -0
  57. {pyopensky-2.19 → pyopensky-2.20}/docs/source/rest.rst +0 -0
  58. {pyopensky-2.19 → pyopensky-2.20}/license.txt +0 -0
  59. {pyopensky-2.19 → pyopensky-2.20}/scripts/decode_pymodes.py +0 -0
  60. {pyopensky-2.19 → pyopensky-2.20}/scripts/decode_rs1090.py +0 -0
  61. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/__init__.py +0 -0
  62. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/decoders/__init__.py +0 -0
  63. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/decoders/base.py +0 -0
  64. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/py.typed +0 -0
  65. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/rebuild.py +0 -0
  66. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/s3.py +0 -0
  67. {pyopensky-2.19 → pyopensky-2.20}/src/pyopensky/tzdata.py +0 -0
  68. {pyopensky-2.19 → pyopensky-2.20}/tests/test_rebuild.py +0 -0
  69. {pyopensky-2.19 → pyopensky-2.20}/tests/test_rebuild_pymodes.py +0 -0
  70. {pyopensky-2.19 → pyopensky-2.20}/tests/test_rest.py +0 -0
  71. {pyopensky-2.19 → pyopensky-2.20}/tests/test_s3.py +0 -0
  72. {pyopensky-2.19 → pyopensky-2.20}/tests/test_trino.py +0 -0
  73. {pyopensky-2.19 → pyopensky-2.20}/tests/test_tzdata.py +0 -0
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: pyopensky
3
+ description: Write and operate OpenSky queries with PyOpenSky. Read before choosing tables, downloading flight/state-vector/raw/ADS-C/MLAT/DF18 data, composing SQLAlchemy expressions or subqueries, or planning cached, bounded and restartable Trino downloads. Use traffic for postprocessing.
4
+ ---
5
+
6
+ # PyOpenSky querying workflows
7
+
8
+ Read the relevant references **before constructing or executing a query**:
9
+
10
+ - `references/querying.md` — provided methods first; automatic hour/day bounds; keys required only when writing custom scans. Read first for every new query.
11
+ - `references/sources.md` — Python schema definitions, identifiers, native units, sparse fields, timestamps and version boundaries.
12
+ - `references/downloads.md` — credential configuration, built-in caching, bounded downloads, monitoring, cancellation, retained outputs and traffic postprocessing.
13
+
14
+ ## Operating rules
15
+
16
+ - **Use the provided functions first.** `history()`, `history_adsc()`, `history_mlat()`, `history_df18()`, `rawdata()`, `flarm()` and `flightlist()` already construct time and partition predicates from start/stop. The partition key is usually **`hour`**; flight tables use **`day`**. Do not reproduce these checks or bounds around a normal helper call.
17
+ - Use `Trino.query()` only when the provided functions cannot express the requirement. Unlike the helpers, it does not add bounds: each custom scan, including independent inner scans, needs its own observation/flight-time AND hour/day predicates. Use the actual model's identity field (`icao24`, source `hex`, or DF18 `address`).
18
+ - **Leave `cached=True` (the default). It should almost never be set to False.** Do not bypass the cache to retry, inspect or validate an already downloaded query. `cached=False` can delete the matching cache file and force another live query; use it only for a specifically justified, user-approved refresh. Do not implement a second cache, transport, retry loop or token-refresh mechanism.
19
+ - A bounding box, airport, callsign, aircraft filter or LIMIT does not replace partition bounds or guarantee a cheap scan. Inspect custom SQL before execution; expensive validation queries also need bounds and authorization.
20
+ - Read `src/pyopensky/schema.py` (and `schema_dev.py` for experimental DF18) before inventing fields or types. Use the default result columns for ordinary downloads; `selected_columns` is an available option for a demonstrated projection/aggregation need, not a routine recommendation.
21
+ - Check the installed version and actual signatures. Merged code is not necessarily released; do not silently replace the user's environment to make an example work.
22
+ - Help users configure credentials in PyOpenSky's `settings.conf` rather than defaulting to browser login for routine production JWT access. Follow `references/downloads.md`; keep secrets out of chat/logs and let the existing client acquire/refresh JWTs. Other endpoints may require OAuth; do not start an unexpected browser flow.
23
+ - Inspect retained files first. Preserve raw observations and native units; do not silently normalize, thin, deduplicate, fill, resample or redownload them.
24
+ - After downloading, use [traffic](https://traffic-viz.github.io/) and its Agent Skill for ALL trajectory postprocessing: source-aware adaptation, segmentation, filtering, resampling, events, analysis and maps. Check adapter support and units; not every PyOpenSky source has a traffic wrapper.
25
+ - Run Python through `uv run script.py` (or `uv run -`), not a global interpreter. Reuse the project's environment.
26
+ - Keep reusable procedures here and dataset-specific queries/manifests in the user's project. Report exact output paths, coverage, schema, query IDs, validation evidence and untested assumptions.
27
+
28
+ ## Scope and discovery
29
+
30
+ PyOpenSky retrieves pandas DataFrames; it is not a trajectory-cleaning framework. For library changes, also read the `pyopensky-dev` skill.
31
+
32
+ These Markdown files are agent-facing repository guidance, not a website guide. Without a checkout, fetch the [query skill](https://github.com/open-aviation/pyopensky/blob/master/.agents/skills/pyopensky/SKILL.md) and its relative references from the appropriate repository revision; do not assume master matches the installed package.
@@ -0,0 +1,133 @@
1
+ # Downloads, caching and postprocessing
2
+
3
+ ## Help configure credentials before relying on browser login
4
+
5
+ For routine production access using JWT, suggest putting credentials in
6
+ PyOpenSky's **`settings.conf`**, rather than repeatedly relying on a browser
7
+ login. Help the user complete the setup, not just react to an authentication
8
+ error. Read `docs/source/credentials.rst` and `src/pyopensky/config.py` for the
9
+ current configuration contract.
10
+
11
+ 1. Establish which endpoint/authentication mode they intend to use and whether
12
+ OpenSky has granted their account historical-data access. Explain how to
13
+ request it if needed; credentials alone do not grant database permissions.
14
+ 2. Locate the file using `pyopensky.config.opensky_config_file` (or its parent
15
+ `opensky_config_dir`), not a guessed OS-specific path. Set cache-preservation
16
+ flags before diagnostic imports. Print the path, never credential values.
17
+ 3. Ask the user to enter their credentials locally in that file. Do not ask for
18
+ passwords or JWTs in chat, write them to scripts, or overwrite existing
19
+ settings. Restrict access to the file appropriately.
20
+
21
+ The standard shared credential fields are:
22
+
23
+ ```ini
24
+ [default]
25
+ username = YOUR_OPENSKY_USERNAME
26
+ password = YOUR_OPENSKY_PASSWORD
27
+ ```
28
+
29
+ The current code also accepts a Trino-specific section when separate credentials
30
+ are needed:
31
+
32
+ ```ini
33
+ [trino]
34
+ username = YOUR_TRINO_USERNAME
35
+ password = YOUR_TRINO_PASSWORD
36
+ ```
37
+
38
+ `client_id` and `client_secret` in `[default]` are for the REST API, not a
39
+ substitute for the Trino username/password fields. Trino-specific settings and
40
+ environment variables can take precedence over shared defaults; fallback can
41
+ also use traffic configuration and environment variables. Inspect the current
42
+ resolution code without exposing secrets instead of overwriting a working setup.
43
+ Configuration/credential values are read during import; restart the relevant
44
+ process after editing them.
45
+
46
+ When JWT access is detected or intended, shepherd the user through this setup:
47
+ check that required values are present (not their contents), explain rejected
48
+ credentials versus missing database permissions, and direct them back to account
49
+ activation/settings as appropriate. Let `Trino` acquire, refresh and retry tokens
50
+ through its implemented flow. Do not paste a JWT into code or create another
51
+ token-refresh loop. The client can fall back to browser OAuth if JWT setup fails;
52
+ explain the cause rather than repeatedly triggering an unexpected browser.
53
+
54
+ Use `Trino(host=..., catalog=..., schema=..., auth=...)` and existing credentials.
55
+ Other endpoints may genuinely require interactive OAuth; do not force JWT there.
56
+ Explain and obtain approval before interactive login or a large live scan.
57
+
58
+ ## Reuse the client and leave the cache enabled
59
+
60
+ `Trino.query()` already supplies transport, retries, streaming, progress, query
61
+ URLs, cancellation and result caching. The convenience functions reuse it.
62
+ Do not reproduce these with requests/httpx, direct cursor loops, a second cache
63
+ or custom signal handlers. Check the installed version before relying on newer
64
+ progress/cancellation behaviour.
65
+
66
+ **Keep `cached=True`, its default. This parameter should almost never be False.**
67
+ An existing cached result should be reused for retries, inspection and routine
68
+ validation. Set `cached=False` only for a specifically justified, user-approved
69
+ fresh download: it can DELETE the matching prior cache file as well as bypass
70
+ it. Do not use it as a generic debugging switch.
71
+
72
+ Current cache keys include compiled SQL/parameters and endpoint/catalog/schema;
73
+ non-default session properties are also included. Results are cached only once
74
+ the entire result arrives. Streaming is not partial-result resume or a
75
+ constant-memory DataFrame pipeline: budget memory for the complete result.
76
+
77
+ Imports can purge expired caches. Before tests/diagnostics that must preserve
78
+ existing files, set `OPENSKY_CACHE_NO_EXPIRE=1` (and
79
+ `TRAFFIC_CACHE_NO_EXPIRE=1` when traffic is involved). Inspect cache configuration
80
+ instead of assuming a path/retention policy. Never delete caches or raw files
81
+ without authorization.
82
+
83
+ ## Restartable outputs, not another cache
84
+
85
+ Inspect existing output and requested coverage before downloading. Choose call
86
+ size from a representative sample, available memory/disk and restart cost.
87
+ Daily files are a starting point, not a universal rule. Hourly partition bounds
88
+ do not split a history call into hourly requests. Do not thin observations at
89
+ download to compensate for an oversized query.
90
+
91
+ Keep raw date/window-named files separate from derived outputs. A small project
92
+ manifest can record source, endpoint, window, filters, code/library revision,
93
+ units, query IDs and completed outputs. Record valid empty intervals explicitly:
94
+ convenience methods can return None; `query()` returns an empty DataFrame. Do not
95
+ retry a valid empty result indefinitely or fabricate placeholder trajectories.
96
+
97
+ Write to a temporary path, validate, then atomically promote it. Resume only if
98
+ schema, provenance and coverage match; existence alone is not completion. Raw
99
+ output files are application records, not another query cache.
100
+
101
+ ## Monitoring and cancellation
102
+
103
+ Report the emitted query URL/ID. Distinguish server work/input bytes, returned
104
+ rows, downloading and completed local output. Server progress does not predict
105
+ the end of a streaming download.
106
+
107
+ Run long jobs on an approved machine that stays up, detached from fragile
108
+ sessions, with a run-owned PID and log. Avoid broad pkill patterns. In current
109
+ code, Ctrl-C/SIGTERM can cancel an active server query; SIGKILL cannot run
110
+ cleanup. Verify the server stopped rather than inferring it from a dead process.
111
+ For leftovers, use an endpoint/auth-aware operational tool or the Trino UI with
112
+ explicit authorization and precise ownership. Do not cancel all of a user's
113
+ queries or blindly copy a production-only helper accessing private JWT state.
114
+
115
+ ## Validation and the traffic handoff
116
+
117
+ Check path, metadata/row count, schema, correct identifier fields, coverage and
118
+ task-relevant nulls. Start with Parquet metadata and bounded column/sample reads,
119
+ not loading gigabytes merely to inspect them. Sparse optional fields are not
120
+ automatically corruption. Flight counts and sampling cadence require actual
121
+ trajectory/operation semantics, not just successful download checks.
122
+
123
+ Use **[traffic](https://traffic-viz.github.io/)** for all trajectory
124
+ postprocessing after download. Its [OpenSky guide](https://traffic-viz.github.io/data_sources/opensky_db.html)
125
+ covers native retrieval workflows. Read the installed traffic Agent Skill (or
126
+ `.agents/skills/traffic/SKILL.md` in the traffic checkout) before adapting,
127
+ segmenting, filtering, resampling, extracting events or plotting.
128
+
129
+ Load retained formats with `Traffic.from_file()` where supported, or use an
130
+ actual source-aware adapter. Preserve provenance and native-unit semantics.
131
+ Use Traffic/Flight operations rather than pandas grouping, custom interpolation
132
+ or manual map primitives. Do not silently fetch missing observations from a
133
+ derived-processing stage.
@@ -0,0 +1,139 @@
1
+ # Query methods and required keys
2
+
3
+ ## Start with the provided functions
4
+
5
+ Use `Trino` for historical downloads. Prefer `flightlist()` for flight metadata,
6
+ `history()` for ADS-B state vectors, `history_adsc()` for ADS-C data,
7
+ `history_mlat()` for MLAT data, `history_df18()` for DF18, `rawdata()` for
8
+ supported raw Mode S tables, and `flarm()` for raw FLARM. ADS-C and MLAT are
9
+ sources; their history functions are convenient ways to download their data,
10
+ not separate kinds of "simplified" data. Check the Python models if a task needs
11
+ fields beyond the helpers' returned columns.
12
+
13
+ Use the supported `rebuild()`/decoder facilities when message decoding is part
14
+ of retrieval. Do not write another decoder. Use `REST` for its supported REST
15
+ endpoints, not as a historical Trino substitute.
16
+
17
+ **Most partitions use `hour`; flight tables use `day`.** The provided functions
18
+ already build and apply the corresponding time/partition predicates from
19
+ `start` and `stop`. Use them rather than rebuilding those checks in application
20
+ code. The explicit-key recipes below are for custom scans through `query()`,
21
+ not extra work required around normal helper calls.
22
+
23
+ Check actual signatures. ADS-C, MLAT and DF18 helpers do not accept receiver or
24
+ flight-join options. Do not pass obsolete `other_params` or `date_delta`, assume
25
+ unknown kwargs are implemented, or assume traffic wraps every PyOpenSky method.
26
+
27
+ For an ordinary download, keep the default result columns and default cache:
28
+
29
+ ```python
30
+ from pyopensky.schema import StateVectorsData4 as SV
31
+ from pyopensky.trino import Trino
32
+
33
+ data = Trino().history(
34
+ "2025-04-07 07:40",
35
+ "2025-04-07 07:43",
36
+ SV.onground == False,
37
+ icao24="38ed1b",
38
+ )
39
+ if data is not None:
40
+ data.to_parquet("raw-state-vectors.parquet")
41
+ ```
42
+
43
+ `selected_columns` exists for a specific projection or aggregate requirement.
44
+ Do not add it routinely: dropping fields can make downstream use harder without
45
+ solving partition-scan cost. The functions already cache results; leave
46
+ **`cached=True`**. Do not wrap them in a second cache, HTTP client, connection
47
+ factory or token-refresh implementation.
48
+
49
+ ## Keys required when a custom scan is really necessary
50
+
51
+ Read `src/pyopensky/schema.py` and `src/pyopensky/schema_dev.py`; the model fields
52
+ and SQLAlchemy types are already defined there. For each direct `query()` scan:
53
+
54
+ - `StateVectorsData4`: observation `time` AND partition `hour`; identifier `icao24`.
55
+ - `ReadsbAdscStateVectors` / `ReadsbMlatStateVectors`: `time` AND `hour`; `icao24`.
56
+ - `ReadsbAdscState` / `ReadsbMlatState`: `time` AND `hour`; source `hex`, not a nonexistent `icao24` column.
57
+ - Raw Mode S models (ACAS, all-call, identification, operational status, position, rollcall replies and velocity): `mintime` AND `hour`; `icao24`. `maxtime` is not a partition key.
58
+ - `Df18Data4`: `mintime` AND `hour`; `address`. Retain `cf` and `addresstype` when interpreting it.
59
+ - `FlightsData4` / `FlightsData5`: the intended flight-time condition (`firstseen`, `lastseen` or explicit interval overlap) AND `day`; `icao24`. `flightlist()` filters firstseen with a departure-airport filter and otherwise lastseen, including routes-only requests. Do not silently substitute overlap semantics.
60
+ - `FlarmRaw`: `timestamp` AND `hour`; receiver field `sensorname`. Do not invent a decoded aircraft `icao24` field in this model.
61
+
62
+ Time/partition predicates constrain scans. Aircraft, route, address, receiver
63
+ and geographic filters are task-specific selectors, not mandatory restrictions
64
+ for every download. A partition key is not a unique observation ID.
65
+
66
+ A custom half-open hourly scan needs `time >= start`, `time < stop`,
67
+ `hour >= start.floor("1h")` and `hour < stop.ceil("1h")`. Substitute `mintime`
68
+ or `timestamp` as appropriate. For daily scans, use corresponding day bounds.
69
+ Reject reversed windows. Do not assume identical helper endpoint inclusion:
70
+ legacy `history()`, `rawdata()` and `flarm()` include stop; the three
71
+ source-specific history helpers exclude it. Define chunk boundaries explicitly
72
+ rather than silently deduplicating results.
73
+
74
+ ## ADS-C: simple helper first, custom payload only if needed
75
+
76
+ For ordinary ADS-C retrieval, the existing helper is sufficient; it supplies the
77
+ bounds and uses the built-in cache:
78
+
79
+ ```python
80
+ from pyopensky.trino import Trino
81
+
82
+ data = Trino().history_adsc(
83
+ "2025-04-07 07:40", "2025-04-07 07:43", icao24="38ed1b"
84
+ )
85
+ ```
86
+
87
+ Only if the task needs a full-payload field such as `seen_pos`, which is not in
88
+ the helper's result, use the existing full model with `query()`:
89
+
90
+ ```python
91
+ import pandas as pd
92
+ from sqlalchemy import select
93
+ from pyopensky.schema import ReadsbAdscState as Source
94
+ from pyopensky.trino import Trino
95
+
96
+ start = pd.Timestamp("2025-04-07 07:40Z")
97
+ stop = pd.Timestamp("2025-04-07 07:43Z")
98
+ statement = select(Source.time, Source.hex, Source.seen_pos).where(
99
+ Source.time >= start,
100
+ Source.time < stop,
101
+ Source.hour >= start.floor("1h"),
102
+ Source.hour < stop.ceil("1h"),
103
+ Source.hex == "38ed1b",
104
+ )
105
+ # Inspect before executing; no database access occurs here.
106
+ print(statement)
107
+ # data = Trino().query(statement) # Existing transport and default cache.
108
+ ```
109
+
110
+ Independent inner scans need their OWN observation-time and partition bounds.
111
+ The convenience method's bounded flight alias constrains that flight scan, not
112
+ other state-vector/message scans inside your subqueries. Flight-overlap queries
113
+ may need an earlier departure partition window: use actual `day` semantics and
114
+ operation coverage rather than blindly clipping to the state-vector window.
115
+
116
+ ## Composition, cost and acceptance
117
+
118
+ Pass SQLAlchemy conditions positionally. Use mapped attributes, labels and
119
+ functions rather than interpolating untrusted SQL strings. `history()` supports
120
+ composed projections when needed and adapts flight expressions to its bounded
121
+ join. Explicit `correlate(FlightsData4)` can request it; implicit correlation
122
+ follows an existing immediate outer binding. Independent subqueries, local
123
+ bindings, aliases and `correlate(None)` must retain their intended scope.
124
+ See `docs/source/trino_advanced.rst` for the detailed correlation examples.
125
+
126
+ Use `routes=[(departure, arrival), ...]` for exact directed pairs. Separate
127
+ airport lists admit Cartesian combinations; per-route loops repeat scans.
128
+ `history()` clips state vectors to the requested window rather than retrieving
129
+ complete overnight flights.
130
+
131
+ One history call submits one query for its whole window, not per hour. A small
132
+ box or LIMIT does not guarantee little input scanning. Measure scan statistics
133
+ separately from returned rows and download bytes. Do not routinely narrow the
134
+ selected columns merely as a presumed scan optimization.
135
+
136
+ Validate cheaply first: model metadata and compiled Trino SQL, then offline
137
+ synthetic cases if needed. A zero-row probe or tiny bounded live sample requires
138
+ appropriate authorization. `LIMIT 0` tests shape/planning, not coverage, units
139
+ or all runtime behaviour. Avoid broad COUNT or EXPLAIN ANALYZE for validation.
@@ -0,0 +1,70 @@
1
+ # Source semantics and compatibility
2
+
3
+ ## Read the Python models, not a second schema specification
4
+
5
+ The fields and types already live in **`src/pyopensky/schema.py`**; experimental
6
+ DF18 is in **`src/pyopensky/schema_dev.py`**. Read the actual classes and column
7
+ docstrings before choosing fields, identifying partition keys or interpreting
8
+ values. `src/pyopensky/trino.py` defines helper signatures and which model each
9
+ function uses. Do not invent another schema or infer it from sample column names.
10
+
11
+ `history_adsc()` and `history_mlat()` are convenient functions for downloading
12
+ ADS-C and MLAT data. Their current implementation uses the `ReadsbAdscStateVectors`
13
+ and `ReadsbMlatStateVectors` models; the full `ReadsbAdscState` and
14
+ `ReadsbMlatState` models expose additional source fields. This distinction is an
15
+ implementation/schema detail, not a reason to describe ADS-C/MLAT themselves as
16
+ "simplified views" or send ordinary downloads straight to custom SQL.
17
+
18
+ ## Check the actual version and capabilities
19
+
20
+ Verify the installed distribution, checkout and method signatures. Read the
21
+ Python requirement from `pyproject.toml` and check actual capabilities rather
22
+ than keeping historical version comparisons here. A checkout's version string
23
+ alone does not prove that its code matches a released wheel. Do not silently
24
+ replace the user's environment.
25
+
26
+ `history_df18()` is the canonical new name; unreleased `df18_messages()` has no
27
+ compatibility alias. Endpoint availability/permissions can differ. The model in
28
+ `schema_dev.py` remains experimental.
29
+
30
+ ## Interpret fields without inventing observations
31
+
32
+ PyOpenSky preserves source-native names and measurement units. The Python models
33
+ are the source of truth; these reminders highlight differences that are easy to
34
+ miss when similarly named columns appear together:
35
+
36
+ - ADS-B `StateVectorsData4`: altitudes in metres, velocity and vertical rate in metres/second, angles in degrees.
37
+ - ADS-C readsb models: altitude in feet, speed in knots, vertical rate in feet/minute. Returned `baroaltitude`, `velocity` and `vertrate` names do NOT imply ADS-B units.
38
+ - MLAT helper model: `time`, `icao24`, `lat`, `lon`, `hour`. Do not synthesize altitude, speed or callsign. The full model also exposes source `hex` and `messages`.
39
+ - DF18: retain address classification and message kind; do not identify every `address` as an ICAO24 transponder or assume uniform altitude/speed semantics across message kinds. Check metadata before conversion.
40
+ - Raw models: retain reception/aggregation fields and use supported decoder facilities. ORM `hour`/`day` primary-key hints are NOT evidence of observation uniqueness.
41
+
42
+ Inspect result dtypes. Integer timestamp decorators return UTC pandas timestamps
43
+ (SQL NULL becomes NaT); floating observation columns such as readsb `time` and
44
+ raw-message `mintime` retain fractional epoch seconds. Do not guess epoch units,
45
+ truncate fractions, or add redundant epoch columns.
46
+
47
+ Record time, last contact and position-update time differ. ADS-C `seen` and
48
+ `seen_pos` are ages in seconds; `gps_ok_before` is epoch seconds. If freshness
49
+ analysis needs fields not returned by the helper, query the full model with its
50
+ own bounds. Preserve nullable arrays and nested `last_position`. No automatic
51
+ freshness correction or resampling takes place.
52
+
53
+ Assume observations are usable unless inspection demonstrates a concrete issue.
54
+ Do not speculatively strip callsigns, normalize identifiers, cast, fill positions,
55
+ filter coordinates or deduplicate. Reuse implemented field/filter handling;
56
+ explain any observed problem and its narrowly scoped correction downstream.
57
+
58
+ ## Hand off to traffic
59
+
60
+ Retain raw results and provenance, then use [traffic](https://traffic-viz.github.io/)
61
+ and its Agent Skill (`.agents/skills/traffic/SKILL.md` in the traffic checkout,
62
+ or the installed skill) for all trajectory postprocessing. Check actual adapter
63
+ support and define any
64
+ source-specific conversion once at that boundary. In particular, do not pass
65
+ ADS-C aviation-unit values through a generic ADS-B SI conversion or assume a
66
+ traffic wrapper exists for every new method.
67
+
68
+ For raw data requiring decoding, use supported PyOpenSky decoder/rebuild APIs,
69
+ then Traffic/Flight operations. Retaining/inspecting raw DataFrames is not a
70
+ reason to create another trajectory-processing framework here.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: pyopensky-dev
3
+ description: Develop and review PyOpenSky. Read before modifying SQL generation, source schemas or history methods, authentication, caching, cancellation, decoders, dependency compatibility, tests or CI. Preserve public query composition and source-native semantics; validate offline before authorized live probes.
4
+ ---
5
+
6
+ # PyOpenSky development workflows
7
+
8
+ Read repository `agents.md` first. Before changing public query behaviour, also read the querying skill (`pyopensky`) and its references.
9
+
10
+ - `references/development.md` — architecture, API contracts, schema/source additions and SQLAlchemy query semantics.
11
+ - `references/validation.md` — regression-first testing, safe live validation, dependency/CI checks and contribution boundaries.
12
+
13
+ ## Operating rules
14
+
15
+ - Inspect current source, tests and documentation. Reproduce the defect against the actual baseline; inherited reports are leads, not proof.
16
+ - Preserve the provided query/download/cache facilities. Do not add a second transport, auth stack, cache or postprocessing framework to solve a local problem.
17
+ - Preserve public composition, source-native names/units, sparse fields and None/empty-result contracts. Put trajectory postprocessing in traffic, with an explicit source-aware adapter when necessary.
18
+ - Prefer existing functions: they already apply time and partition bounds (usually `hour`, `day` for flights). New/custom scans need their own bounds; alias adaptation must not introduce unbounded physical flight-table scans or rewrite independent subqueries. Keep `cached=True` unless a specific refresh is justified and approved.
19
+ - Test query semantics with synthetic data and compiled Trino SQL before requesting live access. Never execute a known unbounded regression query on production.
20
+ - Cover optional decoder paths in typing/tests. Fix contracts precisely instead of excluding files or adding broad attribute suppressions.
21
+ - Set cache-preservation environment flags before imports; run Python with `uv run`.
22
+ - Keep unrelated source/staged changes, raw data, caches and local analysis artifacts intact. No commit, push, merge, version bump, tag or release without the applicable explicit approval. Committing a fix does not authorize publishing it.
23
+
24
+ These Markdown references are agent-facing repository guidance, not a website guide. Without a checkout, fetch the [developer skill](https://github.com/open-aviation/pyopensky/blob/master/.agents/skills/pyopensky-dev/SKILL.md) and its relative files from the appropriate revision. Keep reusable guidance evidence-based; store task-specific investigations outside the skill.
@@ -0,0 +1,75 @@
1
+ # Developing query and source contracts
2
+
3
+ ## Architecture and reuse
4
+
5
+ Inspect the current code rather than maintaining another specification:
6
+
7
+ - `src/pyopensky/api.py`: backend contracts.
8
+ - `src/pyopensky/trino.py`: query construction, transport and lifecycle.
9
+ - `src/pyopensky/schema.py` / `schema_dev.py`: modeled fields, SQLAlchemy types and source semantics.
10
+ - `src/pyopensky/config.py`: credentials, configuration resolution and cache handling.
11
+ - `src/pyopensky/decoders/` and `rebuild.py`: supported message decoding.
12
+ - REST/S3 implementations when changing those backends; do not extrapolate Trino behaviour to them.
13
+
14
+ Reuse provided functions and `Trino.query()` for execution/caching. Existing
15
+ helpers apply time/partition bounds (usually `hour`, `day` for flights); reuse
16
+ the bounded helper where appropriate rather than reproducing checks. Keep
17
+ `cached=True` by default, not a second cache or transport.
18
+
19
+ Expose only filters supported by the actual source schema. Do not swallow
20
+ unsupported kwargs, invent fields, or force new sources through ADS-B assumptions.
21
+ Generic query() returns a DataFrame; convenience methods can return None for no
22
+ matching rows. Preserve that distinction and endpoint inclusion unless an API
23
+ change is explicitly agreed/documented.
24
+
25
+ Read the query skill's required-key/source references before changing generation.
26
+ Windows, partitions, identifiers, native units, nullable/nested fields and
27
+ sparse outputs are public contracts. Post-download trajectory operations belong
28
+ in traffic with an explicit source-aware adapter, not another cleaning framework.
29
+
30
+ ## SQLAlchemy composition and scope
31
+
32
+ Use SQLAlchemy expression coercion/normalization and adapters, not assumptions
33
+ about one expression shape. Labels, functions, mapped descriptors, scalar
34
+ subqueries and EXISTS are legitimate compositions. Assuming every projection
35
+ has `.class_` or `__clause_element__()` caused a real regression. Use appropriate
36
+ public expression interfaces in annotations.
37
+
38
+ Reference the bounded flight join instead of adding another physical flight
39
+ table. Preserve route pairs, requested-window clipping, flight bounds and labels.
40
+ Check projections as well as WHERE conditions when inferring joins.
41
+
42
+ Correlation is lexical, not "replace every flight column recursively":
43
+
44
+ - Explicit `correlate(FlightsData4)` can refer to the bounded outer alias and request its join, including across intervening SELECTs.
45
+ - Implicit correlation follows the immediate existing outer SELECT binding; a UNION wrapper does not add a SELECT scope.
46
+ - `correlate(None)`, `correlate_except()` and independent queries retain their SQLAlchemy meanings and their own time/partition predicates.
47
+ - A local physical flight table shadows the outer binding; a differently aliased table does not. A local explicit JOIN cannot be partially removed by correlation.
48
+
49
+ Three private SQLAlchemy correlation metadata reads are currently isolated in
50
+ one helper because no public introspection API exists. Do not spread them through
51
+ the builder or suppress compatibility failures. Keep them covered on upgrades.
52
+
53
+ ## Schemas and new functions
54
+
55
+ Read the existing Python models first. For additions, obtain independent schema
56
+ evidence (authorized metadata or a retained snapshot): table/view names, fields,
57
+ SQL types, widths, nullability, nested shape, partitions, identity semantics, row
58
+ grain and units. Do not generate the expected schema from the tested model.
59
+ Compatibility views and backing stores can differ.
60
+
61
+ Preserve sparse fields. ORM primary-key hints do not justify deduplication.
62
+ RawTable describes a mapped model CLASS as an object exposing SQL descriptors,
63
+ not a record instance. Preserve support for independent/custom models, not only
64
+ a union of built-ins.
65
+
66
+ Check timestamp bind/results, fractions, timezones and NULL/NaT handling rather
67
+ than enforcing a universal representation. Validate ROW/ARRAY decoding with
68
+ synthetic values; column names alone do not prove compatibility.
69
+
70
+ A new function should reuse execution/cache facilities and implement supported
71
+ filters, time/partition predicates, limits and optional projections. Document
72
+ native units, endpoint inclusion, identifiers, missing fields, permissions,
73
+ experimental status and access to extra source fields. Do not imply traffic
74
+ already wraps it. Keep ordinary usage examples simple: provided function,
75
+ default result columns, default cache.
@@ -0,0 +1,98 @@
1
+ # Validation and contribution workflow
2
+
3
+ ## Reproduce first, then validate in layers
4
+
5
+ Record the baseline/environment and reproduce a minimal failure before changing
6
+ code. Distinguish current evidence from older reports/workarounds. Preserve raw
7
+ inputs and unrelated changes.
8
+
9
+ 1. Inspect models and compile with the Trino dialect. Verify FROMs, joins,
10
+ aliases, labels, parameters and bounds for every independent scan. Compilation
11
+ is not execution evidence.
12
+ 2. Execute synthetic offline cases. Existing SQLite fixtures test values and
13
+ cardinality; Trino compilation checks the target SQL. SQLite alone does not
14
+ prove Trino-specific type/function behaviour. Forbid network in these tests.
15
+ 3. Compare schemas against independent snapshots. For protocol changes, check
16
+ concrete/custom model typing and execute an independent custom-model query.
17
+ 4. Only with authorization, use read-only metadata/zero-row probes, then tiny
18
+ bounded samples if needed. Zero-row results do not prove coverage, units or
19
+ every runtime path. Never execute the known unbounded regression or a broad
20
+ COUNT as a test.
21
+ 5. Test type processors with synthetic nested values and native decoders with
22
+ real frames as well as mocks. Distinguish optional-package absence from a
23
+ broken import; a module need not expose `__version__`.
24
+
25
+ Cover joined/unjoined queries, predicates/projections, empty/None results,
26
+ routes and bounds. For subqueries include historical independent windows,
27
+ explicit/implicit correlation, correlate_except/None, nested scopes, aliases,
28
+ UNION branches and local JOINs. Assert values/cardinality as well as SQL: a
29
+ substring test can miss an extra FROM table after a comma.
30
+
31
+ Use existing doubles for auth, cache, cancellation and streaming: expiry margins,
32
+ rejected-token cleanup, endpoint isolation, retry boundaries, partial failures,
33
+ worker cleanup and interruption. Never show credentials or use live queries for
34
+ ordinary unit tests. Mark untested endpoint/OAuth/platform paths explicitly.
35
+
36
+ ## Environment and checks
37
+
38
+ Set preservation flags BEFORE imports and use the repository environment:
39
+
40
+ ```sh
41
+ export OPENSKY_CACHE_NO_EXPIRE=1 TRAFFIC_CACHE_NO_EXPIRE=1
42
+ uv sync --dev --extra rs1090 --extra cartes --extra pymodes
43
+ uv run ruff check
44
+ uv run ruff format --check
45
+ uv run ty check --error-on-warning src tests
46
+ uv lock --check
47
+ ```
48
+
49
+ Read `requires-python` in `pyproject.toml` instead of assuming the published
50
+ release and checkout have identical floors. Use `uv run`, not a global Python
51
+ or unrecorded overlay. Run relevant offline modules first, then the broader
52
+ offline suite. An unrestricted pytest run includes network integration tests;
53
+ do not start them while claiming an offline check.
54
+
55
+ Build HTML docs with warnings treated as errors:
56
+
57
+ ```sh
58
+ uv run sphinx-build -W -b html docs/source docs/build/html
59
+ ```
60
+
61
+ Report when remote intersphinx inventories were disabled.
62
+ Agent Skill Markdown stays in `.agents/skills/`;
63
+ do not duplicate it into a website guide. Check skill-relative links and any
64
+ repository URLs used by docstrings/docs.
65
+
66
+ On dependency upgrades, reassess new diagnostics before applying old advice.
67
+ Fix precise descriptors/types/version contracts rather than excluding files or
68
+ adding broad ignores. Include optional decoder paths in typing and native smoke
69
+ tests. Check Python/platform support and wheel metadata, not just one interpreter.
70
+
71
+ ## CI, evidence and approval
72
+
73
+ The push workflow tests the feature head. `pull_request_target` normally checks
74
+ out the base; do not present it alone as feature-head evidence, or run untrusted
75
+ head code with secrets to fix that. Check SHAs and logs. A green cache job may
76
+ have skipped its live step on a cache hit; claim a cold fill only if it ran.
77
+
78
+ The current CI cache key hashes uv.lock rather than query fixtures/source.
79
+ New queries can therefore need cache work even without a new lockfile. A live
80
+ service failure can block the matrix. Do not weaken assertions or silently skip
81
+ failures to hide unavailable archive examples; refresh verified fixtures and
82
+ retain semantic checks.
83
+
84
+ Keep the library result cache enabled for routine retrieval. Do not casually
85
+ set `cached=False` to rerun an investigation; it may delete a result and force
86
+ a new live query. If testing fresh-query behaviour, use isolated temporary
87
+ cache directories or mocks rather than the user's cache.
88
+
89
+ Use live checks only with appropriate access/approval. Report physical input
90
+ bytes separately from result size. Passing tests/cached integration/zero-row
91
+ probes are not a security audit, production performance proof or acceptance of
92
+ untested development OAuth.
93
+
94
+ Before committing, inspect index/worktree and stage only approved source/tests/
95
+ docs. Keep credentials, captures, reports, inventories, tools and local issue
96
+ trackers out. Preserve unrelated work and never commit directly to master/main.
97
+ Commit/push/merge need applicable explicit approval. Version bump, tag, release
98
+ and PyPI publication are distinct actions, not implied by merge approval.
@@ -14,7 +14,7 @@ jobs:
14
14
  steps:
15
15
  - uses: actions/checkout@v7
16
16
 
17
- - uses: astral-sh/setup-uv@v10.4.0
17
+ - uses: astral-sh/setup-uv@v10.4.1
18
18
  with:
19
19
  enable-cache: true
20
20
 
@@ -29,12 +29,12 @@ jobs:
29
29
  steps:
30
30
  - uses: actions/checkout@v7
31
31
 
32
- - uses: astral-sh/setup-uv@v10.4.0
32
+ - uses: astral-sh/setup-uv@v10.4.1
33
33
  with:
34
34
  enable-cache: true
35
35
 
36
- - run: uv sync --dev --extra rs1090 --extra cartes
37
- - run: uv run ty check src tests
36
+ - run: uv sync --dev --extra rs1090 --extra cartes --extra pymodes
37
+ - run: uv run ty check --error-on-warning src tests
38
38
  - run: uv cache prune --ci
39
39
 
40
40
  fill_cache:
@@ -45,7 +45,7 @@ jobs:
45
45
  with:
46
46
  fetch-depth: 0
47
47
 
48
- - uses: astral-sh/setup-uv@v10.4.0
48
+ - uses: astral-sh/setup-uv@v10.4.1
49
49
  with:
50
50
  enable-cache: true
51
51
 
@@ -80,20 +80,11 @@ jobs:
80
80
  - windows-latest
81
81
  - macos-latest
82
82
  python-version:
83
- - "3.10"
84
- - "3.11"
85
83
  - "3.12"
86
84
  - "3.13"
87
85
  - "3.14"
88
- # `trino` (v0.336.0) depends on `orjson` (v3.11.5)
89
- # which does not support Python 3.14t
90
- # https://github.com/ijl/orjson/issues/591#issuecomment-3160351169
86
+ # Free-threaded Python needs separate optional-decoder validation.
91
87
  # - "3.14t"
92
- exclude:
93
- # greenlet v3.2.4 is not available for Python 3.14t on Windows
94
- # and fails to compile there. Not much we can do about that right now.
95
- - os: windows-latest
96
- python-version: "3.14t"
97
88
  include:
98
89
  - os: ubuntu-latest
99
90
  python-version: "3.13"
@@ -103,7 +94,7 @@ jobs:
103
94
  with:
104
95
  fetch-depth: 0
105
96
 
106
- - uses: astral-sh/setup-uv@v10.4.0
97
+ - uses: astral-sh/setup-uv@v10.4.1
107
98
  with:
108
99
  enable-cache: true
109
100