psychoinformatics-de / datalad-schema

https://psychoinformatics-de.github.io/datalad-schema/
MIT License
0 stars 0 forks source link

AttributeError: 'str' object has no attribute 'decode' #6

Closed jsheunis closed 1 year ago

jsheunis commented 1 year ago

Error occurs during make test on my mac locally, as well as in the github-action on PR.See https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5:

Run make test
  make test
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.18/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
    Python[2](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:2)_ROOT_DIR: /opt/hostedtoolcache/Python/[3](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:3).9.18/x6[4](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:4)
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib
    VENV: .venv/bin/activate
poetry run gen-project --config-file config.yaml -d tmp src/datalad_schema/schema/datalad_schema.yaml
INFO:root:Generating: graphql
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/graphql
INFO:root: graphql ARGS: {'mergeimports': True}
INFO:root:  WRITING TO: tmp/graphql/datalad_schema.graphql
INFO:root:Generating: jsonldcontext
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/jsonld
INFO:root: jsonldcontext ARGS: {'mergeimports': True}
INFO:root:  WRITING TO: tmp/jsonld/datalad_schema.context.jsonld
INFO:root:Generating: jsonld
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/jsonld
INFO:root: jsonld ARGS: {'mergeimports': True, 'context': 'tmp/jsonld/datalad_schema.context.jsonld'}
INFO:root:  WRITING TO: tmp/jsonld/datalad_schema.jsonld
INFO:root:Generating: jsonschema
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/jsonschema
INFO:root:Using SchemaView with im=None
INFO:root: jsonschema ARGS: {'mergeimports': True}
INFO:root:Importing linkml:types as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/types from source src/datalad_schema/schema/datalad_schema.yaml; base_dir=None
INFO:root:  WRITING TO: tmp/jsonschema/datalad_schema.schema.json
INFO:root:Generating: markdown
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/docs
INFO:root: markdown ARGS: {'mergeimports': True, 'directory': 'tmp/docs', 'index_file': 'datalad_schema.md'}
INFO:root:Generating: owl
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/owl
INFO:root:Using SchemaView with im=None
INFO:root: owl ARGS: {'mergeimports': True, 'metaclasses': True, 'type_objects': True}
INFO:root:Importing linkml:types as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/types from source src/datalad_schema/schema/datalad_schema.yaml; base_dir=None
INFO:root:Importing linkml:units as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/units from source None; base_dir=None
INFO:root:Importing linkml:mappings as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/mappings from source None; base_dir=None
INFO:root:Importing linkml:types as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/types from source None; base_dir=None
INFO:root:Importing linkml:annotations as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/annotations from source None; base_dir=None
INFO:root:Importing linkml:extensions as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/extensions from source None; base_dir=None
WARNING:root:from_schema not populated for element primary_email
INFO:root:  WRITING TO: tmp/owl/datalad_schema.owl.ttl
INFO:root:Generating: prefixmap
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/prefixmap
INFO:root: prefixmap ARGS: {'mergeimports': True}
INFO:root:  WRITING TO: tmp/prefixmap/datalad_schema.yaml
INFO:root:Generating: proto
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/protobuf
INFO:root: proto ARGS: {'mergeimports': True}
INFO:root:  WRITING TO: tmp/protobuf/datalad_schema.proto
INFO:root:Generating: python
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp
INFO:root: python ARGS: {'mergeimports': True}
INFO:root:Importing linkml:types as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/types from source src/datalad_schema/schema/datalad_schema.yaml; base_dir=None
INFO:root:FALSE: OCCURS BEFORE: Dataset == Dataset owning: DatasetCollection
INFO:root:FALSE: OCCURS BEFORE: Dataset == Dataset owning: DatasetCollection
INFO:root:  WRITING TO: tmp/datalad_schema.py
INFO:root:Generating: shex
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/shex
INFO:root: shex ARGS: {'mergeimports': True}
INFO:root:  WRITING TO: tmp/shex/datalad_schema.shex
INFO:root:Generating: shacl
INFO:root: SCHEMA: src/datalad_schema/schema/datalad_schema.yaml
INFO:root: PARENT=tmp/shacl
INFO:root: shacl ARGS: {'mergeimports': True}
INFO:root:Importing linkml:types as /home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/model/schema/types from source src/datalad_schema/schema/datalad_schema.yaml; base_dir=None
Traceback (most recent call last):
ALL_SCHEMAS = ['src/datalad_schema/schema/datalad_schema.yaml']
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/bin/gen-project", line 8, in <module>
# metamodel_version: 1.7.0
    sys.exit(cli())
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/click/core.py", line 11[5](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:5)7, in __call__
    return self.main(*args, **kwargs)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml/generators/projectgen.py", line 243, in cli
    gen.generate(yamlfile, project_config)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml/generators/projectgen.py", line 145, in generate
    gen_dump = gen.serialize(**serialize_args)
  File "/home/runner/.cache/pypoetry/virtualenvs/datalad-schema-_c81gG7w-py3.9/lib/python3.9/site-packages/linkml/generators/shaclgen.py", line 5[6](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:6), in serialize
    data = g.serialize(format="turtle" if self.format in ["owl", "ttl"] else self.format).decode()
AttributeError: 'str' object has no attribute 'decode'
 syntax="proto3";
 package
// metamodel_version: 1.[7](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:7).0
# metamodel_version: 1.7.0
# metamodel_version: 1.7.0
make: *** [Makefile:[11](https://github.com/psychoinformatics-de/datalad-schema/actions/runs/6847819695/job/18616803087?pr=5#step:7:11)3: test-schema] Error 1
Error: Process completed with exit code 2.
jsheunis commented 1 year ago

This is on the schema provided with the standard cookie cutter template.

jsheunis commented 1 year ago

This issue is documented in the linkml cookie cutter project: https://github.com/linkml/linkml-project-cookiecutter/issues/73 And in linkml: https://github.com/linkml/linkml/issues/1567

A temporary fix is available here: https://github.com/linkml/linkml-project-cookiecutter/pull/79/files