-
Notifications
You must be signed in to change notification settings - Fork 493
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
8525 ingest optional skip #8532
Conversation
Update from IQSS
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.
Overall, this pull request looks great. It's API-only but sets the stage for a future GUI to allow users to skip ingest (#2199).
I do have a few small items to look at. Please see the review. Thanks!
Co-authored-by: Philip Durbin <philipdurbin@gmail.com>
…erse into 8525-injest-optional-skip
FWIW: The current failure is just #8533 - not related to your PR. |
String pathToFile = "src/test/resources/sav/dct.sav"; | ||
String jsonAsString = "{\"description\":\"My description.\",\"directoryLabel\":\"data/subdir1\",\"categories\":[\"Data\"], \"restrict\":\"false\", \"tabIngest\":\"false\"}"; | ||
Response r = UtilIT.uploadFileViaNative(datasetIdInt.toString(), pathToFile, jsonAsString, apiToken); | ||
logger.info(r.prettyPrint()); | ||
assertEquals(200, r.getStatusCode()); | ||
|
||
pathToFile = "src/test/resources/sav/frequency-test.sav"; | ||
jsonAsString = "{\"description\":\"My description.\",\"directoryLabel\":\"data/subdir1\",\"categories\":[\"Data\"], \"restrict\":\"false\" }"; | ||
Response rTabIngest = UtilIT.uploadFileViaNative(datasetIdInt.toString(), pathToFile, jsonAsString, apiToken); | ||
logger.info(rTabIngest.prettyPrint()); | ||
assertEquals(200, rTabIngest.getStatusCode()); |
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 might be nice to assert somehow if the file was ingested or not. I'm not sure about the easiest way. Maybe UtilIT.downloadTabularFile? Or check if there's a UNF?
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.
Checking the file name may be enough (making sure it's still ".sav", and not ".tab").
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 yes, I agree, we do need to confirm that the ingest was indeed skipped.
Also, the 2nd file upload in this method - where ingest is NOT being skipped - it may not be necessary, since we are already testing actual ingest elsewhere (in FilesIT.java?).
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.
Ok, I renamed the test and moved it to FilesIT. I also added the ingest check by checking label of file metadata.
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.
@@ -1301,6 +1301,7 @@ When adding a file to a dataset, you can optionally specify the following: | |||
- A description of the file. | |||
- The "File Path" of the file, indicating which folder the file should be uploaded to within the dataset. | |||
- Whether or not the file is restricted. | |||
- Whether or not the file skips tabular ingest. |
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.
This should probably say that it defaults to "true" (?).
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 added the phrase that if tabIngest is not specified then it defaults to true.
@@ -2583,5 +2583,48 @@ public void testFilesUnchangedAfterDatasetMetadataUpdate() throws IOException { | |||
.body("data.latestVersion.files[0].directoryLabel", equalTo("code")); | |||
|
|||
} | |||
|
|||
@Test | |||
public void testAddFileToDatasetTabIngest() throws IOException, InterruptedException { |
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 would make sense to rename this test method, to make it clear that it is specifically testing skipping ingest; to differentiate it from all the other ingest tests in FilesIT etc.
(Thinking about it, maybe this method needs to be moved to FilesIT.java too?)
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 renamed it to testAddFileToDatasetSkipTabIngest and moved it to FilesIT.
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.
Looks great, thank you!
Response r = UtilIT.uploadFileViaNative(datasetIdInt.toString(), pathToFile, jsonAsString, apiToken); | ||
logger.info(r.prettyPrint()); | ||
assertEquals(200, r.getStatusCode()); | ||
|
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.
Sorry to keep bugging you but, since this hasn't been merged yet, could you please insert another sleepForLock statement here? (Otherwise, if the ingest somehow ends up happening, despite the tabIngest:false
above, we will likely fail to detect that - because the file name will be checked before it gets updated!)
It should be the same entry as in line 1820:
assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION));
Thanks. (I should've thought about this sooner of course).
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.
Added sleep for lock.
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.
Great, thanks.
@lubitchv would you mind refreshing from develop branch since we've had a version change? |
Updated |
@lubitchv Can you take a look at this test that is failing with your branch? https://github.com/lubitchv/dataverse/blob/8525-injest-optional-skip/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java#L2243 |
@lubitchv just to give a little more detail on the fail test above: org.xml.sax.SAXParseException: Something to do with exporting the DDI format, it seems. |
I run DatasetsIT.testRestrictFileExportDdi on my machine. It was fine. Maybe it is database issue? |
FWIW: My suspicion is that the test fail here was related to gdcc/dataverse-ansible#231. Don turned off having the tests run with the languages and metadata languages features set to en or de-DE as of last night. |
What this PR does / why we need it: This PR adds optional parameter to native add file to dataset API. The parameter is tabIngest. By default it is true. If tabIngest is false then api call skips tabular ingest.
Which issue(s) this PR closes:
Closes #8525
Suggestions on how to test this:
Test testAddFileToDatasetTabIngest was added in DatasetsIT.
One can also test this api call using curl:
curl -H X-Dataverse-key:$API_TOKEN -X POST -F "file=@test.sav" -F 'jsonData={"description":"My description.","directoryLabel":"data/subdir1","categories":["Data"], "restrict":"false", "tabIngest":"false"}' http://localhost:8080/api/datasets/$DATASET_ID/add