-
Notifications
You must be signed in to change notification settings - Fork 494
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
Changes from 18 commits
8b9e706
b9b2efe
e504bfc
0943258
d0c70e7
46d07ce
3f92d83
5cbe6a7
f0123ec
1a040a6
8457911
d5090b7
2da5d2d
eea514e
3170ef2
9b04c9c
3589b4c
4fc0a35
2163fdc
3cf56e8
fe9e7e6
ecc9ffc
47c1413
66b774b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
Note that when a Dataverse instance is configured to use S3 storage with direct upload enabled, there is API support to send a file directly to S3. This is more complex and is described in the :doc:`/developers/s3-direct-upload-api` guide. | ||
|
||
|
@@ -1315,13 +1316,13 @@ In the curl example below, all of the above are specified but they are optional. | |
export SERVER_URL=https://demo.dataverse.org | ||
export PERSISTENT_ID=doi:10.5072/FK2/J8SJZB | ||
|
||
curl -H X-Dataverse-key:$API_TOKEN -X POST -F "file=@$FILENAME" -F 'jsonData={"description":"My description.","directoryLabel":"data/subdir1","categories":["Data"], "restrict":"false"}' "$SERVER_URL/api/datasets/:persistentId/add?persistentId=$PERSISTENT_ID" | ||
curl -H X-Dataverse-key:$API_TOKEN -X POST -F "file=@$FILENAME" -F 'jsonData={"description":"My description.","directoryLabel":"data/subdir1","categories":["Data"], "restrict":"false", "tabIngest":"false"}' "$SERVER_URL/api/datasets/:persistentId/add?persistentId=$PERSISTENT_ID" | ||
|
||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
|
||
curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST -F [email protected] -F 'jsonData={"description":"My description.","directoryLabel":"data/subdir1","categories":["Data"], "restrict":"false"}' "https://demo.dataverse.org/api/datasets/:persistentId/add?persistentId=doi:10.5072/FK2/J8SJZB" | ||
curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST -F [email protected] -F 'jsonData={"description":"My description.","directoryLabel":"data/subdir1","categories":["Data"], "restrict":"false", "tabIngest":"false"}' "https://demo.dataverse.org/api/datasets/:persistentId/add?persistentId=doi:10.5072/FK2/J8SJZB" | ||
|
||
You should expect a 201 ("CREATED") response and JSON indicating the database id that has been assigned to your newly uploaded file. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2583,5 +2583,48 @@ public void testFilesUnchangedAfterDatasetMetadataUpdate() throws IOException { | |
.body("data.latestVersion.files[0].directoryLabel", equalTo("code")); | ||
|
||
} | ||
|
||
pdurbin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Test | ||
public void testAddFileToDatasetTabIngest() throws IOException, InterruptedException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I renamed it to testAddFileToDatasetSkipTabIngest and moved it to FilesIT. |
||
|
||
Response createUser = UtilIT.createRandomUser(); | ||
assertEquals(200, createUser.getStatusCode()); | ||
String username = UtilIT.getUsernameFromResponse(createUser); | ||
String apiToken = UtilIT.getApiTokenFromResponse(createUser); | ||
|
||
Response createDataverseResponse = UtilIT.createRandomDataverse(apiToken); | ||
assertEquals(201, createDataverseResponse.getStatusCode()); | ||
String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse); | ||
|
||
Response createDatasetResponse = UtilIT.createRandomDatasetViaNativeApi(dataverseAlias, apiToken); | ||
assertEquals(201, createDatasetResponse.getStatusCode()); | ||
Integer datasetIdInt = JsonPath.from(createDatasetResponse.body().asString()).getInt("data.id"); | ||
|
||
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 commentThe 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 commentThe 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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
//cleanup | ||
assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); | ||
|
||
Response destroyDatasetResponse = UtilIT.destroyDataset(datasetIdInt, apiToken); | ||
assertEquals(200, destroyDatasetResponse.getStatusCode()); | ||
|
||
Response deleteDataverseResponse = UtilIT.deleteDataverse(dataverseAlias, apiToken); | ||
assertEquals(200, deleteDataverseResponse.getStatusCode()); | ||
|
||
Response deleteUserResponse = UtilIT.deleteUser(username); | ||
assertEquals(200, deleteUserResponse.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.
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.