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

Missing Dataverse upload schema #56

Closed
dmelichar opened this issue Oct 29, 2020 · 4 comments
Closed

Missing Dataverse upload schema #56

dmelichar opened this issue Oct 29, 2020 · 4 comments
Assignees
Labels
info:beginner Good for newcomers pkg:api api related activities pkg:models models related activities prio:asap Fix as soon as possible status:confirmed Is a valid issue and will be moved forward soon. type:bug Something isn't working
Milestone

Comments

@dmelichar
Copy link

Expected Behavior

It should be possible to create an Dataverse object from a JSON file, such as this example file.

Current Behavior

The following error is thrown:

FileNotFoundError: [Errno 2] No such file or directory: 'schemas/json/dataverse_upload_schema.json'

Possible Solution

Include Dataverse schema

Steps to Reproduce

napi = NativeApi(base_url=url, api_token=token)
dv = Dataverse()

with open('dataverse.json') as dataverse:
    data = json.load(dataverse)
    dv.set(data)
    try: 
        napi.create_dataverse(identifier=dv.alias, metadata=dv.to_json())
        
        # Uploading the file directly works, though
        #napi.create_dataverse(identifier=dv.alias, metadata=data)
    except OperationFailedError:
        print("Dataverse already created")

Context (Environment

Branch - develop
Commit hash - 3b040ff
Environment - macOS using Pipenv

@dmelichar
Copy link
Author

This also seems to be a probem with Dataset objects. I tried to create a new Dataset with the demo file dataset-finch1-json and upload it. Same setup and context as before.

ds1 = Dataset()

with open(dataset1) as df:
    ds1.from_json(df.read()) 
    resp = napi.create_dataset(dataverse=alias, metadata=ds1.to_json())
    print(resp.text)

The error thrown is:

FileNotFoundError: [Errno 2] No such file or directory: 'schemas/json/dataset_upload_default_schema.json'

@skasberger skasberger self-assigned this Nov 2, 2020
@skasberger skasberger added info:beginner Good for newcomers pkg:api api related activities pkg:models models related activities prio:asap Fix as soon as possible status:confirmed Is a valid issue and will be moved forward soon. type:bug Something isn't working labels Nov 2, 2020
@skasberger skasberger added this to the v0.3.0 milestone Nov 2, 2020
@memetics19
Copy link

Facing this issue, any workaround?

@skasberger
Copy link
Member

skasberger commented Dec 2, 2020

@memetics19 yes, if you deactivate validation, the missing schema file is not called. e.g. .to_json(validate=False). But i will try to fix it in the next days.

@dmelichar do you know, how you installed pyDataverse? I have checked, and the file is in the respective place inside the repo, but it is in the repo root directory. So my first guess is, cause the path is relative, that it must be inside the pydataverse folder src/pyDataverse/. So depending on how you install the package, it maybe is not using the repo root as the current working directory or it looks for it inside the src/pyDataverse directory, which only holds the Python files.

skasberger added a commit that referenced this issue Dec 2, 2020
Fix bug: the JSON schema files were not found, when package was installed.
Move schemas directory to src/pyDataverse and add it to MANIFEST.in.
Add MANIFEST.in. Update models.py to load json schema file to
absolute path.

Add some minor changes:

- .gitignore
- tox.ini
- rename deps directory to requirements and rename txt-files

Resolves: #56
@skasberger
Copy link
Member

Fix: 6c53b0f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info:beginner Good for newcomers pkg:api api related activities pkg:models models related activities prio:asap Fix as soon as possible status:confirmed Is a valid issue and will be moved forward soon. type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants