gdcc / python-dvuploader

✈️ - Python package for parallel direct upload to Dataverse
MIT License
4 stars 0 forks source link

Unable to upload directory of files #10

Closed kmika11 closed 5 months ago

kmika11 commented 5 months ago

When adding files using *dv.add_directory("./project/data") as described in the instructions, I consistently receive the error: AttributeError: module 'dvuploader' has no attribute 'add_directory'

Full code:

import dvuploader as dv

#add files
files = [
    #dv.File(filepath="./small.txt"),
    #dv.File(filepath="./small.txt"),
    #dv.File(directoryLabel="some/dir", filepath="./medium.txt"),
    #dv.File(directoryLabel="some/dir", filepath="./big.txt"),
    *dv.add_directory("./project/data"), # Add an entire directory
]

#set variables
DV_URL = "https://dataverse.harvard.edu/"
API_TOKEN = "XXXX-XXX-XXXXX-XXXXXX"
PID = "doi:10.7910/DVN/xxxxxx"

#upload files
dvuploader = dv.DVUploader(files=files)
dvuploader.upload(
    api_token=API_TOKEN,
    dataverse_url=DV_URL,
    persistent_id=PID,
    n_parallel_uploads= 2 # Whatever your instance can handle
)
JR-1991 commented 5 months ago

@kmika11 Thanks for submitting! Which version are you using? The older version did not feature the add_directory function.

kmika11 commented 5 months ago

Thanks for taking a look! I'm on dvuploader 0.2.1. I think that's the current version?

JR-1991 commented 5 months ago

Yes, this is the current version of the dvuploader. I tried to reproduce your error on Colab, but I didn't encounter the same error.

Could you reinstall the library and check if the error persists?

kmika11 commented 5 months ago

I removed and reinstalled and that did seem to fix it. Thanks!