Skip to content

Commit 9eb0ff0

Browse files
committed
remove old pyDataverse methods (now supported natively)
1 parent 9c6dd7f commit 9eb0ff0

3 files changed

Lines changed: 2 additions & 107 deletions

File tree

src/downloads.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ using Tar, CodecZlib, ZipFile
77

88
##
99

10-
OCCA_file_list()=file_list(:OCCA_clim)
11-
ECCO_file_list()=file_list(:ECCO_clim)
12-
13-
##
14-
1510
"""
1611
file_download(DOI::String,nam::String,pth=tempdir())
1712

src/pyDataverse.jl

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
11
module pyDataverse
22

33
using DataFrames
4-
import Dataverse.restDataverse: files_to_DataFrame
54
import Dataverse: pyDataverse_APIs
65

7-
"""
8-
APIs(;do_install=true,base_url = "https://dataverse.harvard.edu/")
9-
10-
```
11-
(DataAccessApi,NativeApi)=pyDataverse.APIs()
12-
```
13-
"""
14-
function APIs(;do_install=true,base_url = "https://dataverse.harvard.edu/")
15-
error("pyDataverse_APIs is now available via the PyCall extension.")
16-
end
17-
18-
"""
19-
demo(option::String)
20-
21-
- call `demo_download` if `option=="download"`
22-
- call `demo_metadata` if `option=="metadata"`
23-
"""
24-
function demo(option="download")
25-
if option=="download"
26-
demo_download()
27-
elseif option=="metadata"
28-
demo_metadata()
29-
else
30-
println("unknown option")
31-
end
32-
end
33-
346
"""
357
demo_download(;path=tempdir(),DOI = "doi:10.7910/DVN/KBHLOD")
368
@@ -57,72 +29,4 @@ function demo_download(;path=tempdir(),DOI = "doi:10.7910/DVN/KBHLOD")
5729
filenames
5830
end
5931

60-
#Deprecated : see `dataset_file_list`+`files_to_DataFrame` instead
61-
function tree_children_to_DataFrame(files)
62-
nf=length(files)
63-
filename=[files[ff]["filename"] for ff in 1:nf]
64-
pid=[files[ff]["pid"] for ff in 1:nf]
65-
datafile_id=[files[ff]["datafile_id"] for ff in 1:nf]
66-
DataFrame(filename=filename,pid=pid,datafile_id=datafile_id)
67-
end
68-
69-
"""
70-
demo_metadata()
71-
72-
```
73-
pyDataverse.demo_metadata()
74-
```
75-
"""
76-
function demo_metadata()
77-
df1=dataset_file_list(:OCCA_clim)
78-
df2=dataverse_file_list(:ECCOv4r2)
79-
df1,df2
80-
end
81-
82-
##
83-
84-
"""
85-
dataset_file_list(nam::Symbol=:OCCA_clim)
86-
87-
Lookup DOI from list of demo data sets.
88-
89-
```
90-
dataset_file_list(:OCCA_clim)
91-
```
92-
"""
93-
function dataset_file_list(nam::Symbol)
94-
(DataAccessApi,NativeApi)=pyDataverse_APIs()
95-
DOI=(OCCA_clim="doi:10.7910/DVN/RNXA2A",ECCO_clim="doi:10.7910/DVN/3HPRZI")
96-
dataset_file_list(DOI[nam])
97-
end
98-
99-
"""
100-
dataset_file_list(DOI::String="doi:10.7910/DVN/ODM2IQ")
101-
102-
Use `NativeApi.get_dataset` to derive the list of files (name, etc) via `files_to_DataFrame`.
103-
104-
```
105-
dataset_file_list("doi:10.7910/DVN/ODM2IQ")
106-
```
107-
"""
108-
function dataset_file_list(DOI::String)
109-
(DataAccessApi,NativeApi)=pyDataverse_APIs()
110-
dataset = NativeApi.get_dataset(DOI)
111-
dataset_files = dataset.json()["data"]["latestVersion"]["files"]
112-
files_to_DataFrame(dataset_files)
113-
end
114-
115-
"""
116-
dataverse_file_list(nam::Symbol=:ECCOv4r2)
117-
118-
- Use `NativeApi.get_children` to get the tree of datasets
119-
- Loop through and return vector of `dataset_file_list` output
120-
"""
121-
function dataverse_file_list(nam::Symbol=:ECCOv4r2)
122-
(DataAccessApi,NativeApi)=pyDataverse_APIs()
123-
tree = NativeApi.get_children(string(nam), children_types= ["datasets", "datafiles"])
124-
#[tree_children_to_DataFrame(leaf["children"]) for leaf in tree]
125-
[dataset_file_list(leaf["pid"]) for leaf in tree]
126-
end
127-
12832
end

test/runtests.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ if do_py_test>0
88
end
99

1010
if do_py_test>1
11-
tmp=pyDataverse.demo("download")
11+
tmp=pyDataverse.demo_download()
1212
@test isfile(tmp[1])
13-
14-
df1,df2=pyDataverse.demo("metadata")
15-
@test size(df1,1)==56
16-
@test size(df2,1)==11
1713
end
1814

1915
@testset "Dataverse.jl" begin
@@ -23,7 +19,7 @@ end
2319
j=json_ld.get("10.7910/DVN/CAGYQL")
2420
@test j["@type"]=="sc:Dataset"
2521

26-
lst=Dataverse.downloads.OCCA_file_list()
22+
lst=Dataverse.file_list(:OCCA_clim)
2723
pth=joinpath(tempdir(),string(UUIDs.uuid4()))
2824
mkdir(pth)
2925

0 commit comments

Comments
 (0)