linkml.generators package — linkml documentation

# linkml.generators package

## Submodules

## linkml.generators.csvgen module

Generate CSVs

class linkml.generators.csvgen.CsvGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  generatorname: str = 'csvgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['csv', 'tsv']
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_schema(classes: Optional[List[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = None, **_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.dotgen module

Generate dotfiles

class linkml.generators.dotgen.DotGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  directory_output: bool = True
  edge(*args, **kwargs) → None
  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  end_schema(**_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'dotgen.py'
  generatorversion: str = '0.1.1'
  node(*args, **kwargs) → None
  valid_formats: List[str] = ['png', 'bmp', 'canon', 'cgimage', 'cmap', 'cmapx', 'cmapx_np', 'dot', 'dot_json', 'eps', 'exr', 'fig', 'gd', 'gd2', 'gif', 'gtk', 'gv', 'ico', 'imap', 'imap_np', 'ismap', 'jp2', 'jpe', 'jpeg', 'jpg', 'json', 'json0', 'pct', 'pdf', 'pic', 'pict', 'plain', 'plain-ext', 'png', 'pov', 'ps', 'ps2', 'psd', 'sgi', 'svg', 'svgz', 'tga', 'tif', 'tiff', 'tk', 'vml', 'vmlz', 'vrml', 'wbmp', 'webp', 'x11', 'xdot', 'xdot1.2', 'xdot1.4', 'xdot_json', 'xlib']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition)

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_schema(classname: Optional[List[str]] = None, directory: Optional[str] = None, filename: Optional[str] = None, **_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.excelgen module

class linkml.generators.excelgen.ExcelGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], output: Optional[str] = None, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  This class is a blueprint for the generator module that is responsible for automatically creating Excel spreadsheets from the LinkML schema.

  Parameters

    - schema (class:SchemaDefinition) – LinkML schema object

    - output (str) – LinkML schema specification in YAML format

  generator_name = 'excelgen'
  generator_version = '0.0.1'
  sheet_name_cols = []
  valid_formats: List[str] = ['xlsx']
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Overridden method to intercept classes from generator framework.

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Overridden method to intercept classes and associated slots from generator framework.

  visit_enum(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → bool

    Overridden method to intercept enums from generator framework.

## linkml.generators.flattener module

## linkml.generators.golrgen module

Generate GOlr YAML schema definitions.

These can be converted to solr schema-xml, and used in amigo-bbop tools

See the golr-views directory in this repo for examples

class linkml.generators.golrgen.GOLRClass(*args, _if_missing: Callable[[ForwardRef('JsonObj'), str], Tuple[bool, Any]] = None, **kwargs)

  Bases: `linkml_runtime.utils.yamlutils.YAMLRoot`

  description: str
  display_name: str
  document_category: str
  fields: List[linkml.generators.golrgen.GOLRField]
  id: str
  schema_generating: bool
  weight: int

class linkml.generators.golrgen.GOLRField(*args, _if_missing: Callable[[ForwardRef('JsonObj'), str], Tuple[bool, Any]] = None, **kwargs)

  Bases: `linkml_runtime.utils.yamlutils.YAMLRoot`

  cardinality: Optional[str] = None
  description: str
  display_name: str
  id: str
  property: List

class linkml.generators.golrgen.GolrSchemaGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], directory: Optional[str] = None, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  directory_output: bool = True
  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  generatorname: str = 'golrgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['golr']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_schema(directory: str, **_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.graphqlgen module

class linkml.generators.graphqlgen.GraphqlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  generatorname: str = 'graphqlgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['graphql']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

## linkml.generators.infer_model module

Infer a schema from a TSV

class linkml.generators.infer_model.Hit(term_id: str, name: str, score: float, **kwargs)

  Bases: `object`

  name: str
  score: float
  term_id: str

linkml.generators.infer_model.convert_range(k: str, dt: str) → str

linkml.generators.infer_model.get_db(id: str) → str

linkml.generators.infer_model.get_pv_element(v: str, zooma_confidence: str, cache: dict = {}) → linkml.generators.infer_model.Hit

  uses ZOOMA to guess a meaning of an enum permissible value

  Parameters

    - v –

    - zooma_confidence –

    - cache –

  Returns

linkml.generators.infer_model.infer_enum_meanings(schema: dict, zooma_confidence: str = 'MEDIUM', cache={}) → None

linkml.generators.infer_model.infer_model(tsvfile: str, sep='\t', class_name='example', schema_name: str = 'example', enum_columns=[], enum_threshold=0.1, max_enum_size=50) → dict

linkml.generators.infer_model.infer_range(slot: dict, vals: set, types: dict) → str

linkml.generators.infer_model.is_date(string, fuzzy=False)

  Return whether the string can be interpreted as a date.

  Parameters

    - string – str, string to check for date

    - fuzzy – bool, ignore unknown tokens in string if True

## linkml.generators.javagen module

class linkml.generators.javagen.JavaGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], package: Optional[str] = None, template_file: Optional[str] = None, format: str = 'java', genmeta: bool = False, gen_classvars: bool = True, gen_slots: bool = True, **kwargs)

  Bases: `linkml.generators.oocodegen.OOCodeGenerator`

  generatorname: str = 'javagen.py'
  generatorversion: str = '0.9.0'
  map_type(t: linkml_runtime.linkml_model.meta.TypeDefinition) → str
  serialize(directory: str) → None

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

  valid_formats: List[str] = ['java']
  visit_all_class_slots: bool = False

## linkml.generators.jsonldcontextgen module

Generate JSON-LD contexts

class linkml.generators.jsonldcontextgen.ContextGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  end_schema(base: Optional[str] = None, output: Optional[str] = None, prefixes: Optional[bool] = True, flatprefixes: Optional[bool] = False, model: Optional[bool] = True, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'jsonldcontextgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['context', 'json']
  visit_all_class_slots: bool = False
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_schema(base: Optional[str] = None, output: Optional[str] = None, **_)

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  visit_slot(aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited once for every slot definition in the schema.

    @param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

## linkml.generators.jsonldgen module

Generate JSONld

class linkml.generators.jsonldgen.JSONLDGenerator(*args, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  adjust_slot(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None
  end_schema(context: Optional[str] = None, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'jsonldgen.py'
  generatorversion: str = '0.0.2'
  valid_formats: List[str] = ['jsonld', 'json']
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_slot(aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited once for every slot definition in the schema.

    @param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

  visit_subset(ss: linkml_runtime.linkml_model.meta.SubsetDefinition) → None

    Visited once for every subset definition in the schema

    #param subset: Subset definition

  visit_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition) → None

    Visited once for every type definition in the schema

    @param typ: Type definition

## linkml.generators.jsonschemagen module

class linkml.generators.jsonschemagen.JsonSchemaGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], top_class: Optional[str] = None, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  Generates JSONSchema documents from a LinkML SchemaDefinition

  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  end_schema(**_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'jsonschemagen.py'
  generatorversion: str = '0.0.2'
  valid_formats: List[str] = ['json']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_enum(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → bool

    Visited once for every enum definition in the schema

    @param enum: Enum definition

  visit_schema(inline: bool = False, not_closed=True, **kwargs) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.lpgen module

class linkml.generators.lpgen.LogicProgramGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  emit(p, *args)
  generatorname: str = 'lpgen.py'
  generatorversion: str = '0.0.2'
  valid_formats: List[str] = ['lp', 'sexpr']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_slot(slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Add a slot definition per slot

    @param slot_name: @param slot: @return:

## linkml.generators.markdowngen module

class linkml.generators.markdowngen.MarkdownGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], no_types_dir: bool = False, noyuml: bool = False, warn_on_exist: bool = False, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  Generates markdown documentation for a LinkML schema

  Each schema element (class, slot, type, enum) is translated into its own markdown file; additionally, an index.md is generated that links everything together.

  The markdown is suitable for deployment as a MkDocs or Sphinx site

  static anchor(id_: str) → None
  static anchorend() → None
  bbin(obj: linkml_runtime.linkml_model.meta.Element) → str

    Boldify built in types

    @param obj: object name or id @return:

  static bullet(txt: str, level=0) → None
  class_hier(cls: linkml_runtime.linkml_model.meta.ClassDefinition, level=0) → None
  class_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.ClassDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False, add_subset: bool = True) → str
  class_type_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.TypeDefinition, linkml_runtime.linkml_model.meta.EnumDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False, add_subset: bool = True) → str
  desc_for(obj: linkml_runtime.linkml_model.meta.Element, doing_descs: bool) → str

    Return a description for object if it is unique (different than its parent)

    @param obj: object to be described @param doing_descs: If false, always return an empty string @return: text or empty string

  dir_path(obj: Union[linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.SlotDefinition, linkml_runtime.linkml_model.meta.TypeDefinition, linkml_runtime.linkml_model.meta.EnumDefinition]) → str
  directory_output: bool = True
  element_header(obj: linkml_runtime.linkml_model.meta.Element, name: str, curie: str, uri: str) → None
  element_properties(obj: linkml_runtime.linkml_model.meta.Element) → None
  enum_hier(enum: linkml_runtime.linkml_model.meta.EnumDefinition, level=0) → None
  enum_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.EnumDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False, add_subset: bool = True) → str
  exist_warning(*fpath: str) → str

    Create a file name out of fpath and check whether it already exists

  frontmatter(thingtype: str, layout='default') → None
  generatorname: str = 'markdowngen.py'
  generatorversion: str = '0.2.1'
  header(level: int, txt: str) → None
  static id_to_url(id_: str) → str
  is_secondary_ref(en: str) → bool

    Determine whether ‘en’ is the name of something in the neighborhood of the requested classes

    @param en: element name @return: True if ‘en’ is the name of a slot, class or type in the immediate neighborhood of of what we are building

  mappings()
  static para(txt: str) → None
  pred_hier(slot: linkml_runtime.linkml_model.meta.SlotDefinition, level=0) → None
  static predicate_cardinality(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → str

    Emit cardinality for a suffix on a predicate

  static range_cardinality(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → str

    Emits cardinality decorator at end of type

  slot_field(cls: linkml_runtime.linkml_model.meta.ClassDefinition, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None
  slot_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.SlotDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False, add_subset: bool = True) → str
  subset_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.SubsetDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False) → str
  to_uri(uri_or_curie: str) → str

    Return the URI for the slot if known

  type_link(ref: Optional[Union[str, linkml_runtime.linkml_model.meta.TypeDefinition]], *, after_link: Optional[str] = None, use_desc: bool = False, add_subset: bool = True) → str
  valid_formats: List[str] = ['md']
  visit_all_class_slots: bool = False
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_enum(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → None

    Visited once for every enum definition in the schema

    @param enum: Enum definition

  visit_schema(directory: Optional[str] = None, classes: Optional[Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = None, image_dir: bool = False, index_file: str = 'index.md', noimages: bool = False, **_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  visit_slot(aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited once for every slot definition in the schema.

    @param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

  visit_subset(subset: linkml_runtime.linkml_model.meta.SubsetDefinition) → None

    Visited once for every subset definition in the schema

    #param subset: Subset definition

  visit_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition) → None

    Visited once for every type definition in the schema

    @param typ: Type definition

  xlink(id_: str) → str

## linkml.generators.namespacegen module

class linkml.generators.namespacegen.NamespaceGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], format: str = 'py', genmeta: bool = False, gen_classvars: bool = True, gen_slots: bool = True, **kwargs)

  Bases: `linkml.generators.pythongen.PythonGenerator`

  gen_namespaces() → str
  gen_schema() → str
  generatorname: str = 'namespacegen.py'
  generatorversion: str = '0.9.0'
  valid_formats: List[str] = ['py']
  visit_all_class_slots: bool = False

## linkml.generators.oocodegen module

class linkml.generators.oocodegen.OOClass(name: str, is_a: Optional[str] = None, abstract: Optional[bool] = None, mixins: List[str] = <factory>, fields: List[linkml.generators.oocodegen.OOField] = <factory>, annotations: List[str] = <factory>, package: Optional[str] = None, source_class: Optional[linkml_runtime.linkml_model.meta.ClassDefinition] = None, **kwargs)

  Bases: `object`

  An object-oriented class

  abstract: Optional[bool] = None
  annotations: List[str]
  fields: List[linkml.generators.oocodegen.OOField]
  is_a: Optional[str] = None
  mixins: List[str]
  name: str
  package: str = None
  source_class: linkml_runtime.linkml_model.meta.ClassDefinition = None

class linkml.generators.oocodegen.OOCodeGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition, linkml.utils.generator.Generator], format: Optional[str] = None, metadata: bool = True, useuris: Optional[bool] = None, importmap: Optional[str] = None, log_level: int = 30, mergeimports: Optional[bool] = True, source_file_date: Optional[str] = None, source_file_size: Optional[int] = None, logger: Optional[logging.Logger] = None, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  create_documents() → List[linkml.generators.oocodegen.OODocument]

    Currently hardcoded for java-style :return:

  get_class_name(cn)
  get_slot_name(sn)
  java_style = True
  make_multivalued(range: str) → str
  map_type(t: linkml_runtime.linkml_model.meta.TypeDefinition) → str
  package: str = 'example'
  abstract serialize(directory: str) → None

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

class linkml.generators.oocodegen.OODocument(name: str, package: Optional[str] = None, source_schema: Optional[linkml_runtime.linkml_model.meta.SchemaDefinition] = None, classes: List[linkml.generators.oocodegen.OOClass] = <factory>, imports: List[str] = <factory>, **kwargs)

  Bases: `object`

  A collection of one or more OO classes

  classes: List[linkml.generators.oocodegen.OOClass]
  imports: List[str]
  name: str
  package: str = None
  source_schema: linkml_runtime.linkml_model.meta.SchemaDefinition = None

class linkml.generators.oocodegen.OOField(name: str, range: Optional[str] = None, annotations: List[str] = <factory>, source_slot: linkml_runtime.linkml_model.meta.SlotDefinition = <factory>, **kwargs)

  Bases: `object`

  A field belonging to an OO class that corresponds to a LinkML class slot

  annotations: List[str]
  name: str
  range: str = None
  source_slot: linkml_runtime.linkml_model.meta.SlotDefinition

## linkml.generators.owlgen module

Generate OWL ontology corresponding to information model

model classes are translated to OWL classes, slots to OWL properties.

class linkml.generators.owlgen.ElementDefinition

  Bases: `object`

class linkml.generators.owlgen.OwlSchemaGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], ontology_uri_suffix: Optional[str] = None, type_objects=True, metaclasses=True, add_ols_annotations=True, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  Generates a schema-oriented OWL representation of a LinkML model

  OWL Generator Docs

  Attributes:

    type_objects if True, represent TypeDefinitions as objects; if False, as literals metaclasses if True, include OWL representations of ClassDefinition, SlotDefinition, etc. Introduces punning

  add_metadata(e: linkml_runtime.linkml_model.meta.Definition, uri: rdflib.term.URIRef) → None

    Add generic annotation properties

    Parameters

      - e – schema element

      - uri – URI representation of schema element

    Returns

  end_schema(output: Optional[str] = None, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'owlgen.py'
  generatorversion: str = '0.1.1'
  is_slot_object_property(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → bool
  slot_owl_type(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → rdflib.term.URIRef
  valid_formats: List[str] = ['owl', 'ttl', 'json-ld', 'xml', 'n3', 'turtle', 'ttl', 'ntriples', 'nt', 'nt11', 'nquads', 'trix', 'trig']
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Each ClassDefinition is represented as an OWL class

    - the OWL Class will instantiate ClassDefinition, if schema.metaclasses is true

    - the OWL Class will be annotated using the same properties as the source ClassDefinition

    - induced slots and their ranges added as OWL restrictions; note this will be under the Open World Assumption

    Parameters

      cls –

    Returns

  visit_schema(output: Optional[str] = None, **_)

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  visit_slot(slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Add a slot definition per slot

    Note: visit_slot may be called multiple times for the same slot_uri, as the same slot_uri can be used: * when the schema declares attributes * when slot_usage induces additional slots

    @param slot_name: @param slot: @return:

  visit_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition) → None

    Visited once for every type definition in the schema

    @param typ: Type definition

  visits_are_sorted: bool = True

## linkml.generators.prefixmapgen module

Generate JSON-LD contexts

class linkml.generators.prefixmapgen.PrefixGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  end_schema(base: Optional[str] = None, output: Optional[str] = None, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'prefixmapgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['json', 'tsv']
  visit_all_class_slots: bool = False
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_schema(base: Optional[str] = None, output: Optional[str] = None, **_)

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  visit_slot(aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited once for every slot definition in the schema.

    @param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

## linkml.generators.projectgen module

class linkml.generators.projectgen.ProjectConfiguration(directory: str = 'tmp', generator_args: Dict[str, Dict[str, Any]] = <factory>, includes: Optional[List[str]] = None, excludes: Optional[List[str]] = None, mergeimports: Optional[bool] = None, **kwargs)

  Bases: `object`

  Global project configuration, and per-generator configurations

  directory: str = 'tmp'
  excludes: List[str] = None
  generator_args: Dict[str, Dict[str, Any]]
  includes: List[str] = None
  mergeimports: bool = None

class linkml.generators.projectgen.ProjectGenerator

  Bases: `object`

  generate(schema_path: str, config: linkml.generators.projectgen.ProjectConfiguration = ProjectConfiguration(directory='tmp', generator_args=defaultdict(<class 'dict'>, {}), includes=None, excludes=None, mergeimports=None))

linkml.generators.projectgen.get_local_imports(schema_path: str, dir: str)

## linkml.generators.protogen module

class linkml.generators.protogen.ProtoGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  A Generator for creating Protobuf schemas from a linkml schema.

  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  generatorname: str = 'protogen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['proto']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

## linkml.generators.pydanticgen module

class linkml.generators.pydanticgen.PydanticGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], template_file: Optional[str] = None, format: str = 'pydantic', genmeta: bool = False, gen_classvars: bool = True, gen_slots: bool = True, **kwargs)

  Bases: `linkml.generators.oocodegen.OOCodeGenerator`

  generatorname: str = 'pydanticgen.py'
  generatorversion: str = '0.0.1'
  map_type(t: linkml_runtime.linkml_model.meta.TypeDefinition) → str
  serialize() → None

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

  valid_formats: List[str] = ['pydantic']
  visit_all_class_slots: bool = False

## linkml.generators.pythongen module

class linkml.generators.pythongen.PythonGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], format: str = 'py', genmeta: bool = False, gen_classvars: bool = True, gen_slots: bool = True, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  Generates Python dataclasses from a LinkML model

  class_reference_type(slot: linkml_runtime.linkml_model.meta.SlotDefinition, cls: Optional[linkml_runtime.linkml_model.meta.ClassDefinition]) → Tuple[str, str, str]

    Return the type of a slot referencing a class

    Parameters

      - slot – slot to be typed

      - cls – owning class. Used for generating key references

    Returns

      Python class reference type, most proximal type, most proximal type name

  compile_module(**kwargs) → module

    Compiles generated python code to a module :return:

  end_schema(**_)

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  forward_reference(slot_range: str, owning_class: str) → bool

    Determine whether slot_range is a forward reference

  gen_class_meta(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → str
  static gen_class_reference(rangelist: List[str]) → str

    Return a basic or a union type depending on the number of elements in range list

    Parameters

      rangelist – List of types from distal to proximal

    Returns

  gen_class_variable(cls: linkml_runtime.linkml_model.meta.ClassDefinition, slot: linkml_runtime.linkml_model.meta.SlotDefinition, can_be_positional: bool) → str

    Generate a class variable declaration for the supplied slot. Note: the can_be_positional attribute works, but it makes tag/value lists unduly complex, as you can’t load them with tag=…, value=… – you HAVE to load positionally. We currently ignore this parameter, meaning that we have a tag/value option for any LinkML element

    Parameters

      - cls – Owning class

      - slot – slot definition

      - can_be_positional – True means that positional parameters are allowed.

    Returns

      Initializer string

  gen_class_variables(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → str

    Generate the variable declarations for a dataclass.

    Parameters

      cls – class containing variables to be rendered in inheritence hierarchy

    Returns

      variable declarations for target class and its ancestors

  gen_classdef(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → str

    Generate python definition for class cls

  gen_classdefs() → str

    Create class definitions for all non-mixin classes in the model Note that apply_to classes are transformed to mixins

  gen_enum(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → str
  gen_enum_comment(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → str
  gen_enum_definition(enum: linkml_runtime.linkml_model.meta.EnumDefinition, enum_name: str) → str
  gen_enum_description(enum: linkml_runtime.linkml_model.meta.EnumDefinition, enum_name: str) → str
  gen_enumerations() → str
  gen_import_list() → Dict[str, List[str]]

    Generate a list of types to import

    Returns

      source file followed by elements to import

  gen_imports() → str
  gen_inherited_slots(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → str
  gen_namespaces() → str
  gen_postinit(cls: linkml_runtime.linkml_model.meta.ClassDefinition, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → Optional[str]

    Generate python post init rules for slot in class

  gen_postinits(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → str

    Generate all the typing and existence checks post initialize

  gen_pv_constructor(pv: linkml_runtime.linkml_model.meta.PermissibleValue, indent: int) → List[str]

    Generate a permissible value constructor @param pv: Value to be constructed @param indent: number of additional spaces to add on successive lines @return: Permissible value constructor

  gen_pvs(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → str

    Generate the python compliant permissible value initializers as a set of class variables @param enum: @return:

  gen_pvs2(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → str

    Generate the non-python compliant permissible value initializers as a set of setattr instructions @param enum: @return:

  gen_pvs2_initializers(enum: linkml_runtime.linkml_model.meta.EnumDefinition) → str
  gen_references() → str

    Generate python type declarations for all identifiers (primary keys)

  gen_schema() → str
  gen_slot(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → str
  gen_slotdefs() → str
  gen_type_meta(typ: linkml_runtime.linkml_model.meta.TypeDefinition) → str
  gen_typedefs() → str

    Generate python type declarations for all defined types

  generatorname: str = 'pythongen.py'
  generatorversion: str = '0.9.0'
  is_key_value_class(range_name: linkml_runtime.linkml_model.meta.DefinitionName) → bool

    Return True if range_name references a class with exactly one key and one value

    Parameters

      range_name – class definition (name)

    Returns

      True if meets the special case

  key_name_for(class_name: linkml_runtime.linkml_model.meta.ClassDefinitionName) → Optional[str]
  primary_keys_for(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → List[linkml_runtime.linkml_model.meta.SlotDefinitionName]

    Return the primary key for cls.

    Note: At the moment we return at most one entry. At some point, keys will be expanded to support

      composite keys.

    @param cls: class to get keys for @return: List of primary keys or identifiers

  python_uri_for(uriorcurie: Union[str, rdflib.term.URIRef]) → Tuple[str, Optional[str]]

    Return the python form of uriorcurie :param uriorcurie: :return: URI and CURIE form

  range_cardinality(slot: linkml_runtime.linkml_model.meta.SlotDefinition, cls: Optional[linkml_runtime.linkml_model.meta.ClassDefinition], positional_allowed: bool) → Tuple[str, Optional[str]]

    Return the range type including initializers, etc. Generate a class variable declaration for the supplied slot. Note: the positional_allowed attribute works, but it makes tag/value lists unduly complex, as you can’t load them with tag=…, value=… – you HAVE to load positionally. We currently ignore this parameter, meaning that we have a tag/value option for any LinkML element

    Parameters

      - slot – slot to generate type for

      - cls – containing class – used to render key slots correctly. If absent, slot is an add-in

      - positional_allowed – True Means that we are in the positional space and defaults are not supplied

    Returns

      python property name and initializer (if any)

  range_type_name(slot: linkml_runtime.linkml_model.meta.SlotDefinition) → str

    Generate the type name for the slot

  valid_formats: List[str] = ['py']
  visit_all_class_slots: bool = False
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_schema(**kwargs) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  visit_slot(aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited once for every slot definition in the schema.

    @param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

  visit_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition) → None

    Visited once for every type definition in the schema

    @param typ: Type definition

## linkml.generators.rdfgen module

YAML Schema to RDF Generator

Generate a JSON LD representation of the model

class linkml.generators.rdfgen.RDFGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  end_schema(output: Optional[str] = None, context: Optional[str] = None, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'rdfgen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['ttl', 'json-ld', 'n3', 'nquads', 'nt', 'nt11', 'ntriples', 'trig', 'trix', 'ttl', 'turtle', 'xml']
  visit_all_class_slots: bool = False

## linkml.generators.shaclgen module

class linkml.generators.shaclgen.ShaclGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], format: str = 'ttl', genmeta: bool = False, gen_classvars: bool = True, gen_slots: bool = True, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  as_graph() → None
  generatorname: str = 'shaclgen.py'
  generatorversion: str = '0.0.1'
  serialize(**args) → None

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

  valid_formats: List[str] = ['ttl']
  visit_all_class_slots: bool = False

## linkml.generators.shexgen module

Generate ShEx definition of a model

class linkml.generators.shexgen.ShExGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **args)

  Bases: `linkml.utils.generator.Generator`

  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  end_schema(output: Optional[str] = None, **_) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generatorname: str = 'shexgen.py'
  generatorversion: str = '0.0.2'
  valid_formats: List[str] = ['shex', 'json', 'rdf']
  visit_all_class_slots: bool = False
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: linkml_runtime.linkml_model.meta.SlotDefinitionName, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_schema(**_)

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.sparqlgen module

class linkml.generators.sparqlgen.SparqlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], format: str = 'sparql', named_graphs: Optional[List[str]] = None, limit: Optional[int] = None, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  generate_sparql(named_graphs=None, limit: Optional[int] = None)
  generatorname: str = 'sparqlgen.py'
  serialize(directory=None) → str

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

  split_sparql(sparql: str) → Dict[str, str]
  valid_formats: List[str] = ['sparql']
  visit_all_class_slots: bool = False

linkml.generators.sparqlgen.materialize_schema(schemaview: linkml_runtime.utils.schemaview.SchemaView)

## linkml.generators.sqlddlgen module

class linkml.generators.sqlddlgen.Backref(original_column: 'SQLColumn', backref_column: 'SQLColumn', order_by: str = None, **kwargs)

  Bases: `object`

  backref_column: linkml.generators.sqlddlgen.SQLColumn
  order_by: str = None
  original_column: linkml.generators.sqlddlgen.SQLColumn

class linkml.generators.sqlddlgen.DDLEntity(description: Optional[str] = None, **kwargs)

  Bases: `object`

  abstract grouping

  description: str = None

class linkml.generators.sqlddlgen.SQLColumn(description: Optional[str] = None, name: Optional[str] = None, mapped_to: Optional[linkml_runtime.linkml_model.meta.SlotDefinition] = None, mapped_to_alias: Optional[str] = None, table: Optional[linkml.generators.sqlddlgen.SQLTable] = None, base_type: Optional[str] = None, is_singular_primary_key: bool = False, foreign_key: Optional[linkml.generators.sqlddlgen.SQLColumn] = None, **kwargs)

  Bases: `linkml.generators.sqlddlgen.DDLEntity`

  represents a Relational Table Column

  as_ddlstr()
  base_type: str = None
  foreign_key: Optional[linkml.generators.sqlddlgen.SQLColumn] = None
  is_primary_key()
  is_singular_primary_key: bool = False
  mapped_to: linkml_runtime.linkml_model.meta.SlotDefinition = None
  mapped_to_alias: str = None
  name: str = None
  table: linkml.generators.sqlddlgen.SQLTable = None

class linkml.generators.sqlddlgen.SQLDDLGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], dialect='sqlite', use_foreign_keys=True, rename_foreign_keys=False, direct_mapping=False, **kwargs)

  Bases: `linkml.utils.generator.Generator`

  A Generator for creating SQL DDL

  The basic algorithm for mapping a linkml schema S is as follows:

  > - Each schema S corresponds to one database schema D (see SQLSchema)

  > - Each Class C in S is mapped to a table T (see SQLTable)

  > - Each slot S in each C is mapped to a column Col (see SQLColumn)

  if the direct_mapping attribute is set to true, then no further transformations are applied. Note that this means:

  > - inline objects are modeled as Text strings

  > - multivalued fields are modeled as single Text strings

  this direct mapping is useful for simple spreadsheet/denormalized representations of complex data. however, for other applications, additional transformations should occur. these are:

  MULTIVALUED SLOTS

  The relational model does not have direct representation of lists. These are normalized as follows.

  If the range of the slot is a class, and there are no other slots whose range is this class, and the slot is for a class that has a singular primary key, then a backref is added.

  E.g. if we have User 0..* Address, then add a field User_id to Address.

  When SQLAlchemy bindings are created, a backref mapping is added

  If the range of the slot is an enum or type, then a new linktable is created, and a backref added

  E.g. if a class User has a multivalues slot alias whose range is a string, then create a table user_aliases, with two columns (1) alias [a string] and (2) a backref to user

  > Each mapped slot C.S has a range R

  > ranges that are types (literals):

  >   > - If R is a type, and the slot is NOT multivalued, do a direct type conversion

  >   > - If R is a type, and the slot is multivalued: * do not include the mapped column * create a new table T_S, with 2 columns: S, and a backref to T

  >   ranges that are classes:

  >     Ref = map_class_to_table(R) - if R is a class, and the slot is NOT multivalued, and Ref has a singular primary key:

  >     > - Col.type = ForeignKey(Ref.PK)

  >     - if R is a class, and the slot is NOT multivalued, and Ref has NO singular primary key: * add a foreign key C.pk to Ref * add a backref C.S => Ref, C.pk * remove Col from T

  >     - If R is a class, and the slot IS multivalued

  dialect: str
  end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → None

    Visited after visit_class_slots (if visit_class returned true)

    @param cls: class being visited

  end_schema(**kwargs) → None

    Visited once at the end of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

  generate_ddl() → None
  generatorname: str = 'sqlddlgen.py'
  generatorversion: str = '0.1.1'
  get_sql_range(slot: linkml_runtime.linkml_model.meta.SlotDefinition)

    returns a SQL Alchemy column type

  inject_primary_keys: bool = True
  sqlschema: linkml.generators.sqlddlgen.SQLSchema = SQLSchema(description=None, name=None, mapped_to=None, tables={})
  use_inherits: bool = False
  valid_formats: List[str] = ['proto']
  visit_all_class_slots: bool = True
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  write_sqla_python_imperative(model_path: str) → str

    imperative mapping: https://docs.sqlalchemy.org/en/14/orm/mapping_styles.html#imperative-mapping-with-dataclasses-and-attrs

    maps to the python classes generated using PythonGenerator

    ``` output = StringIO() with redirect_stdout(output):

    > gen.write_sqla_python_imperative()

class linkml.generators.sqlddlgen.SQLSchema(description: Optional[str] = None, name: Optional[str] = None, mapped_to: Optional[linkml_runtime.linkml_model.meta.SchemaDefinition] = None, tables: Dict[str, linkml.generators.sqlddlgen.SQLTable] = <factory>, **kwargs)

  Bases: `linkml.generators.sqlddlgen.DDLEntity`

  represents a Relational Schema

  add_table(t: linkml.generators.sqlddlgen.SQLTable)
  all_columns() → List[linkml.generators.sqlddlgen.SQLColumn]
  get_table_by_class_name(cn: linkml_runtime.linkml_model.meta.ClassDefinitionName) → Optional[linkml.generators.sqlddlgen.SQLTable]
  mapped_to: linkml_runtime.linkml_model.meta.SchemaDefinition = None
  name: str = None
  tables: Dict[str, linkml.generators.sqlddlgen.SQLTable]

class linkml.generators.sqlddlgen.SQLTable(description: Optional[str] = None, name: Optional[str] = None, mapped_to: Optional[linkml_runtime.linkml_model.meta.ClassDefinition] = None, columns: Dict[str, linkml.generators.sqlddlgen.SQLColumn] = <factory>, in_schema: Optional[linkml.generators.sqlddlgen.SQLSchema] = None, referenced_by: List[linkml.generators.sqlddlgen.SQLColumn] = <factory>, primary_keys: List[linkml.generators.sqlddlgen.SQLColumn] = <factory>, backrefs: List[linkml.generators.sqlddlgen.Backref] = <factory>, **kwargs)

  Bases: `linkml.generators.sqlddlgen.DDLEntity`

  represents a Relational Table

  add_column(c: linkml.generators.sqlddlgen.SQLColumn)
  as_var() → str
  backrefs: List[linkml.generators.sqlddlgen.Backref]
  columns: Dict[str, linkml.generators.sqlddlgen.SQLColumn]
  get_singular_primary_key() → Optional[linkml.generators.sqlddlgen.SQLColumn]
  in_schema: linkml.generators.sqlddlgen.SQLSchema = None
  mapped_to: linkml_runtime.linkml_model.meta.ClassDefinition = None
  name: str = None
  primary_keys: List[linkml.generators.sqlddlgen.SQLColumn]
  referenced_by: List[linkml.generators.sqlddlgen.SQLColumn]
  remove_column(c)

## linkml.generators.summarygen module

Generate Summary Spreadsheets

class linkml.generators.summarygen.SummaryGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **args)

  Bases: `linkml.utils.generator.Generator`

  generatorname: str = 'summarygen.py'
  generatorversion: str = '0.1.1'
  valid_formats: List[str] = ['tsv']
  visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) → bool

    Visited once per schema class

    @param cls: class being visited @return: Visit slots and end class. False means skip and go on

  visit_class_slot(cls: linkml_runtime.linkml_model.meta.ClassDefinition, aliased_slot_name: str, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → None

    Visited for each slot in a class. If class level visit_all_slots is true, this is visited once for any class that is inherited (class itself, is_a, mixin, apply_to). Otherwise just the own slots.

    @param cls: containing class @param aliased_slot_name: Aliased slot name. May not be unique across all class slots @param slot: slot being visited

  visit_schema(**_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## linkml.generators.terminusdbgen module

## linkml.generators.yamlgen module

Validate linkml input and optionally emit completely resolved biolink yaml output

class linkml.generators.yamlgen.YAMLGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)

  Bases: `linkml.utils.generator.Generator`

  A generator that produces a schema as a YAML Document

  generatorname: str = 'yamlgen.py'
  generatorversion: str = '0.1.0'
  serialize(validateonly: bool = False, **kwargs) → str

    Generate output in the required format

    Parameters

      kwargs – Generater specific parameters

    Returns

      Generated output

  valid_formats: List[str] = ['yaml']

## linkml.generators.yumlgen module

Generate yuml

https://yuml.me/diagram/scruffy/class/samples

class linkml.generators.yumlgen.YumlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **args)

  Bases: `linkml.utils.generator.Generator`

  static cardinality(slot: linkml_runtime.linkml_model.meta.SlotDefinition, is_attribute: bool = True) → str
  class_associations(cn: linkml_runtime.linkml_model.meta.ClassDefinitionName, must_render: bool = False) → str

    Emit all associations for a focus class. If none are specified, all classes are generated

    @param cn: Name of class to be emitted @param must_render: True means render even if this is a target (class is specifically requested) @return: YUML representation of the association

  class_box(cn: linkml_runtime.linkml_model.meta.ClassDefinitionName) → str

    Generate a box for the class. Populate its interior only if (a) it hasn’t previously been generated and (b) it appears in the gen_classes list

    @param cn: @return:

  filtered_cls_slots(cn: linkml_runtime.linkml_model.meta.ClassDefinitionName, all_slots: bool = True, filtr: Optional[Callable[[linkml_runtime.linkml_model.meta.SlotDefinition], bool]] = None) → List[linkml_runtime.linkml_model.meta.SlotDefinition]

    Return the set of slots associated with the class that meet the filter criteria. Slots will be returned in defining order, with class slots returned last

    @param cn: name of class to filter @param all_slots: True means include attributes @param filtr: Slot filter predicate @return: List of slot definitions

  generatorname: str = 'yumlgen.py'
  generatorversion: str = '0.1.1'
  prop_modifier(cls: linkml_runtime.linkml_model.meta.ClassDefinition, slot: linkml_runtime.linkml_model.meta.SlotDefinition) → str
    Return the modifiers for the slot:

      (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey

    @param cls: @param slot: @return:

  valid_formats: List[str] = ['yuml', 'png', 'pdf', 'jpg', 'json', 'svg']
  visit_all_class_slots: bool = False
  visit_schema(classes: Optional[Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = None, directory: Optional[str] = None, load_image: bool = True, **_) → None

    Visited once at the beginning of generation

    @param kwargs: Arguments passed through from CLI – implementation dependent

## Module contents

Generators translate between a SchemaDefinition and an alternative representation such as JsonSchema