Skip to content

omero transfer prepare needs a connection but omero import -f does not #95

@glyg

Description

@glyg

omero transfer prepare fails to execute for a simple user if $OMERODIR is not defined or points to a non existing directory.

Creating $OMERODIR even as an empty directory allows omero transfer prepare to run.

omero transfer prepare calls omero import -f in generate_xml through a CLI() instance.
The OMERODIR not found error happens at this line, but further traceback is lost by the subcommand

from omero.cli import CLI

cli = CLI()
cli.loadplugins()
cli.invoke(['logout'])



# import -f works
cli.invoke(['import', '-f', '.'])


# output
"""
Using OMERO.java-5.6.6-ice36
2025-02-13 13:48:43,780 103        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.6.0
2025-02-13 13:48:43,788 111        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 6.11.1 revision: 383bac974cd52e83908b54e4769ebb1e0d0673ee date: 1 December 2022
2025-02-13 13:48:43,826 149        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2025-02-13 13:48:43,976 299        [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 4 Metadata Level: MINIMUM
2025-02-13 13:48:44,099 422        [      main] ERROR                  loci.formats.ImageReader - File has length 0 and may be corrupt
2025-02-13 13:48:44,109 432        [      main] INFO      ome.formats.importer.ImportCandidates - 8 file(s) parsed into 0 group(s) with 8 call(s) to setId in 127ms. (133ms total) [8 unknowns]
"""

# We are not connected, this fails
cli.invoke(['fs', 'images'])

# output
"""
Previously logged in to localhost:4064 as facility0
stdin is not a terminal: cannot request server
"""


# this fails too
cli.invoke(['transfer', 'prepare', '.'])

# output
"""
Previously logged in to localhost:4064 as facility0
stdin is not a terminal: cannot request server
"""

# Now connect
cli.invoke(['login', '-w', 'omero', 'facility0@localhost'])

"""
Previously logged in to localhost:4064 as facility0
Created session for facility0@localhost:4064. Idle timeout: 10 min. Current group: default
"""



Path(os.environ['OMERODIR']).exists()

# output
"""
False
"""


# run transfer prepare while logged in
cli.invoke(['transfer', 'prepare', '.'])

# output
"""
Using session for facility0@localhost:4064. Idle timeout: 10 min. Current group: default


Truncated Traceback (Use C-c C-$ to view full TB):
File ~/miniforge3/envs/quay/lib/python3.10/subprocess.py:1847, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1845     if errno_num != 0:
   1846         err_msg = os.strerror(errno_num)
-> 1847     raise child_exception_type(errno_num, err_msg, err_filename)
   1848 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: '/home/guillaume/OMERO.server'
"""

# create an empty dir
Path(os.environ["OMERODIR"]).mkdir()

# This succeeds
cli.invoke(['transfer', 'prepare', '.'])

"""
Using session for facility0@localhost:4064. Idle timeout: 10 min. Current group: default
"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions