Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mrdata common public
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
hpc-kyb
mrdata common public
Commits
deaf7535
Commit
deaf7535
authored
9 months ago
by
Blake Fitch
Browse files
Options
Downloads
Patches
Plain Diff
enable proper handling of dcm2niix stdout and stderr when additional DICOM files come for a series
parent
d6c0daaf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pymods/irods_utils/irods_utils.py
+33
-26
33 additions, 26 deletions
pymods/irods_utils/irods_utils.py
with
33 additions
and
26 deletions
pymods/irods_utils/irods_utils.py
+
33
−
26
View file @
deaf7535
...
...
@@ -314,7 +314,8 @@ def streaming_transfer_file_to_object( args ):
irods_obj_handle
=
target_obj
.
open
(
'
w
'
,
checksum
=
True
)
except
Exception
as
ex
:
logging
.
error
(
"
Failed open irods object for transfer. file:
"
+
file_pathname
+
"
to irods ipath:
"
+
irods_ipath
+
"
ex:
"
+
str
(
ex
)
)
return
-
1
,
hasher256
,
hasher512
,
0
raise
#return -1, hasher256, hasher512, 0
try
:
with
open
(
file_pathname
,
'
rb
'
)
as
input_file
:
...
...
@@ -337,7 +338,8 @@ def streaming_transfer_file_to_object( args ):
+
"
to irods_ipath:
"
+
irods_ipath
+
"
ex:
"
+
str
(
ex
)
)
#return None
rc
=
-
1
#rc = -1
raise
irods_obj_handle
.
close
()
...
...
@@ -365,9 +367,9 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
# a network file system twice due to blowing cache.
# So, we upload to temp, checkusmming along the way, and then check for a pre-existing irods object.
if
irods_sesh
==
None
:
logging
.
error
(
"
irods_sesh == None
"
)
return
None
#
if irods_sesh == None:
#
logging.error( "irods_sesh == None" )
#
return None
# Figure out if this path in the archive is occupied with pre-existing data.
existing_obj
=
None
...
...
@@ -381,7 +383,7 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging
.
debug
(
"
OBJ_PATH_DOES_NOT_EXIST
"
+
new_obj_ipath
)
except
Exception
as
ex
:
logging
.
error
(
"
Failed using data_onject.get() (but not DataObjectDoesNotExist) ipath:
"
+
new_obj_ipath
+
"
ex:
"
+
str
(
ex
)
+
"
type
"
+
str
(
type
(
ex
))
)
r
eturn
Non
e
r
ais
e
try
:
upload_file_size
=
os
.
path
.
getsize
(
file_pathname
)
...
...
@@ -390,9 +392,10 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
raise
if
upload_file_size
==
0
and
existing_obj
!=
None
and
replace_existing
and
skip_on_zero_len
:
logging
.
warning
(
f
"
got zero len file with replace_existing -- removing current data object. ipath:
{
new_obj
ect
_ipath
}
"
)
logging
.
warning
(
f
"
got zero len file with replace_existing -- removing current data object. ipath:
{
new_obj_ipath
}
"
)
try
:
existing_obj
.
unlink
(
force
=
True
)
return
0
except
Exception
as
ex
:
logging
.
warning
(
"
Failed remove zero line file on replace_existing and skip_on_zero_len. ipath: {new_obj_ipath} ex: {ex}
"
)
raise
...
...
@@ -411,7 +414,7 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
+
"
file_pathname:
"
+
file_pathname
+
"
tmp ipath:
"
+
new_obj_ipath_tmp
+
"
ex:
"
+
str
(
axe
)
)
r
eturn
Non
e
r
ais
e
run_args
=
[
file_pathname
,
irods_sesh
,
new_obj_ipath_tmp
,
block_size
]
...
...
@@ -425,11 +428,11 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
hash_digest512
=
run_results
[
2
]
transfer_size
=
run_results
[
3
]
if
transfer_rc
<
0
:
if
transfer_rc
<
0
:
# Maybe not needed ... take out the rc part of the return
logging
.
error
(
"
Falied transfer file to irods oobject.
"
+
"
file_pathname:
"
+
file_pathname
+
"
tmp ipath:
"
+
new_obj_ipath_tmp
)
return
None
sys
.
exit
(
-
1
)
# Example here: https://github.com/irods/python-irodsclient/blob/main/irods/test/helpers.py#L251
# ... in function: def compute_sha256_digest(file_path):
...
...
@@ -455,7 +458,7 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
except
Exception
as
ex
:
logging
.
error
(
"
Failed to create AVUS on iRODS object. ipath:
"
+
new_obj_ipath
+
"
ex:
"
+
str
(
ex
)
)
logging
.
error
(
"
metadata AVU dict >
"
+
str
(
metadata_dict
)
+
"
<
"
)
r
eturn
Non
e
r
ais
e
mismatch
=
False
...
...
@@ -492,7 +495,7 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging
.
error
(
"
Failed to move an existing object out of the way so can not upload current version.
"
+
"
path
"
+
existing_obj
.
path
+
"
ex:
"
+
str
(
ex
)
)
r
eturn
Non
e
r
ais
e
logging
.
warn
(
f
"
Moved mismatching existing object (reason:
{
mismatch_reason
}
) to ipath:
{
dup_ipath
}
"
)
# Fall through to move newly uploaded object into place.
else
:
...
...
@@ -503,10 +506,11 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging
.
error
(
"
Failed to inlink newly created, but duplicate object.
"
+
"
new_obj_ipath_tmp:
"
+
str
(
new_obj_ipath_tmp
)
+
"
ex:
"
+
str
(
ex
)
)
raise
logging
.
warn
(
"
Existing object matched data and metadata at ipath (removed uploaded tmp object):
"
+
"
ipath:
"
+
new_obj_ipath
)
return
existing_obj
return
transfer_size
# Move the tmp object to the proper object ipath.
try
:
...
...
@@ -516,7 +520,7 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
+
"
new_obj_ipath_tmp:
"
+
new_obj_ipath_tmp
+
"
new_obj_ipath:
"
+
new_obj_ipath
+
"
ex:
"
+
str
(
ex
)
)
r
eturn
Non
e
r
ais
e
logging
.
debug
(
"
file
"
+
file_pathname
+
"
in place at ipath
"
+
new_obj_ipath
)
...
...
@@ -527,19 +531,22 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
dup_obj
.
unlink
(
force
=
True
)
except
Exception
as
ex
:
logging
.
warning
(
"
Failed remove dup when remove_existing flag set. ipath: {dup_ipath} ex: {ex}
"
)
raise
new_obj
=
None
try
:
new_obj
=
irods_sesh
.
data_objects
.
get
(
new_obj_ipath
)
except
Exception
as
ex
:
logging
.
error
(
"
Failed data_onject.open(). ipath:
"
+
new_obj_ipath
+
"
ex:
"
+
str
(
ex
)
)
return
None
logging
.
debug
(
"
Returning new object handle for:
"
+
"
file_pathname:
"
+
file_pathname
+
"
new_obj.ipath:
"
+
new_obj
.
path
)
return
new_obj
return
transfer_size
#new_obj = None
#try:
# new_obj = irods_sesh.data_objects.get( new_obj_ipath )
#except Exception as ex:
# logging.error("Failed data_onject.open(). ipath: " + new_obj_ipath + " ex: " + str(ex) )
#
#
#logging.debug( "Returning new object handle for: "
# + " file_pathname: " + file_pathname
# + " new_obj.ipath: " + new_obj.path )
#
#return new_obj
# Bring in the experiment validation code
...
...
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