python-irodsclient icon indicating copy to clipboard operation
python-irodsclient copied to clipboard

local and remote opening appears to matter when writing

Open trel opened this issue 2 years ago • 4 comments

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...

  1. Works - open iRODS data object for write, then open local file for read

  2. 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())

trel avatar Nov 20 '23 17:11 trel

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.

d-w-moore avatar Nov 20 '23 22:11 d-w-moore

Please confirm the opposite as well... (open iRODS first, then local).

trel avatar Nov 20 '23 22:11 trel

Confirmed, works with the with-clauses inverted.

d-w-moore avatar Nov 21 '23 00:11 d-w-moore

well, that's comforting. okay. not a priority until someone can show us it's broken. thanks.

trel avatar Nov 21 '23 00:11 trel

I think we can probably close this as resolved / invalid.

trel avatar Jan 21 '25 01:01 trel

Agreed. Please close it.

korydraughn avatar Jan 22 '25 22:01 korydraughn

closing.

trel avatar Jan 22 '25 22:01 trel