-
Notifications
You must be signed in to change notification settings - Fork 27
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
DOCK-2523: Fix formatting of conceptDOI #5894
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5894 +/- ##
=============================================
- Coverage 73.61% 70.05% -3.57%
+ Complexity 5298 4955 -343
=============================================
Files 374 371 -3
Lines 19404 19192 -212
Branches 2021 2012 -9
=============================================
- Hits 14284 13444 -840
- Misses 4150 4765 +615
- Partials 970 983 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -184,6 +184,9 @@ protected static String extractDoiFromDoiUrl(String doiUrl) { | |||
try { | |||
URI uri = new URI(doiUrl); | |||
doi = StringUtils.stripStart(uri.getPath(), "/"); | |||
if (doi.startsWith("doi/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you trace/test this?
It isn't clear to me whether this would fix concept DOIs only going forward or whether this is in a part of code that is called for retrieving past concept DOIs as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would fix future DOIs and then we would have to do a database migration to change the past DOIs. I didn't realize the migrations happen in this repo so I'll add that onto this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was like this already, but I think you should take advantage of the URI
class features instead of converting the URI back to a string and manipulating it. Something like:
URI base = new URI("https://doi.org/doi");
URI uri = new URI(doiUrl);
final String doi = base.relativize(uri);
...
But if we're expecting paths that don't start with doi
, then the above won't work as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we're expecting paths that don't start with doi, then the above won't work as is.
It seems like we only call this for the concept DOI url which we retrieve from the parent_doi
link of the published record.
dockstore/dockstore-webservice/src/main/java/io/dockstore/webservice/helpers/ZenodoHelper.java
Lines 168 to 170 in b769e72
String conceptDoiUrl = publishedDeposit.getLinks().get("parent_doi"); | |
String conceptDoi = extractDoiFromDoiUrl(conceptDoiUrl); |
This link has the form https://zenodo.org/doi/10.5281/zenodo.11093964 so we can't assume that the URL starts with https://doi.org/doi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conceptdoi
appears to be included in raw form in the zenodo response, could we retrieve it from there and avoid the url manipulation? https://zenodo.org/api/records/11093965
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do stick with extracting the concept DOI from the link url, and we need a cue as to where the Zenodo DOI begins in a given string, Zenodo DOIs always start with 10.5281/zenodo.
in the current Zenodo DOI generation scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it so we use the conceptdoi
from the zenodo response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ticket has a 1.15.x milestone, should the base be changed to the hotfix branch?
dockstore-webservice/src/test/java/io/dockstore/webservice/helpers/ZenodoHelperTest.java
Outdated
Show resolved
Hide resolved
@@ -184,6 +184,9 @@ protected static String extractDoiFromDoiUrl(String doiUrl) { | |||
try { | |||
URI uri = new URI(doiUrl); | |||
doi = StringUtils.stripStart(uri.getPath(), "/"); | |||
if (doi.startsWith("doi/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we're expecting paths that don't start with doi, then the above won't work as is.
It seems like we only call this for the concept DOI url which we retrieve from the parent_doi
link of the published record.
dockstore/dockstore-webservice/src/main/java/io/dockstore/webservice/helpers/ZenodoHelper.java
Lines 168 to 170 in b769e72
String conceptDoiUrl = publishedDeposit.getLinks().get("parent_doi"); | |
String conceptDoi = extractDoiFromDoiUrl(conceptDoiUrl); |
This link has the form https://zenodo.org/doi/10.5281/zenodo.11093964 so we can't assume that the URL starts with https://doi.org/doi
I think it's worth considering depending on how invasive this all ends up being. |
dockstore-webservice/src/main/java/io/dockstore/webservice/helpers/ZenodoHelper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if latest version has been uploaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question for clarification
dockstore-webservice/src/main/java/io/dockstore/webservice/helpers/ZenodoHelper.java
Outdated
Show resolved
Hide resolved
<sql dbms="postgresql"> | ||
UPDATE workflow | ||
SET conceptdoi = REGEXP_REPLACE(conceptdoi, 'doi/', '', 'g') | ||
WHERE archived=false AND conceptdoi IS NOT NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why when archived = false
? If there's a reason for it, you might want to add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the "frozenness" of archived entries is enforced via a trigger that makes an update fail when the archived
flag is true
both before and after the update. Essentially, the trigger causes updates to an archived entry to throw if they don't unarchive it. So, if we found that we did need to make changes to archived entries during migration, one approach might be to disable the trigger, make the update, and then re-enable the trigger afterwards. https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-DESC-DISABLE-ENABLE-TRIGGER
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled and reenabled the trigger in my new commit
@@ -191,4 +191,11 @@ | |||
<modifyDataType columnName="topicmanual" newDataType="varchar(250)" tableName="tool"/> | |||
<modifyDataType columnName="topicmanual" newDataType="varchar(250)" tableName="workflow"/> | |||
</changeSet> | |||
<changeSet author="hyunnaye" id="fixConceptDOIs"> | |||
<sql dbms="postgresql"> | |||
UPDATE workflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you only updating the workflow table because it's the only one that has this issue? If somebody creates a DOI in app tool, service, or notebook between now and the 1.16 release, that won't introduce the same misformatted conceptdoi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I added them for the other tables
<sql dbms="postgresql"> | ||
UPDATE workflow | ||
SET conceptdoi = REGEXP_REPLACE(conceptdoi, 'doi/', '', 'g') | ||
WHERE archived=false AND conceptdoi IS NOT NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, the "frozenness" of archived entries is enforced via a trigger that makes an update fail when the archived
flag is true
both before and after the update. Essentially, the trigger causes updates to an archived entry to throw if they don't unarchive it. So, if we found that we did need to make changes to archived entries during migration, one approach might be to disable the trigger, make the update, and then re-enable the trigger afterwards. https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-DESC-DISABLE-ENABLE-TRIGGER
dockstore-webservice/src/main/java/io/dockstore/webservice/helpers/ZenodoHelper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question, may not be blocker
ALTER TABLE apptool ENABLE TRIGGER update_archived_apptool; | ||
</sql> | ||
<sql dbms="postgresql"> | ||
ALTER TABLE service DISABLE TRIGGER update_archived_service; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have these migrations been tested on qa?
Asking because I thought migrations are run via the dockstore user
https://github.com/dockstore/compose_setup/blob/5c59a56af0cecaea4887bd805aba7277ab7e58b8/templates/init_migration.sh.template
I don't recall if the dockstore user has the ability to disable the frozen trigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we've done it in the past, as the dockstore user, so I think it's OK (but definitely test). You should be able to test locally if it's easier, if you have your postgres and dockstore DB users set up correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it locally and the migrations work :)
ALTER TABLE apptool ENABLE TRIGGER update_archived_apptool; | ||
</sql> | ||
<sql dbms="postgresql"> | ||
ALTER TABLE service DISABLE TRIGGER update_archived_service; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we've done it in the past, as the dockstore user, so I think it's OK (but definitely test). You should be able to test locally if it's easier, if you have your postgres and dockstore DB users set up correctly.
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
This PR removes the
doi/
prefix inconceptDOI
Review Instructions
Go to https://qa.dockstore.org/workflows/github.com/kathy-t/ghapps-single-workflow:master?tab=info and verify that the link works correctly.
Issue
https://ucsc-cgl.atlassian.net/browse/DOCK-2523
https://ucsc-cgl.atlassian.net/browse/DOCK-2527
Security and Privacy
If there are any concerns that require extra attention from the security team, highlight them here and check the box when complete.
e.g. Does this change...
Please make sure that you've checked the following before submitting your pull request. Thanks!
mvn clean install
@RolesAllowed
annotation