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

Infer datapackage.json from transformed data files #48

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Conversation

switzersc
Copy link
Collaborator

Addresses #40

Use the datapackage ruby gem to infer the json schema for the resulting CSV files. There may be additional fields or some HSDS fields may not all be present, so we can't just use a static example datapackage.json file. This PR leaves the default as a fall-back in case the source data has path issues (still figuring out what's necessary for path management with this as a gem).

This PR also makes it so that the datapackage.json is present in the output regardless of whether the files have been zipped. Previously, the json schema was only generated if the files were zipped.

This also closes #46.

@@ -1,650 +0,0 @@
id,organization_id,program_id,name,alternate_name,description,url,email,status,interpretation_services,application_process,wait_time,fees,accreditations,licenses
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this because we don't use it as far as I can tell.

@@ -0,0 +1 @@
{"profile":"tabular-data-package","resources":[{"format":"csv","mediatype":"text/csv","name":"regular_schedules","path":"tmp/datapackage/data/regular_schedules.csv","schema":{"fields":[{"name":"id","type":"any","format":"default"},{"name":"service_id","type":"any","format":"default"},{"name":"location_id","type":"integer","format":"default"},{"name":"service_at_location_id","type":"any","format":"default"},{"name":"weekday","type":"any","format":"default"},{"name":"opens_at","type":"time","format":"default"},{"name":"closes_at","type":"time","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"phones","path":"tmp/datapackage/data/phones.csv","schema":{"fields":[{"name":"id","type":"any","format":"default"},{"name":"location_id","type":"any","format":"default"},{"name":"service_id","type":"any","format":"default"},{"name":"organization_id","type":"any","format":"default"},{"name":"contact_id","type":"any","format":"default"},{"name":"service_at_location_id","type":"any","format":"default"},{"name":"number","type":"any","format":"default"},{"name":"extension","type":"any","format":"default"},{"name":"type","type":"any","format":"default"},{"name":"language","type":"any","format":"default"},{"name":"description","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"eligibility","path":"tmp/datapackage/data/eligibility.csv","schema":{"fields":[{"name":"id","type":"any","format":"default"},{"name":"service_id","type":"integer","format":"default"},{"name":"eligibility","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"postal_addresses","path":"tmp/datapackage/data/postal_addresses.csv","schema":{"fields":[{"name":"id","type":"any","format":"default"},{"name":"location_id","type":"any","format":"default"},{"name":"organization_id","type":"integer","format":"default"},{"name":"attention","type":"any","format":"default"},{"name":"address_1","type":"any","format":"default"},{"name":"city","type":"any","format":"default"},{"name":"region","type":"any","format":"default"},{"name":"state_province","type":"any","format":"default"},{"name":"postal_code","type":"integer","format":"default"},{"name":"country","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"organizations","path":"tmp/datapackage/data/organizations.csv","schema":{"fields":[{"name":"id","type":"integer","format":"default"},{"name":"name","type":"any","format":"default"},{"name":"alternate_name","type":"any","format":"default"},{"name":"description","type":"any","format":"default"},{"name":"email","type":"any","format":"default"},{"name":"url","type":"any","format":"default"},{"name":"tax_status","type":"any","format":"default"},{"name":"tax_id","type":"any","format":"default"},{"name":"year_incorporated","type":"any","format":"default"},{"name":"legal_status","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"services_at_location","path":"tmp/datapackage/data/services_at_location.csv","schema":{"fields":[{"name":"id","type":"any","format":"default"},{"name":"service_id","type":"integer","format":"default"},{"name":"location_id","type":"integer","format":"default"},{"name":"description","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"locations","path":"tmp/datapackage/data/locations.csv","schema":{"fields":[{"name":"id","type":"integer","format":"default"},{"name":"organization_id","type":"integer","format":"default"},{"name":"name","type":"any","format":"default"},{"name":"alternate_name","type":"any","format":"default"},{"name":"description","type":"any","format":"default"},{"name":"transportation","type":"any","format":"default"},{"name":"latitude","type":"any","format":"default"},{"name":"longitude","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"},{"format":"csv","mediatype":"text/csv","name":"services","path":"tmp/datapackage/data/services.csv","schema":{"fields":[{"name":"id","type":"integer","format":"default"},{"name":"organization_id","type":"integer","format":"default"},{"name":"program_id","type":"any","format":"default"},{"name":"name","type":"any","format":"default"},{"name":"alternate_name","type":"any","format":"default"},{"name":"description","type":"any","format":"default"},{"name":"url","type":"any","format":"default"},{"name":"email","type":"any","format":"default"},{"name":"status","type":"any","format":"default"},{"name":"interpretation_services","type":"any","format":"default"},{"name":"application_process","type":"any","format":"default"},{"name":"wait_time","type":"any","format":"default"},{"name":"fees","type":"any","format":"default"},{"name":"accreditations","type":"any","format":"default"},{"name":"licenses","type":"any","format":"default"}],"missingValues":[""]},"profile":"tabular-data-resource","encoding":"utf-8"}]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to pretty print this but didn't know how to get the tests to ignore whitespace when comparing this with the actual output file.

expect(output_datapackage_json).to eq(datapackage_json_fixture)
end

xit "uses default datapackage.json when path is unsafe" do
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

@switzersc switzersc merged commit b787d62 into master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant