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

JSON dump problem #332

Closed
bedroesb opened this issue May 21, 2019 · 2 comments
Closed

JSON dump problem #332

bedroesb opened this issue May 21, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@bedroesb
Copy link

When I try to dump with ISA JSON using:

from isatools.isajson import ISAJSONEncoder
json.dumps(investigation, cls=ISAJSONEncoder, sort_keys=True, indent=4, separators=(',', ': '))

I get following error:

2019-05-21 11:43:28,237 [ERROR]: brapi_to_isa.py(<module>:424) >> 'str' object has no attribute 'term'
Traceback (most recent call last):
  File "brapi_to_isa.py", line 422, in <module>
    main(arg=SERVER)
  File "brapi_to_isa.py", line 373, in main
    json.dumps(investigation, cls=ISAJSONEncoder, sort_keys=True, indent=4, separators=(',', ': '))
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.6/json/encoder.py", line 437, in _iterencode
    o = _default(o)
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1832, in default
    "studies": list(map(lambda x: get_study(x), o.studies))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1832, in <lambda>
    "studies": list(map(lambda x: get_study(x), o.studies))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1775, in get_study
    "assays": list(map(lambda x: get_assay(x), o.assays))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1775, in <lambda>
    "assays": list(map(lambda x: get_assay(x), o.assays))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1798, in get_assay
    "characteristicCategories": get_characteristic_categories(o.characteristic_categories),
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1780, in get_characteristic_categories
    return list(map(lambda x: get_characteristic_category(x), o))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1780, in <lambda>
    return list(map(lambda x: get_characteristic_category(x), o))
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1663, in get_characteristic_category
    "characteristicType": get_ontology_annotation(o)
  File "/usr/local/lib/python3.6/dist-packages/isatools/isajson.py", line 1568, in get_ontology_annotation
    "annotationValue": o.term,
AttributeError: 'str' object has no attribute 'term'

The isatab.dump instead works flawless on the given dataset.

@Zigur
Copy link
Contributor

Zigur commented Jul 7, 2020

I will add a test where we create an investigation with characteristic_category set as a string, and see whether serialising this to JSON triggers an error.

Potential problematic line: https://github.com/ISA-tools/isa-api/blob/master/isatools/model.py#L2706

@proccaserra proccaserra modified the milestones: 0.10.5, 0.12 Jul 7, 2020
@proccaserra proccaserra added the bug label Jul 7, 2020
@Zigur
Copy link
Contributor

Zigur commented Jan 18, 2021

Verify if a test takes care of this issue

Zigur added a commit that referenced this issue Jan 21, 2021
Zigur added a commit that referenced this issue Jan 21, 2021
@Zigur Zigur closed this as completed Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants