Skip to content

Commit a6759bb

Browse files
authored
Update dvuploader dep (#3)
* use recent `dvuploader` * use dataverse action for tests * run action on patch and dispatch * fix and rename * Update repo_uploader.py * Update test.yml * remove trailing slash * remove print
1 parent f1bcc12 commit a6759bb

5 files changed

Lines changed: 144 additions & 41 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"datasetVersion": {
3+
"license": {
4+
"name": "CC0 1.0",
5+
"uri": "http://creativecommons.org/publicdomain/zero/1.0"
6+
},
7+
"metadataBlocks": {
8+
"citation": {
9+
"fields": [
10+
{
11+
"value": "Darwin's Finches",
12+
"typeClass": "primitive",
13+
"multiple": false,
14+
"typeName": "title"
15+
},
16+
{
17+
"value": [
18+
{
19+
"authorName": {
20+
"value": "Finch, Fiona",
21+
"typeClass": "primitive",
22+
"multiple": false,
23+
"typeName": "authorName"
24+
},
25+
"authorAffiliation": {
26+
"value": "Birds Inc.",
27+
"typeClass": "primitive",
28+
"multiple": false,
29+
"typeName": "authorAffiliation"
30+
}
31+
}
32+
],
33+
"typeClass": "compound",
34+
"multiple": true,
35+
"typeName": "author"
36+
},
37+
{
38+
"value": [
39+
{ "datasetContactEmail" : {
40+
"typeClass": "primitive",
41+
"multiple": false,
42+
"typeName": "datasetContactEmail",
43+
"value" : "finch@mailinator.com"
44+
},
45+
"datasetContactName" : {
46+
"typeClass": "primitive",
47+
"multiple": false,
48+
"typeName": "datasetContactName",
49+
"value": "Finch, Fiona"
50+
}
51+
}],
52+
"typeClass": "compound",
53+
"multiple": true,
54+
"typeName": "datasetContact"
55+
},
56+
{
57+
"value": [ {
58+
"dsDescriptionValue":{
59+
"value": "Darwin's finches (also known as the Galápagos finches) are a group of about fifteen species of passerine birds.",
60+
"multiple":false,
61+
"typeClass": "primitive",
62+
"typeName": "dsDescriptionValue"
63+
}}],
64+
"typeClass": "compound",
65+
"multiple": true,
66+
"typeName": "dsDescription"
67+
},
68+
{
69+
"value": [
70+
"Medicine, Health and Life Sciences"
71+
],
72+
"typeClass": "controlledVocabulary",
73+
"multiple": true,
74+
"typeName": "subject"
75+
}
76+
],
77+
"displayName": "Citation Metadata"
78+
}
79+
}
80+
}
81+
}
82+

.github/workflows/scripts/check_content.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
if path.is_file() and not str(path).startswith(".")
3535
}
3636

37-
assert len(ds_files) == len(
38-
repo_files
39-
), f"Length mismatch: {len(ds_files)} != {len(repo_files)}"
37+
assert len(ds_files) == len(repo_files), (
38+
f"Length mismatch: {len(ds_files)} != {len(repo_files)}"
39+
)
4040

4141
for ds_name, ds_hash in ds_files:
4242
assert ds_name in repo_files, f"File not found: {ds_name}"

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# doi:10.18419/darus-3801
2+
3+
name: Test action
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
9+
jobs:
10+
dv-sync:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: 'Checkout'
14+
uses: 'actions/checkout@v4'
15+
16+
- name: Run Dataverse Action
17+
id: dataverse
18+
uses: gdcc/dataverse-action@main
19+
20+
- name: 'Install Python'
21+
uses: 'actions/setup-python@v2'
22+
with:
23+
python-version: '3.11'
24+
25+
- name: 'Install requests'
26+
run: |
27+
python3 -m pip install requests
28+
29+
- name: 'Create Dataset'
30+
run: |
31+
export API_TOKEN=${{ steps.dataverse.outputs.api_token }}
32+
export PARENT=root
33+
export SERVER_URL=${{ steps.dataverse.outputs.base_url }}
34+
35+
# Remove the trailing slash from the server URL
36+
SERVER_URL=${SERVER_URL%/}
37+
38+
DATASET_RESPONSE=$(curl -s -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/dataverses/$PARENT/datasets" --upload-file .github/workflows/data/initial_dataset.json -H 'Content-type:application/json')
39+
40+
# Print the response
41+
echo $DATASET_RESPONSE
42+
43+
echo "DATASET_PID=$(echo $DATASET_RESPONSE | jq -r '.data.persistentId')" >> $GITHUB_ENV
44+
45+
- name: Synchronize to DV
46+
uses: ./
47+
with:
48+
dataverse_url: ${{ steps.dataverse.outputs.base_url }}
49+
api_token: ${{ steps.dataverse.outputs.api_token }}
50+
persistent_id: ${{ env.DATASET_PID }}
51+
52+
- name: Test content
53+
env:
54+
DV_API_TOKEN: ${{ steps.dataverse.outputs.api_token }}
55+
DV_URL: ${{ steps.dataverse.outputs.base_url }}
56+
DV_PID: ${{ env.DATASET_PID }}
57+
run: |
58+
python3 .github/workflows/scripts/check_content.py

.github/workflows/test_publish.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

action.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ runs:
3131
- name: "Upload data"
3232
shell: "bash"
3333
run: |
34-
python3 -m pip install git+https://github.com/gdcc/python-dvuploader.git@feature/non-direct-upload
34+
python3 -m pip install dvuploader
3535
3636
python3 ${{ github.action_path }}/repo_uploader.py \
3737
--dataverse-url "${{ inputs.dataverse_url }}" \
3838
--persistent-id "${{ inputs.persistent_id }}" \
3939
--api-token "${{ inputs.api_token }}" \
4040
--directory "${{ inputs.directory }}"
41-
42-
43-

0 commit comments

Comments
 (0)