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

Schema included in a data package not added to CKAN #61

Closed
Stephen-Gates opened this issue Dec 6, 2017 · 8 comments
Closed

Schema included in a data package not added to CKAN #61

Stephen-Gates opened this issue Dec 6, 2017 · 8 comments
Milestone

Comments

@Stephen-Gates
Copy link

A data package can include schemas for each data resource. When I upload a datapackage.zip file containing schemas I expect these to be stored in CKAN.

If they were stored they could be

@GeraldGrootRoessink
Copy link

Suppose we could import/export schema from/to datapackage.json to/from CKAN. Like that idea. I wonder though, how that relates to the field information provided bij de datastore-create-API and the datapusher-extension. For example, the test for the API provided in the CKAN documentation gives this result:

    "fields": [
        {
            "type": "int",
            "id": "_id"
        },
        {
            "type": "int4",
            "id": "a"
        },
        {
            "type": "text",
            "id": "b"
        }
    ],

Will this be compatible?

@Stephen-Gates
Copy link
Author

@GeraldGrootRoessink this is related and worth a read ckan/ckanext-validation#1

@GeraldGrootRoessink
Copy link

Worth a read indeed. My understanding is that ckanext-validation introduces with ckanext-scheming a new field schema that accepts a json-object like (without the whitespace):
{
"fields" : [{
"name" : "regel",
"title" : "kolom 1",
"type" : "string",
"rdfType" : "http://lod.duo.nl/cdm/def/v0/regelnummer"
}, {
"name" : "brin",
"title" : "kolom 2",
"type" : "integer",
"rdfType" : "http://lod.duo.nl/cdm/def/v0/BRIN-V02"
}
]
}
So it should be possible to extract this part of het datapackage.json in
https://github.com/frictionlessdata/ckan-datapackage-tools/blob/master/ckan_datapackage_tools/converter.py at line 116.

Am I right?

@GeraldGrootRoessink
Copy link

Me again.
Added these lines after line 139

if resource.descriptor.get('schema'):
    resource_dict['schema'] = resource.descriptor['schema']

This works

@amercader
Copy link
Member

@GeraldGrootRoessink That sounds like a good approach, can you submit a PR?

@GeraldGrootRoessink
Copy link

Submitted a PR. However the coverall/coverage checks fails at 96.465 because of a warning:

tests/test_converter.py::TestDataPackageToDatasetDict::test_datapackage_name_title_and_version
_/home/travis/build/frictionlessdata/ckan-datapackage-tools/.tox/py/lib/python2.7/site-packages/datapackage/package.py:420: UserWarning: Property "package.to_dict" is deprecated.
UserWarning)

I'm afraid I'm in over my head with this one.

@amercader
Copy link
Member

@GeraldGrootRoessink this is coverage complaining that you didn't add a test for your change :)
Plus an unrelated warning which I fixed.

I did myself here, plus fixed the logic for the inverse path (dataset -> datapackage).

@amercader amercader added this to the MVP v1 milestone Feb 8, 2018
@GeraldGrootRoessink
Copy link

Super. For anyone who follows: It will only work nicely if there is a schema-field defined as a json-object. For example I managed this using https://github.com/ckan/ckanext-scheming.

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

No branches or pull requests

3 participants