-
Notifications
You must be signed in to change notification settings - Fork 8
Issue 40 validate example data #75
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
base: main
Are you sure you want to change the base?
Changes from 11 commits
a24f119
74b02d9
9db30a9
7fdddfe
dba9e26
eaa009a
af15c9a
c0acbd1
bcc5a0f
3532b15
53a05b9
3aadfea
9661da0
5332619
e05cd3c
9d50d5d
06a8294
102e1c3
d7a9756
446ec34
5088e6c
ec3c7e8
1b94140
9d8f05f
88e19b0
cb6dd18
5bc9310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Validate Example TIDES Data | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - 'data/*/TIDES/*' | ||
| - 'spec/*' | ||
| pull_request: | ||
| paths: | ||
| - 'data/*/TIDES/*' | ||
| - 'spec/*' | ||
| workflow_dispatch: | ||
| create: | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
| - name: Validate data | ||
| uses: frictionlessdata/repository@v2 | ||
|
botanize marked this conversation as resolved.
|
||
| with: | ||
| packages: "data/*/TIDES/datapackage.json" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| .DS_Store* | ||
| .vscode* | ||
| /__pycache__/* | ||
| .env | ||
| /venv* | ||
| /site | ||
| /__pycache__ | ||
| /site/* | ||
| # pages that are copied in from main repo | ||
| /docs/CONTRIBUTING.md | ||
| /docs/CODE_OF_CONDUCT.md | ||
| /docs/README.md | ||
| # pages that are generated from templates | ||
| /docs/tables.md | ||
| /docs/architecture.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| # Contributors | ||
| # Contributors |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| {{ include_file('README.md', downshift_h1= False) }} | ||
| # TIDES Transit Specification Suite | ||
|
|
||
| {{ include_file('README.md', start_line = 2, downshift_h1= False) }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Sample Data | ||
|
|
||
| Sample data can be found in the `/samples` directory, with one directory for each data sample. | ||
|
|
||
| {{ include_file('samples/README.md')}} | ||
|
|
||
| ## Data List | ||
|
|
||
| {{ list_samples('samples') }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| -r docs/requirements.txt | ||
| pre-commit | ||
| -r docs/requirements.txt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Data Directory Organization | ||
|
|
||
| Each TIDES Data Package example should follow the following directory structure, consistent with the structure of the [Frictionless Data Package specification](https://specs.frictionlessdata.io/data-package/), including: | ||
|
|
||
| ``` | ||
| unique-example-name | ||
| \TIDES # data to be validated against the TIDES specification | ||
| \TIDES\datapackages.json # data package metadata per https://specs.frictionlessdata.io/data-package/ | ||
|
e-lo marked this conversation as resolved.
Outdated
|
||
| \raw # data which the agency uses to create TIDES data | ||
| \scripts # scripts used to transform raw --> TIDES | ||
|
e-lo marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| ## Adding Examples | ||
|
|
||
| We encourage the addition of examples, but please follow the following guidelines: | ||
|
|
||
| 1. *No large files* This isn't the place to store your data, rather to document some minimal examples. The recommended size is 100-1000 records per file, more if absolutely required to reproduce an issue with the spec. All individual files should be well under 50 MB. | ||
| 2. *Include Metadata* as specified in [`datapackage.json`](#data-package). | ||
| 3. *Include a README.md* in the base folder of your example with an overview so that it can be included in the documentation. | ||
|
|
||
| ## Data Package | ||
|
|
||
| TIDES data packages must include a [`datapackage.json`](https://specs.frictionlessdata.io/data-package/). Key information to include in [`datapackage.json`](https://specs.frictionlessdata.io/data-package/) includes: | ||
|
|
||
| | **Field** | **Description** | **Required** | | ||
| | --------- | --------------- | ------------ | | ||
| | `title` | A human-readable title. | Required | | ||
| | `name` | Identifier string as a URL-friendly slug. | Required | | ||
| | `description` | Short description of data package. | Recommended | | ||
| | `agency` | Transit agency name. | Recommended | | ||
| | `ntd_id` | ID for the National Transit Database. | Recommended | | ||
| | `profile` | Should be `tabular-data-package` | Required | | ||
| | `licenses` | Should be `[{"name": "Apache-2.0"}]` to be consistent with this repository | Required | | ||
| | `contributors` | Array of data contributors `[{"title": "My Name", "github": "my_handle", "email": "me@myself.com"}]` | Recommended | | ||
| | `maintainers` | Array of data maintainers `[{"title": "My Name", "github": "my_handle", "email": "me@myself.com"}]` | Recommended | | ||
| | `resources` | Array of data files included in your package, formated as a [`tabular-data-resource`](#data-resource)| Required | | ||
|
|
||
| ### Template | ||
|
|
||
| A `datapackage.json` template is available at [`/data/template/TIDES/datapackage.json`](https://raw.githubusercontent.com/TIDES-transit/TIDES/main/data/template/TIDES/datapackage.json). | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to ### Example datapackage.json
```
{
"title": "Example Title",
"name": "example-name",
"description": "a description goes here, can include markdown formatting",
"agency": "Metro",
"ntd_id": 00000,
"profile": "tabular-data-package",
"licenses": [{"name": "Apache-2.0"}],
"contributors": [
{"title": "Name Name", "github": "my_handle", "email": null}
],
"resources": [
{
"name": "vehicle_locations",
"path": "TIDES/vehicle_locations.csv",
"schema": "https://raw.githubusercontent.com/TIDES-transit/TIDES/main/spec/vehicle_locations.schema.json"
}
]
}
```
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is better when we can include the file in the markdown? I'd prefer to manage data as data, not as data within markdown.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it's not data!—it's documentation, an example that doesn't even have meaningful values. Documentation for just about every software tool is littered with example code and configuration, this is exactly the same. If you want to include a file, go ahead, but I do think that at the very least the file should have an obviously different name, e.g., |
||
| Once `datapackage.json` is created for your data, you can easily conduct [data validation](#data-validation) using a variet of tools. | ||
|
|
||
| ### Data Resource | ||
|
|
||
| Key fields for each [`tabular-data-resource`](https://specs.frictionlessdata.io/tabular-data-resource/) are as follows: | ||
|
|
||
| | **Field** | **Description** | **Required** | | ||
| | --------- | --------------- | ------------ | | ||
| | `name` | Short sluggable name used to refer to data in this file. | Required | | ||
| | `path` | Path of the data resource file relative to the `datapackage.json` | Required | | ||
| | `schema` | Data schema to use to valdiate the data resource to | Required | | ||
| | `sources` | Array of data sources formatted as a [`source`](#data-source) | Recommended | | ||
|
|
||
| ### Data Source | ||
|
|
||
| | **Field** | **Description** | **Required** | | ||
| | --------- | --------------- | ------------ | | ||
| | `title` | Description of the data source. | Required | | ||
| | `component` | What technology component was used to generate this data (directly or indirectly)? Examples include `AVL`, `APC`, `AFC`, etc. | Recommended | | ||
| | `product` | What product was used to generate this data (directly or indirectly)? | Recommended | | ||
| | `vendor` | What company makes this product? | Recommended | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the primary use for this if for people to see at a glance if the example they're looking at is comparable to their system—this level of precision, with vendor, product and component per resource is overkill and leads to a lot of duplication in the For example, in our system vehicle_locations, stop_visits, passenger_events, station_activities, trips_performed would all be the same vendor/product (Vontas/TransitMaster), and the component would be an array ( I suggest we move the {
"title": "Metro Transit Basic",
"name": "metrotransitmn-basic",
"agency": "Metro Transit",
"ntd_id": 50027,
"sources": [
{ "source": "TransitMaster", "components": ["APC", "AVL"]},
{ "source": "emtrac", "components": "AVL"},
{ "source": "Cubic", "components": "AFC"}
],
"resources": [
{
"path": "TIDES/vehicle_locations.csv",
"profile": "tabular-data-resource",
"schema": "https://raw.githubusercontent.com/TIDES-transit/TIDES/main/spec/vehicle_locations.schema.json"
}
]
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main value I see in putting it under each resource is to explicitly say where each piece of the "TIDES pie" is coming from so that agencies that are trying to mimic another agency's a data flow diagram can do so. It's not necessarily implicit which resource comes from which product. For example, there are many agencies that receive APC data from their "APC product" that is then manipulated by another product (including internal scripts) and then spat out to other systems. Exposing this seems like it would add a great deal of value. That said, there is no reason why you can't just put all the sources up top....especially if we aren't articulating a profile which would require it and are merely suggesting.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. It could be nested, big-picture at the top-level, details for each resource, both optional. |
||
|
|
||
| ## Data validation | ||
|
|
||
| Data with a valid [`datapackage.json`](#data-package) can be easily validated using the [frictionless framework](https://framework.frictionlessdata.io/), which can be installed and invoke as follows: | ||
|
|
||
| ```bash | ||
| pip install frictionless | ||
| frictionless validate path/to/your/datapackage.json | ||
| ``` | ||
|
|
||
| ### Specific files | ||
|
|
||
| Specific files can be validated by running the frictionless framework against them and their corresponding schemas as follows: | ||
|
|
||
| ```sh | ||
| frictionless validate vehicles.csv https://raw.githubusercontent.com/TIDES-transit/TIDES/main/spec/schema.vehicles.json | ||
|
e-lo marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| ### Continuous Data Validation | ||
|
|
||
| Example data in the `\TIDES` subdirectories is validated upon a push action to the main repository according to the `TIDES` schema posted to the `main` branch. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Example TIDES Data Package | ||
|
|
||
| Template directory for example scaffolding and helper scripts. | ||
|
|
||
| ## Scripts for Generating Template Data | ||
|
|
||
| `scripts\create_template.py` has some template code which can help with the following | ||
|
|
||
| - `write_schema_examples()`: will generate blank csvs according to the TIDES schema | ||
| - `write_datapackage()` will generate a datapackage.json based on the TIDES schemas and a set of defaults specified in th script. | ||
|
|
||
| To run both (note this replaces the existing files in the directory) | ||
|
|
||
| ```bash | ||
| python samples/template/scripts/create_template.py | ||
| ``` |
Uh oh!
There was an error while loading. Please reload this page.