Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local and remote opening appears to matter when writing #493

Open
trel opened this issue Nov 20, 2023 · 4 comments
Open

local and remote opening appears to matter when writing #493

trel opened this issue Nov 20, 2023 · 4 comments

Comments

@trel
Copy link
Member

trel commented Nov 20, 2023

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())
@d-w-moore
Copy link
Collaborator

d-w-moore commented Nov 20, 2023

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.

@trel
Copy link
Member Author

trel commented Nov 20, 2023

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

@d-w-moore
Copy link
Collaborator

d-w-moore commented Nov 21, 2023

Confirmed, works with the with-clauses inverted.

@trel
Copy link
Member Author

trel commented Nov 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants