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

adding to_datacite method #596

Merged
merged 35 commits into from
May 19, 2021
Merged

adding to_datacite method #596

merged 35 commits into from
May 19, 2021

Conversation

djarecka
Copy link
Member

this is a continuation of #516 (I had issues with using the secrets, so testing this from the dandi branch)

Adding a new method to_dandicite that creates a datacite dictionary from the metadata object

@djarecka djarecka marked this pull request as draft April 26, 2021 17:08
@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #596 (2ae1c02) into master (36141db) will increase coverage by 0.31%.
The diff coverage is 96.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #596      +/-   ##
==========================================
+ Coverage   84.08%   84.40%   +0.31%     
==========================================
  Files          59       59              
  Lines        5644     5790     +146     
==========================================
+ Hits         4746     4887     +141     
- Misses        898      903       +5     
Flag Coverage Δ
unittests 84.40% <96.57%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dandi/models.py 88.79% <93.33%> (+0.83%) ⬆️
dandi/tests/test_models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36141db...2ae1c02. Read the comment docs.

@djarecka
Copy link
Member Author

@satra - I'm testing metadata that I took from dandisets 04 and 08. I could modify dataset 27 and add to the test, but can also keep adding various metadata to test_dantimeta_datacite

@satra
Copy link
Member

satra commented Apr 27, 2021

for the moment you can use a local test, but we should also add a test which downloads from the API, augments it with the missing pieces (because draft metadata may not have doi, url, etc.,.) and then runs through your datacite test using the test server.

dandi/models.py Outdated Show resolved Hide resolved

# checking if i'm able to get the url
rg = requests.get(
url=f"https://api.test.datacite.org/dois/{doi.replace('/','%2F')}/activities"
Copy link
Member

Choose a reason for hiding this comment

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

why activities and not compare to the posted metadata?

Copy link
Member

Choose a reason for hiding this comment

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

also we shouldn't have to do the doi.replace

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, the replacement is not needed. But the form with "activities" I took from datacite examples and it doesn't work without

@yarikoptic yarikoptic requested a review from jwodder May 12, 2021 21:00
@yarikoptic yarikoptic added the patch Increment the patch version when merged label May 12, 2021
dandi/models.py Outdated Show resolved Hide resolved
dandi/models.py Outdated Show resolved Hide resolved
dandi/models.py Outdated Show resolved Hide resolved
dandi/tests/test_models.py Outdated Show resolved Hide resolved
dandi/tests/test_models.py Show resolved Hide resolved
dandi/tests/test_models.py Outdated Show resolved Hide resolved
dandi/tests/test_models.py Outdated Show resolved Hide resolved
dandi/tests/test_models.py Show resolved Hide resolved
dandi/tests/test_models.py Outdated Show resolved Hide resolved
dandi/tests/test_models.py Outdated Show resolved Hide resolved
@yarikoptic
Copy link
Member

Please merge master or rebase -- "Test populate_dandiset_yaml.py / test (push) " should be gone now.

@yarikoptic
Copy link
Member

didn't look through all details (we should put con/tinuous to work here, filed #639) but those failing which are saw are of the

dandi/tests/test_models.py:232: in test_datacite
    newmeta = PublishedDandisetMeta(**newmeta_js)
pydantic/main.py:406: in pydantic.main.BaseModel.__init__
    ???
E   pydantic.error_wrappers.ValidationError: 1 validation error for PublishedDandisetMeta
E   assetsSummary
E     field required (type=value_error.missing)

nature

@djarecka
Copy link
Member Author

the biggest problem is that assetsSummary was added to PublishedDandisetMeta. Do you have any function to create it?

@satra
Copy link
Member

satra commented May 17, 2021

that would be a good function to right. this function should iterate over all assets in a dandiset to create a summary of unique values for those fields.

however, this is also what yarik was going to add to the asset. for example approach/technique are not being populated at the asset level right now. we can relax some of the components to optional, but i think species, approach, technique should really be there.

@djarecka
Copy link
Member Author

i'm a bit confused since it looks like a combination of information that should be provided by the author and info that could be calculated automatically...

@satra
Copy link
Member

satra commented May 17, 2021

all of that info is calculated from asset metadata, hence the name. the authors would provide this when creating nwb files (and they generally do). we have to do a bit more magic for bids datasets, so those would likely not be publishable till we have figured out some pieces.

@djarecka
Copy link
Member Author

ok, so for testing, I guess it's ok for me to use some random entry

@satra
Copy link
Member

satra commented May 17, 2021

I guess it's ok for me to use some random entry

yes

@djarecka
Copy link
Member Author

for now, I just saved meta from 000004 and 00008 in tests/data/metadata for testing. I could work on dandiset 000027 and additional dandisets later. Today I was not really able to use https://gui-staging.dandiarchive.org/ (doesn't load) and I still can't edit 000027

@djarecka
Copy link
Member Author

not sure what to do with Test model schemata / publish test

@yarikoptic
Copy link
Member

well, if you look at that fail run fail you will see

diff --git a/releases/0.3.1/published-dandiset.json b/releases/0.3.1/published-dandiset.json
index 14b909b..3f03ea5 100644
--- a/releases/0.3.1/published-dandiset.json
+++ b/releases/0.3.1/published-dandiset.json
@@ -270,7 +270,8 @@
     "contributor",
     "license",
     "assetsSummary",
-    "version"
+    "version",
+    "doi"
   ],
   "definitions": {
     "RoleType": {
Error:  Existing schema files modified instead of creating a new version
Error: Process completed with exit code 1.

so this PR modifies schema by adding doi (I am just surprised we did not have it for published-dandiset yet). I guess it is intended, so let's just boost schema version to 0.3.2 and merge. Or @satra -- you want to mutate 0.3.1? change is minor but not sure if would not cause some ripples in dandi-api / webui.

@satra
Copy link
Member

satra commented May 19, 2021

@yarikoptic - the doi was already there in the model, and should also be non-optional. this mutates it by removing a default value, which i think has an impact on whether or not it got exported to JSON schema. so this was a bug in the schema generation which this PR fixes.

@satra
Copy link
Member

satra commented May 19, 2021

technically this should not cause any issues in api/ui since we have had discussions about doi, but pinging @dchiquito. would be fine with me to mutate.

dandi/models.py Outdated Show resolved Hide resolved
@yarikoptic
Copy link
Member

ok, left minor comments but could be handled post-merge/migration to dedicated dandischema.
So I guess we could just wait for @dchiquito to give blessing to mutate or could boost the .patch and proceed with the merge.

@yarikoptic
Copy link
Member

Ok, @dchiquito gave blessing in slack, I fixed lint issue I introduced, let's proceed. Anything remaining should be done against dandischema

@yarikoptic yarikoptic merged commit 8f29c1b into master May 19, 2021
@yarikoptic yarikoptic deleted the datacite_upstr_tmp branch May 19, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants