local and remote opening appears to matter when writing
To investigate / reproduce...
- iRODS 4.2.7
- PRC 1.1.8
- Python 3.11.2
Reported issue with opening a local file and writing to iRODS...
-
Works - open iRODS data object for write, then open local file for read
-
Does not work - open local file for read, then open iRODS data object for write
with open(local_bam_file, 'rb') as f_a:
uploaded_obj = f'{coll}{obj_name}'
with uploaded_obj.open('w', **options) as irods_f_a:
irods_f_a.write(f_a.read())
The script here fails to reproduce the issue (runs and performs as expected, without errors), but is structurally identical to the snippet above. Maybe we could try it out on the platform mentioned above (4.2.7/1.1.8/Py3.11.2) ? It takes a local file called aabc.dat and writes its content to a new data object.
#--script write_dataobj_with_local_file.py--
from irods.test.helpers import make_session as ms
ses=ms()
options = dict()
local_bam_file = 'aabc.dat'
coll = '/tempZone/home/rods/'
obj_name = 'aabc.datobj'
uploaded_name = '{coll}{obj_name}'.format(**locals())
with open(local_bam_file, 'rb') as f_a:
uploaded_obj = ses.data_objects.create(uploaded_name) #1
with uploaded_obj.open('w', **options) as irods_f_a: #1
irods_f_a.write(f_a.read()) #1
# with ses.data_objects.open(uploaded_name, 'w', **options) as irods_f_a: #2
# irods_f_a.write(f_a.read()) #2
Note sections marked with #1 and #2 are parallel ways of accomplishing the same thing, so comment in and out to alternate between the two as desired.
Please confirm the opposite as well... (open iRODS first, then local).
Confirmed, works with the with-clauses inverted.
well, that's comforting. okay. not a priority until someone can show us it's broken. thanks.
I think we can probably close this as resolved / invalid.
Agreed. Please close it.
closing.