gdcc / easyDataverse

🪐 - Lightweight Dataverse interface in Python to upload, download and update datasets found in Dataverse installations.
MIT License
15 stars 4 forks source link

func list_files does not list files #8

Closed atrisovic closed 1 year ago

atrisovic commented 1 year ago

Hey!

I was testing the Dataset functions and I noticed that list_files does not list files, but all metadata. See the example here:

dataset = Dataset.from_dataverse_doi(
  doi="doi:10.7910/DVN/TNI7DY",
  dataverse_url="https://dataverse.harvard.edu"
)
dataset.list_files

Result:

<bound method Dataset.list_files of Dataset(metadatablocks={'citation': Citation(title='Replication Code for: "Essay Content and Style are Strongly Related to Household Income and SAT Scores: Evidence from 60,000 Undergraduate Applications"', author=[Author(name='Alvero, AJ', affiliation='Stanford University', identifier_type=None, identifier=None), Author(name='Giebel, Sonia', affiliation='Stanford University', identifier_type='ORCID', identifier='https://orcid.org/ 0000-0002-4730-8980'), Author(name='Gebre-Medhin, Ben', affiliation='Mount Holyoke College', identifier_type='ORCID', identifier='https://orcid.org/ 0000-0002-8140-0406'), Author(name='antonio, anthony', affiliation='Stanford University', identifier_type='ORCID', identifier='https://orcid.org/ 0000-0002-7083-0355'), Author(name='Stevens, Mitchell', affiliation='Stanford University', identifier_type='ORCID', identifier='https://orcid.org/ 0000-0003-2194-9226'), Author(name='Domingue, Ben', affiliation='Stanford University', identifier_type='ORCID', identifier='https://orcid.org/ 0000-0002-3894-9049')], point_of_contact=[PointOfContact(name='Alvero, AJ', affiliation='Stanford University', e_mail='aaronjalvero@gmail.com')], description=[Description(text='Code used in paper "Essay Content and Style are Strongly Related to Household Income and SAT Scores: Evidence from 60,000 Undergraduate Applications"')], subject=['Arts and Humanities', 'Computer and Information Science', 'Social Sciences', 'Other'], language=['English'], depositor='AJ Alvero', deposit_date='2021-08-27', _metadatablock_name='citation')}, p_id='doi:10.7910/DVN/TNI7DY', files=[File(filename='bootstrap_CI_sat.R', description='Updated variable/column names', file_pid='5595601', local_path='./bootstrap_CI_sat.R', dv_dir=None), 
...

However, dataset.files correctly lists the files:

[File(filename='bootstrap_CI_sat.R', description='Updated variable/column names', file_pid='5595601', local_path='./bootstrap_CI_sat.R', dv_dir=None),
 File(filename='create_cor_figure_S1.R', description='', file_pid='5414271', local_path='./create_cor_figure_S1.R', dv_dir=None),
 File(filename='ctm_essays.R', description='', file_pid='5414269', local_path='./ctm_essays.R', dv_dir=None),
 File(filename='decile_barplots_code.R', description='', file_pid='5414274', local_path='./decile_barplots_code.R', dv_dir=None),
 File(filename='hist_code.R', description='', file_pid='5414284', local_path='./hist_code.R', dv_dir=None),
 File(filename='k_fold_ebrw_on_rhi.R', description='', file_pid='5414270', local_path='./k_fold_ebrw_on_rhi.R', dv_dir=None),
 File(filename='k_fold_ebrw.R', description='', file_pid='5414279', local_path='./k_fold_ebrw.R', dv_dir=None),
....
JR-1991 commented 1 year ago

Thanks Ana! This is a method that needs to be invoked, which will list files and their IDs. Anyway, I think this is a strong indicator to add a proper documentation.

Using your code I get:

dataset.list_files()

Out

5595601 bootstrap_CI_sat.R
5414271 create_cor_figure_S1.R
5414269 ctm_essays.R
5414274 decile_barplots_code.R
5414284 hist_code.R
5414270 k_fold_ebrw_on_rhi.R
5414279 k_fold_ebrw.R
5414288 k_fold_liwc_rhi.R
5414287 k_fold_liwc_sat.R
5414276 k_fold_math_on_rhi.R
5414280 k_fold_math.R
5414286 k_fold_sat_on_rhi.R
5414283 k_fold_topic_rhi.R
5414273 k_fold_topic_sat.R
5414272 ldatuning_plot.R
5414275 merged_on_sat_by_decile_fig_3.R
5414281 pennebaker_replication.R
5414285 primary_results.R
5414277 readability_regs.R
5414278 sat_var_by_decile.R
atrisovic commented 1 year ago

That explains it! It works with the brackets :))