Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Riricdata
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
Container Registry
Model registry
Operate
Environments
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
Riricdata
Commits
1fe53e39
Commit
1fe53e39
authored
4 years ago
by
LouisGendron
Browse files
Options
Downloads
Patches
Plain Diff
Improved validation of 'dataset' parameter in 'file_upload'
parent
7c785cac
No related branches found
No related tags found
1 merge request
!3
Resolve "fetch files annotations when download dataset"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/IRICData-class.R
+29
-8
29 additions, 8 deletions
R/IRICData-class.R
with
29 additions
and
8 deletions
R/IRICData-class.R
+
29
−
8
View file @
1fe53e39
...
...
@@ -170,27 +170,48 @@ setMethod(
# Upload file
setGeneric
(
name
=
"file_upload"
,
def
=
function
(
object
,
session
,
file_path
,
annotation
=
''
,
lab
=
''
,
dataset
=
''
){
def
=
function
(
object
,
session
,
file_path
,
annotation
s
=
''
,
lab
=
''
,
dataset
=
''
){
standardGeneric
(
"file_upload"
)
}
)
setMethod
(
f
=
'file_upload'
,
signature
=
'IRICData'
,
definition
=
function
(
object
,
session
,
file_path
,
annotation
=
''
,
lab
=
''
,
dataset
=
''
){
definition
=
function
(
object
,
session
,
file_path
,
annotations
=
''
,
lab
=
''
,
dataset
=
''
){
error
=
FALSE
#Check if annotation can be parsed as JSON
if
(
typeof
(
annotation
)
==
'list'
){
annotation
<-
toJSON
(
annotation
)}
else
if
(
typeof
(
annotation
)
==
'character'
){
validation
=
jsonlite
::
validate
(
annotation
)
if
(
typeof
(
annotation
s
)
==
'list'
){
annotation
s
<-
toJSON
(
annotation
)}
else
if
(
typeof
(
annotation
s
)
==
'character'
){
validation
=
jsonlite
::
validate
(
annotation
s
)
if
(
!
(
validation
[[
1
]])){
print
(
paste
(
'Error occured while uploading'
,
file_path
,
': the annotation parameter could not be parsed as JSON'
))
return
(
NULL
)
error
=
TRUE
}
}
#TO DO : check is lab is available
#Check if dataset is available
if
(
dataset
!=
''
)
{
datasets
=
get_available_dataset
(
object
,
session
)
if
(
!
(
dataset
%in%
datasets
$
Slug_id
)){
print
(
"ERROR : 'dataset' parameter does not match of any of the available dataset, try get_available_dataset(client, session) for more details."
)
error
=
TRUE
}
else
{
#Check if the file is already in the dataset
dataset_details
=
get_dataset_hash
(
IData
,
IData_session
,
dataset
)
if
(
file_name
%in%
dataset_details
$
file_name
){
print
(
paste
(
'WARNING : file'
,
file_name
,
'already exist in the selected dataset.'
))
}
}
}
if
(
error
){
return
(
NULL
)
}
file_form
=
list
(
file
=
httr
::
upload_file
(
file_path
),
lab
=
lab
,
annotations
=
annotation
,
dataset
=
dataset
)
lab
=
lab
,
annotations
=
annotation
s
,
dataset
=
dataset
)
session
=
rvest
:::
request_POST
(
x
=
IData_session
,
body
=
file_form
,
url
=
paste
(
object
@
url
,
'secure/servlet/datafiles/upload'
,
sep
=
'/'
))
...
...
@@ -254,7 +275,7 @@ setMethod(
definition
=
function
(
object
,
session
){
resp
=
rvest
::
jump_to
(
IData_session
,
paste
(
IData
@
url
,
'secure/my-datasets/list/json/'
,
sep
=
'/'
))
output
=
as.data.frame
(
jsonlite
::
fromJSON
(
rawToChar
(
resp
$
response
$
content
)))
names
(
output
)
=
c
(
'
Name'
,
'Slug_id
'
)
names
(
output
)
=
c
(
'
Dataset_name'
,
'Dataset_slug
'
)
return
(
output
)
}
)
...
...
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