Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyiricdata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioinfo_iric
pyiricdata
Commits
2a4c0057
Commit
2a4c0057
authored
4 years ago
by
Albert Feghaly
Browse files
Options
Downloads
Patches
Plain Diff
Use metadata instead of filename
parent
0d59783b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Resolve "Allow to keep file content in memory"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyiricdata/Client.py
+4
-24
4 additions, 24 deletions
pyiricdata/Client.py
with
4 additions
and
24 deletions
pyiricdata/Client.py
+
4
−
24
View file @
2a4c0057
...
...
@@ -13,7 +13,7 @@ from collections import namedtuple
from
.tools
import
is_json
IDF
=
namedtuple
(
'
IricDataFile
'
,
[
'
na
me
'
,
'
data
'
,
'
metadata
'
])
IDF
=
namedtuple
(
'
IricDataFile
'
,
[
'
me
tadata
'
,
'
data
'
,
'
annotations
'
])
class
Client
:
...
...
@@ -174,25 +174,6 @@ class Client:
def
get_dataset_filelist
(
self
,
dataset_id
):
sys
.
stderr
.
write
(
"
DEPRECATED: Please use
"
+
"
get_list_datafiles(dataset_id=dataset_id)
\n
"
)
# df = pd.DataFrame(columns=['file_id', 'file_name', 'file_hash', 'file_slug'])
# if dataset_id not in self.datasets.index:
# sys.stderr.write(
# "ERROR: Dataset '{}' does not exist or you do not have permission to access it.".format(dataset_id) +\
# " Try Client.datasets for more details.\n")
# return df
# files = self.session.get(os.path.join(self.url, 'secure/dataset', dataset_id, 'file-list')).text.split('\n')
# file_id_list = np.unique([x.split('/')[-1] for x in files])
# df.file_id = file_id_list
# if files != ['']:
# for index, row in df.iterrows():
# file_meta = self.get_file_metadata(row['file_id'])
# assert not file_meta is None
# row['file_name'] = file_meta['filename']
# row['file_slug'] = file_meta['iric_data_id']
# row['file_hash'] = file_meta['hash']
# df.index = df.file_slug.copy()
# df.index.name = 'ID'
return
(
self
.
get_list_datafiles
(
dataset_id
=
dataset_id
))
"""
Get DatasetId by name
"""
...
...
@@ -205,13 +186,12 @@ class Client:
"""
Get file content according to file_id
"""
def
get_file
(
self
,
file_id
):
file_object
=
self
.
get_file_metadata
(
file_id
)
path
=
os
.
path
.
join
(
self
.
url
,
'
secure/datafiles/download
'
,
str
(
file_id
))
try
:
file_
name
=
file_object
[
'
filename
'
]
file_
metadata
=
self
.
get_file_metadata
(
file_id
)
file_content
=
self
.
session
.
get
(
path
,
allow_redirects
=
True
).
content
file_annotation
=
self
.
get_file_metadata
(
file_id
)
return
IDF
(
file_
na
me
,
file_content
,
file_annotation
)
return
IDF
(
file_me
tadata
,
file_content
,
file_annotation
)
except
TypeError
:
return
IDF
(
None
,
None
,
None
)
...
...
@@ -224,7 +204,7 @@ class Client:
else
:
folder_out
=
os
.
path
.
join
(
os
.
getcwd
(),
folder_out
)
os
.
makedirs
(
folder_out
,
exist_ok
=
True
)
filename
=
idf
.
name
if
not
filename
else
filename
filename
=
idf
.
metadata
[
'
file
name
'
]
if
not
filename
else
filename
out_file_path
=
os
.
path
.
join
(
folder_out
,
filename
)
if
os
.
path
.
exists
(
out_file_path
):
sys
.
stderr
.
write
(
'
Warning: File already exists at location %s, skipping.
\n
'
%
out_file_path
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment