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
1096bfff
Commit
1096bfff
authored
9 months ago
by
Blake Fitch
Browse files
Options
Downloads
Patches
Plain Diff
add replace_existing flag and function to confirmed_put()
parent
2cd63f06
No related branches found
Branches containing commit
Tags
STAG-2024-06-23-13-13-11
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
+11
-2
11 additions, 2 deletions
pymods/irods_utils/irods_utils.py
with
11 additions
and
2 deletions
pymods/irods_utils/irods_utils.py
+
11
−
2
View file @
1096bfff
...
...
@@ -350,11 +350,12 @@ def streaming_transfer_file_to_object( args ):
return
rc
,
hash_digest256
,
hash_digest512
,
transfer_size
# Returns None or the data_object irods ref.
def
confirmed_put
(
irods_sesh
,
file_pathname
,
new_obj_ipath
,
metadata_dict
=
None
,
datatype
=
None
,
block_size
=
(
2
**
28
)
):
def
confirmed_put
(
irods_sesh
,
file_pathname
,
new_obj_ipath
,
metadata_dict
=
None
,
datatype
=
None
,
block_size
=
(
2
**
28
)
,
replace_existing
=
None
):
logging
.
debug
(
"
file_pathname:
"
+
file_pathname
+
"
new_obj_ipath:
"
+
new_obj_ipath
+
"
datatype:
"
+
datatype
+
"
block_size:
"
+
str
(
block_size
)
)
+
"
block_size:
"
+
str
(
block_size
)
+
"
replace_existing
"
+
str
(
replace_existing
)
)
# NOTE: this routine uploades the file as a temporary iRODS object.
# Common sense suggests checking if the objct already exsists, a rare condition first.
...
...
@@ -504,6 +505,14 @@ def confirmed_put( irods_sesh, file_pathname, new_obj_ipath, metadata_dict=None,
logging
.
debug
(
"
file
"
+
file_pathname
+
"
in place at ipath
"
+
new_obj_ipath
)
if
existing_obj
!=
None
and
replace_existing
:
logging
.
warning
(
f
"
replace_existing flag set. Removing old data object. ipath:
{
dup_ipath
}
"
)
try
:
dup_obj
=
irods_sesh
.
data_objects
.
get
(
dup_ipath
)
dup_obj
.
unlink
(
force
=
True
)
except
Exception
as
ex
:
logging
.
warning
(
"
Failed remove dup when remove_existing flag set. ipath: {dup_ipath} ex: {ex}
"
)
new_obj
=
None
try
:
new_obj
=
irods_sesh
.
data_objects
.
get
(
new_obj_ipath
)
...
...
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