Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Importing slots has odd side effect of turning them into Types in python generator #121

Closed
cmungall opened this issue Jun 2, 2020 · 1 comment

Comments

@cmungall
Copy link
Contributor

cmungall commented Jun 2, 2020

Minimal example, of a schema with one class and one slot "depth"

nmdc.py (imports mixs.yaml):

id: https://microbiomedata/schema

prefixes:
  biolinkml: https://w3id.org/biolink/biolinkml/
  
imports:
  - biolinkml:types
  - mixs
  
classes:

  biosample:
    slots:
      - depth
    slot_usage:
      depth:
        required: false

slots: {}

mixs.yaml:

id: https://microbiomedata/schema/mixs
slots:
  depth: {}

output:

$ pipenv run gen-py-classes schema/nmdc.yaml | grep -A2 -B2 'from includes.types'
Warning: default_range not specified. Default set to 'string'
from rdflib import Namespace, URIRef
from biolinkml.utils.curienamespace import CurieNamespace
from includes.types import Depth, String

metamodel_version = "1.4.3"

Note this line:

from includes.types import Depth, String

This of course causes an error as includes.types is from blml core, Depth is in our model

cmungall added a commit that referenced this issue Jun 2, 2020
@cmungall
Copy link
Contributor Author

cmungall commented Jun 2, 2020

OK, tracked down to here:

for slot in self.schema.slots.values():
if not slot.imported_from:
if slot.is_a:
parent = self.schema.slots[slot.is_a]
if parent.imported_from:
rval.add_element(self.schema.slots[slot.is_a])
if slot.domain:
domain = self.schema.classes[slot.domain]
if domain.imported_from:
rval.add_element(self.schema.classes[slot.domain])
add_slot_range(slot)

@hsolbrig may need help with the logic here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

No branches or pull requests

1 participant