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

Reading JSON mysteriously fails #39

Closed
mtbc opened this issue May 12, 2020 · 3 comments · Fixed by ome/omero-py#213
Closed

Reading JSON mysteriously fails #39

mtbc opened this issue May 12, 2020 · 3 comments · Fixed by ome/omero-py#213
Labels
bug Something isn't working

Comments

@mtbc
Copy link
Member

mtbc commented May 12, 2020

$ omero render info 5251 --style=yaml >/tmp/foo.yaml
Using session for user-3@localhost:4064. Idle timeout: 10 min. Current group: read-only-1
$ omero render set Image:5251 /tmp/foo.yaml 
Using session for user-3@localhost:4064. Idle timeout: 10 min. Current group: read-only-1
/tmp/omero/lib/python3.5/site-packages/omero/util/pydict_text_io.py:81: YAMLLoadWarning: calling yaml.load_all() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  data = list(yaml.load_all(rawdata))
$ omero render info 5251 --style=json >/tmp/foo.json
Using session for user-3@localhost:4064. Idle timeout: 10 min. Current group: read-only-1
$ omero render set Image:5251 /tmp/foo.json
Using session for user-3@localhost:4064. Idle timeout: 10 min. Current group: read-only-1
Could not read /tmp/foo.json
$ 
@sbesson sbesson added the question Further information is requested label May 12, 2020
@sbesson
Copy link
Member

sbesson commented May 12, 2020

I failed to reproduce locally

[sbesson@ome-demoserver ~]$  venv/bin/omero render info 120100 --style=yaml > /tmp/foo.yml
Using session for sbesson@localhost:4064. Idle timeout: 10 min. Current group: 2018-11
[sbesson@ome-demoserver ~]$ venv/bin/omero render set Image:120100 /tmp/foo.yml 
Using session for sbesson@localhost:4064. Idle timeout: 10 min. Current group: 2018-11
/fc/homes/sbesson/venv/lib64/python3.6/site-packages/omero/util/pydict_text_io.py:81: YAMLLoadWarning: calling yaml.load_all() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  data = list(yaml.load_all(rawdata))
[sbesson@ome-demoserver ~]$ venv/bin/omero render info 120100 --style=json > /tmp/foo.json
Using session for sbesson@localhost:4064. Idle timeout: 10 min. Current group: 2018-11
[sbesson@ome-demoserver ~]$ venv/bin/omero render set Image:120100 /tmp/foo.json
Using session for sbesson@localhost:4064. Idle timeout: 10 min. Current group: 2018-11

My environment is as follows:

[sbesson@ome-demoserver ~]$ venv/bin/pip freeze
future==0.18.2
numpy==1.18.4
omero-cli-render==0.5.0
omero-py==5.6.2
Pillow==7.1.2
PyYAML==5.3.1
zeroc-ice==3.6.5

Can you give the output of the following command which should log the underlying exception at the DEBUG level?

omero --debug=DEBUG render set Image:5251 /tmp/foo.json

@mtbc
Copy link
Member Author

mtbc commented May 12, 2020

$ omero --debug=DEBUG render set Image:5251 /tmp/foo.json
Using session for user-3@localhost:4064. Idle timeout: 10 min. Current group: read-only-1
Error printing text
the JSON object must be str, not 'bytes'
Traceback (most recent call last):
  File "/tmp/omero/lib/python3.5/site-packages/omero_cli_render.py", line 590, in _load_rendering_settings
    data = pydict_text_io.load(source, session=session)
  File "/tmp/omero/lib/python3.5/site-packages/omero/util/pydict_text_io.py", line 91, in load
    data = json.loads(rawdata)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/omero/lib/python3.5/site-packages/omero/cli.py", line 523, in safePrint
    stream.write(text)
TypeError: write() argument must be str, not TypeError
Could not read /tmp/foo.json
$ pip freeze
attrs==19.3.0
certifi==2020.4.5.1
chardet==3.0.4
Deprecated==1.2.9
Django==1.11.29
django-pipeline==1.6.14
flake8==2.4.0
future==0.18.2
gunicorn==20.0.4
idna==2.9
importlib-metadata==1.6.0
mccabe==0.3.1
more-itertools==8.2.0
numexpr==2.7.1
numpy==1.18.4
omero-cli-render==0.5.0
omero-marshal==0.7.0
omero-py==5.6.2
omero-web==5.6.3
packaging==20.3
pathlib2==2.3.5
pep8==1.5.7
Pillow==7.1.2
pkg-resources==0.0.0
pluggy==0.13.1
py==1.8.1
pyflakes==0.8.1
PyGithub==1.51
PyJWT==1.7.1
pyparsing==2.4.7
pytest==5.4.2
pytz==2020.1
PyYAML==5.3.1
requests==2.23.0
scc==0.12.8
six==1.14.0
tables==3.6.1
urllib3==1.25.9
wcwidth==0.1.9
websocket-client==0.57.0
wrapt==1.12.1
yaclifw==0.2.0
zeroc-ice==3.6.5
zipp==1.2.0
$

@mtbc
Copy link
Member Author

mtbc commented May 12, 2020

Thank you, I shall certainly have to remember that DEBUG trick.

@sbesson sbesson added bug Something isn't working and removed question Further information is requested labels May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants