singularityhub / singularity-hpc

Local filesystem registry for containers (intended for HPC) using Lmod or Environment Modules. Works for users and admins.
https://singularity-hpc.readthedocs.io
Mozilla Public License 2.0
111 stars 26 forks source link

running shpc show with pipe command leads to exception #645

Closed shahzebsiddiqui closed 1 year ago

shahzebsiddiqui commented 1 year ago

Describe the bug

I was trying to run shpc show and filter by first x lines using head or tail and this led to exception

(singularity-hpc)  ~/gitrepos/singularity-hpc/ [main*] shpc show | head -n 5
adminer
bids/aa
bids/baracus
bids/brainiak-srm
bids/brainsautoworkup
Traceback (most recent call last):
  File "/global/u1/s/siddiq90/.local/share/virtualenvs/singularity-hpc-9qpnFEzH/bin/shpc", line 33, in <module>
    sys.exit(load_entry_point('singularity-hpc', 'console_scripts', 'shpc')())
  File "/global/u1/s/siddiq90/gitrepos/singularity-hpc/shpc/client/__init__.py", line 549, in run_shpc
    main(args=args, parser=parser, extra=extra, subparser=helper)
  File "/global/u1/s/siddiq90/gitrepos/singularity-hpc/shpc/client/show.py", line 22, in main
    cli.show(args.name, names_only=not args.versions, filter_string=args.filter_string)
  File "/global/u1/s/siddiq90/gitrepos/singularity-hpc/shpc/main/client.py", line 246, in show
    out.write("%s\n" % config.name)
BrokenPipeError: [Errno 32] Broken pipe

I can confirm this was an issue when piping with tail and more

To Reproduce Run shpc show | head -n 5

Expected behavior i should see the output without an exception. It looks like the file in client.py doing out.write

Version of Singularity and Singularity Registry HPC Client

(singularity-hpc)  ~/gitrepos/singularity-hpc/ [main*] shpc --version
0.1.21

Anything else?

vsoch commented 1 year ago

Please see https://github.com/singularityhub/singularity-hpc/pull/647

shahzebsiddiqui commented 1 year ago

Thanks I did take a look at the PR.