-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate against a remote schema and by version tag.
Provides the functionality to validate against a remote schema hosted on github by github reference (e.g. master HEAD, version tag, etc.). It also pulls out a "spec" as a class object to make it easier to pass around and abstract the differences between getting a spec from Github vs Local files. This PR also: - formats code per pre-commit - refactors apply_schema_to_df into smaller functions - updates errors and warning to be more helpful (pointing to files, etc) - adds tests for field constraints in constraint_tests.py - adds assert statements to basic_tests.py Closes #25 Closes #26 NOTE: Tests failing due to zephyr-data-specs/GMNS#70
- Loading branch information
Showing
24 changed files
with
923 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,49 @@ | ||
|
||
To come. | ||
# General Architecture of GMNS | ||
|
||
```mermaid | ||
erDiagram | ||
link |o--|{ node : from_node_id | ||
link |o--|{ node : to_node_id | ||
link }|--o| geometry : "is optionally associated with" | ||
link ||--o{ use-group : "is optionally associated with a" | ||
link-tod }|--|| link : "is associated with a" | ||
link-tod }|--|| time-set-definitions : "is associated with a" | ||
node }o--|| zone : "is optionally associated with" | ||
lane }o--|| link : "is part of a" | ||
lane-tod }o--|| lane : "is part of a lane" | ||
lane-tod }o--|| time-set-definitions : "is associated with a" | ||
lane-tod }o--o{ use-group : "is optionally associated with a" | ||
location }o--|| link : "is associated with a" | ||
location }o--|| node : "is associated with a" | ||
location }o--|{ zone : "is optionally associated with a" | ||
location ||--o{ "gtfs.stop_id" : "is optionally associated with a" | ||
segment }o--|{ link : "is associated with a" | ||
segment }o--|{ node : "is associated with a" | ||
segment }o--|{ use-group : "is optionally associated with a" | ||
use-group }|--|{ use-definition : "includes groups of" | ||
``` | ||
|
||
## Signals | ||
|
||
```mermaid | ||
erDiagram | ||
signal_controller |o--|{ signal_coordination : "" | ||
signal_coordination |o--|{ signal_timing_plan : "" | ||
signal_controller |o--|{ signal_timing_plan :"" | ||
signal_phase_mvmt }o--|| signal_controller :"" | ||
signal_phase_mvmt }o--|| movement :"" | ||
signal_phase_mvmt }o--|| link :"" | ||
signal_timing_plan }o--|| signal_controller :"" | ||
signal_timing_plan }o--|{ time_set_definitions :"" | ||
signal_timing_phase }|--|| signal_timing_plan :"" | ||
signal_detector }o--|| link :"" | ||
signal_detector }o--|| node :"" | ||
signal_detector }o--|| signal_controller : "" | ||
movement }o--|| node :"" | ||
movement }o--|| link : "ib_link_id" | ||
movement }o--|| link : "ob_link_id" | ||
movement_tod }o--|| timeday_id : "" | ||
movement_tod }o--|| link : ib_link_id | ||
movement_tod }o--|| link : ob_link_id | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Development Branch GMNS Specification | ||
|
||
Schema under development for General Network Feed Specification. | ||
|
||
## Files in Specification | ||
|
||
GMNS consists of a package of files as defined in the following table. | ||
|
||
*The following tables are automatically generated.* | ||
|
||
{{ official_frictionless_spec('development') }} | ||
|
||
## Data Table Schemas | ||
|
||
{{ official_frictionless_schemas('development') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Local Branch GMNS Specification | ||
|
||
Local copy of General Network Feed Specification. | ||
|
||
## Files in Specification | ||
|
||
GMNS consists of a package of files as defined in the following table. | ||
|
||
*The following tables are automatically generated.* | ||
|
||
{{ local_frictionless_spec() }} | ||
|
||
## Data Table Schemas | ||
|
||
{{ local_frictionless_schemas() }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,22 @@ | ||
# GMNS Specification | ||
# Official GMNS Specification | ||
|
||
Schema for General Network Feed Specification. | ||
The GMNS specification is managed in the following Github repo: <https://github.com/zephyr-data-specs/GMNS> | ||
|
||
## Files in Specification | ||
| **GMNS Version** | **Description** | | ||
| ----- | ----- | | ||
| [development](spec-versions/development.md) | Not yet in official spec. Hasn't been voted on by PMG | | ||
| [local](spec-versions/local.md) | Local copy of spec. May not be identical to official spec. | | ||
|
||
GMNS consists of a package of files as defined in the following table. | ||
GMNS is defined using the [Frictionless Framework](https://specs.frictionlessdata.io/#data-package-specs-suite) as a series of `tabular-data-resources`. | ||
|
||
**The following table is automatically generated from `gmns.spec.json`** | ||
## Files in Specification | ||
|
||
{{ frictionless_spec() }} | ||
GMNS consists of a package of files as defined in the following table. | ||
|
||
File components for GMNS are specified in `gmns.spec.json` in a format compatible with the | ||
[frictionless data](https://specs.frictionlessdata.io/tabular-data-package/) data package standard. | ||
*The following tables are automatically generated from the official spec.* | ||
|
||
Example `gmns.spec.json`: | ||
```JSON | ||
{ | ||
"profile": "gmns-data-package", | ||
"profile_version":0.0, | ||
"name": "my-dataset", | ||
"resources": [ | ||
{ | ||
"name":"link", | ||
"path": "link.csv", | ||
"schema": "link.schema.json", | ||
"required": true | ||
}, | ||
{ | ||
"name":"node", | ||
"path": "node.csv", | ||
"schema": "node.schema.json", | ||
"required": true | ||
} | ||
] | ||
} | ||
``` | ||
{{ official_frictionless_spec('master') }} | ||
|
||
## Data Table Schemas | ||
|
||
Data table schemas are specified in JSON and are compatible with the | ||
[frictionless data](https://specs.frictionlessdata.io/table-schema/) table | ||
schema standards. | ||
|
||
Example: | ||
|
||
```JSON | ||
{ | ||
"primaryKey": "segment_id", | ||
"missingValues": ["NaN",""], | ||
"fields": [ | ||
{ | ||
"name": "segment_id", | ||
"type": "any", | ||
"description": "Primary key.", | ||
"constraints": { | ||
"required": true, | ||
"unique": true | ||
} | ||
}, | ||
{ | ||
"name": "road_link_id", | ||
"type": "any", | ||
"description": "Required. Foreign key to road_links. The link that the segment is located on.", | ||
"foreign_key": "link.link_id", | ||
"constraints": { | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"name": "ref_node_id", | ||
"type": "any", | ||
"description": "Required. Foreign key to node.", | ||
"foreign_key": "node.node_id", | ||
"constraints": { | ||
"required": true | ||
} | ||
}, | ||
{ | ||
"name": "start_lr", | ||
"type": "number", | ||
"description": "Required. Distance from ref_node_id.", | ||
"constraints": { | ||
"required": true, | ||
"minimum": 0 | ||
} | ||
}, | ||
{ | ||
"name": "end_lr", | ||
"type": "number", | ||
"description": "Required. Distance from ref_node_id.", | ||
"constraints": { | ||
"required": true, | ||
"minimum": 0 | ||
} | ||
} | ||
] | ||
} | ||
|
||
``` | ||
|
||
{{ frictionless_schemas() }} | ||
{{ official_frictionless_schemas('master') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
SPEC_GITHUB_USER = "zephyr-data-specs" | ||
SPEC_GITHUB_REPO = "GMNS" | ||
SPEC_GITHUB_PATH = Path("Specification") | ||
SPEC_GITHUB_SPEC_FILE = "gmns.spec.json" | ||
SPEC_GITHUB_REF = "master" | ||
|
||
LOCAL_SPEC = os.path.join(os.path.dirname(os.path.realpath(__file__)), "spec", "gmns.spec.json") |
Oops, something went wrong.