linkml.utils package

Submodules

linkml.utils.converter module

linkml.utils.datautils module

linkml.utils.datautils.get_dumper(fmt: str) linkml_runtime.loaders.loader_root.Loader[source]
linkml.utils.datautils.get_loader(fmt: str) linkml_runtime.loaders.loader_root.Loader[source]
linkml.utils.datautils.infer_index_slot(sv: linkml_runtime.utils.schemaview.SchemaView, root_class: linkml_runtime.linkml_model.meta.ClassDefinitionName) Optional[linkml_runtime.linkml_model.meta.SlotDefinitionName][source]
linkml.utils.datautils.infer_root_class(sv: linkml_runtime.utils.schemaview.SchemaView) Optional[linkml_runtime.linkml_model.meta.ClassDefinitionName][source]

Infer the class that should be at the root of the object tree

(Note this is distinct from the root of the class hierarchy)

If a class is explicitly designated with tree_root, use this. Otherwise use the class that is not referenced as a range in any other class.

linkml.utils.datavalidator module

class linkml.utils.datavalidator.DataValidator(schema: Optional[linkml_runtime.linkml_model.meta.SchemaDefinition] = None)[source]

Bases: object

Base class for all validators

schema: linkml_runtime.linkml_model.meta.SchemaDefinition = None

linkml.utils.execute_tutorial module

class linkml.utils.execute_tutorial.Block(category: str = None, title: str = None, content: str = None, output: str = None, error: str = None, expected_fail: bool = None, prior_lines: List[str] = None, annotations: List[str] = None)[source]

Bases: object

annotations: List[str] = None
category: str = None
content: str = None
error: str = None
expected_fail: bool = None
is_bash() bool[source]
is_file_block() bool[source]
is_stdout() bool[source]
output: str = None
prior_lines: List[str] = None
title: str = None
linkml.utils.execute_tutorial.execute_blocks(directory: str, blocks: List[linkml.utils.execute_tutorial.Block]) List[str][source]

Execute the code blocks embedded in a tutorial

Parameters
  • directory

  • blocks

Returns

errors

linkml.utils.execute_tutorial.parse_file_to_blocks(input) List[linkml.utils.execute_tutorial.Block][source]

Parses a markdown tutorial file to code blacks to be executed

Parameters

input

Returns

linkml.utils.execute_tutorial.write_lines(lines: List[str]) None[source]

linkml.utils.generator module

class linkml.utils.generator.Generator(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)[source]

Bases: object

add_id_prefixes(element: linkml_runtime.linkml_model.meta.Element) None[source]
add_mappings(defn: linkml_runtime.linkml_model.meta.Definition) None[source]

Process any mappings in defn, adding all of the mappings prefixes to the namespace map :param defn: Class or Slot Definition

add_prefix(ncname: str) None[source]

Add a prefix to the list of prefixes to emit

@param ncname: name to add

aliased_slot_name(slot: Union[linkml_runtime.linkml_model.meta.SlotDefinitionName, linkml_runtime.linkml_model.meta.SlotDefinition]) linkml_runtime.linkml_model.meta.SlotDefinitionName[source]

Return the overloaded slot name – the alias if one exists otherwise the actual name

@param slot: either a slot name or a definition @return: overloaded name

all_slots(cls: Union[linkml_runtime.linkml_model.meta.ClassDefinitionName, linkml_runtime.linkml_model.meta.ClassDefinition], *, cls_slots_first: bool = False, seen: Optional[Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = None) List[linkml_runtime.linkml_model.meta.SlotDefinition][source]

Return all slots that are part of the class definition. This includes all is_a, mixin and apply_to slots but does NOT include slot_usage targets. If class B has a slot_usage entry for slot “s”, only the slot definition for the redefined slot will be included, not its base. Slots are added in the order they appear in classes, with recursive is_a’s being added first followed by mixins and finally apply_tos

@param cls: class definition or class definition name @param cls_slots_first: True means return own slots at the top of the list @param seen: List of slots already recorded. Used for internal recursion @return: ordered list of slots in the class with slot usages removed

ancestors(element: Union[linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.SlotDefinition]) List[linkml_runtime.linkml_model.meta.ElementName][source]

Return an ordered list of ancestor names for the supplied slot or class

@param element: Slot or class name or definition @return: Ordered list of of ancestor names

base_dir: str = None
class_identifier(def_or_name: Union[str, linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.TypeDefinition]) Optional[linkml_runtime.linkml_model.meta.SlotDefinitionName][source]

Return the class identifier if any

Parameters

def_or_name – class name or definition

Returns

name of class key (or identifier) if one exists

class_identifier_path(cls_or_clsname: Union[str, linkml_runtime.linkml_model.meta.ClassDefinition], force_non_key: bool) List[str][source]

Return the path closure to a class identifier if the class has a key and force_non_key is false otherwise return a dictionary closure.

Parameters
  • cls_or_clsname – class definition

  • force_non_key – True means inlined even if the class has a key

Returns

path

class_or_type_for(name: str) Optional[linkml_runtime.linkml_model.meta.Element][source]

Return the corresponding class or type for name

class_or_type_name(name: str) str[source]

Return the camelcase representation of clsname if it is a valid class or type. Prepend “Unknown” if the name isn’t valid

default_prefix() Optional[str][source]

Return the default prefix for the schema

@return: URI or NCNAME of default prefix

directory_output: bool = False
domain_slots(cls: linkml_runtime.linkml_model.meta.ClassDefinition) List[linkml_runtime.linkml_model.meta.SlotDefinition][source]

Return all slots in the class definition that are owned by the class

end_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) None[source]

Visited after visit_class_slots (if visit_class returned true)

@param cls: class being visited

end_schema(**kwargs) None[source]

Visited once at the end of generation

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

enum_identifier_path(enum_or_enumname: Union[str, linkml_runtime.linkml_model.meta.EnumDefinition]) List[str][source]

Return an enum_identifier path

formatted_element_name(el_or_elname: Union[linkml_runtime.linkml_model.meta.ElementName, linkml_runtime.linkml_model.meta.Element], is_range_name: bool = False) Optional[str][source]

Return the default format for the name or the referenced element. Slots are under_scored, all others are CamelCased. Slot names are the alias, not the actual name

Parameters
  • el_or_elname – element or name to map

  • is_range_name – True means that we’re looking for a class or type. False means Slot or Subset. Only

applies if el_or_elname is an ElementName (otherwise we know what we’ve got :return: Formatted name if type can be known else None

generatorname: str = None
generatorversion: str = None
get_metamodel_slot_name(slot_name: str) str[source]

Allows for localization of some generators, such as markdown generator

The client can control how metamodel elements are displayed; e.g. mapping the metamodel slot “slot” to “field”

This method also takes care of pluralization; e.g. if “slot” is mapped to “field”, then “slots” will be mapped to “fields”

Parameters

slot_name

Returns

is_class_unconstrained(cls: linkml_runtime.linkml_model.meta.ClassDefinition)[source]

Determine if the class is mapped to typing.Any, i.e the unconstrained class

Parameters

cls – class definition

Returns

true if the class is unconstrained

metamodel_name_map: Dict[str, str] = None
neighborhood(elements: Union[str, linkml_runtime.linkml_model.meta.ElementName, List[linkml_runtime.linkml_model.meta.ElementName]]) linkml.utils.typereferences.References[source]

Return a list of all slots, classes and types that touch any element in elements, including the element itself

@param elements: Element names to do proximity with @return: All slots and classes that touch element

obj_for(el_or_elname: str, is_range_name: bool = False) Optional[linkml_runtime.linkml_model.meta.Element][source]
own_slot_names(cls: Union[linkml_runtime.linkml_model.meta.ClassDefinitionName, linkml_runtime.linkml_model.meta.ClassDefinition]) List[linkml_runtime.linkml_model.meta.SlotDefinitionName][source]
own_slots(cls: Union[linkml_runtime.linkml_model.meta.ClassDefinitionName, linkml_runtime.linkml_model.meta.ClassDefinition]) List[linkml_runtime.linkml_model.meta.SlotDefinition][source]

Return the list of slots owned the class definition. An “own slot” is any cls slot that does not appear in the class is_a parent. Own_slots include:

  • any slot whose domain is cls

  • slot_usage entries

  • slots from mixins entries

  • slots from apply_to entries

@param cls: class name or class definition name @return: list of owned slots. List is sorted if sort_class_slots is true, otherwise in class order

parent(element: Union[linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.SlotDefinition]) Optional[Union[linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.SlotDefinition]][source]

Return the parent of element, if any

range_type_path(typ: linkml_runtime.linkml_model.meta.TypeDefinition) List[str][source]

Return a formatted list of range types from the base up

Parameters

typ – type definition whose name is to be formatted

Returns

List of possible types with base at the leftmost

serialize(**kwargs) str[source]

Generate output in the required format

Parameters

kwargs – Generater specific parameters

Returns

Generated output

slot_for(name: str) Optional[linkml_runtime.linkml_model.meta.Element][source]
slot_name(name: str) str[source]

Return the underscored version of the aliased slot name if name is a slot. Prepend “unknown_” if the name isn’t valid.

slot_range_path(slot_or_name: Union[str, linkml_runtime.linkml_model.meta.SlotDefinition]) List[str][source]

Return a ordered list of slot ranges from distal to proximal

Parameters

slot_or_name – slot whose range is being typed

Returns

ordered list of types from base type forward

sort_class_slots: bool = False
subset_for(name: str) Optional[linkml_runtime.linkml_model.meta.Element][source]
subset_name(name: str) str[source]
valid_formats: List[str] = []
visit_all_class_slots: bool = False
visit_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition) bool[source]

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[source]

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) None[source]

Visited once for every enum definition in the schema

@param enum: Enum definition

visit_schema(**kwargs) None[source]

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[source]

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[source]

Visited once for every subset definition in the schema

#param subset: Subset definition

visit_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition) None[source]

Visited once for every type definition in the schema

@param typ: Type definition

visits_are_sorted: bool = True
linkml.utils.generator.shared_arguments(g: Type[linkml.utils.generator.Generator]) Callable[[click.core.Command], click.core.Command][source]

linkml.utils.helpers module

linkml.utils.helpers.remove_duplicates(lst)[source]

Remove duplicate tuples from a list of tuples.

linkml.utils.helpers.write_to_file(file_path, data, mode='w', encoding='utf-8')[source]

linkml.utils.ifabsent_functions module

linkml.utils.ifabsent_functions.curie_for(loader: linkml.utils.schemaloader.SchemaLoader, is_class: bool) Optional[str][source]

Return the Curie for the schema in loader. Return None if there is no curie form

linkml.utils.ifabsent_functions.default_curie_or_uri(loader: linkml.utils.schemaloader.SchemaLoader) str[source]
linkml.utils.ifabsent_functions.default_ns_for(loader: linkml.utils.schemaloader.SchemaLoader, cls: linkml_runtime.linkml_model.meta.ClassDefinition) str[source]

Return code to produce the default namespace for the supplied class

linkml.utils.ifabsent_functions.default_uri_for(loader: linkml.utils.schemaloader.SchemaLoader) str[source]
linkml.utils.ifabsent_functions.ifabsent_postinit_declaration(txt: str, loader, cls, slot) Optional[str][source]
linkml.utils.ifabsent_functions.ifabsent_value_declaration(txt: str, loader, cls, slot) Optional[str][source]
linkml.utils.ifabsent_functions.isabsent_match(txt: str) Optional[Tuple[Match[str], bool, Callable[[Match[str], linkml.utils.schemaloader.SchemaLoader, linkml_runtime.linkml_model.meta.ClassDefinition, linkml_runtime.linkml_model.meta.SlotDefinition], str]]][source]
linkml.utils.ifabsent_functions.strval(txt: str) str[source]
linkml.utils.ifabsent_functions.uri_for(s: str, loader: linkml.utils.schemaloader.SchemaLoader) str[source]

linkml.utils.mergeutils module

linkml.utils.mergeutils.alias_root(schema: linkml_runtime.linkml_model.meta.SchemaDefinition, slotname: linkml_runtime.linkml_model.meta.SlotDefinitionName) Optional[linkml_runtime.linkml_model.meta.SlotDefinitionName][source]

Return the ultimate alias of a slot

linkml.utils.mergeutils.merge_classes(schema: linkml_runtime.linkml_model.meta.SchemaDefinition, target: linkml_runtime.linkml_model.meta.ClassDefinition, source: linkml_runtime.linkml_model.meta.ClassDefinition, at_end: bool = False) None[source]

Merge the slots in source into target

Parameters
  • schema – Containing schema

  • target – mergee

  • source – class to merge

  • at_end – True means add mergee to the end. False to the front

linkml.utils.mergeutils.merge_dicts(target: Dict[str, linkml_runtime.linkml_model.meta.Element], source: Dict[str, linkml_runtime.linkml_model.meta.Element], imported_from: str, imported_from_uri: str, merge_imports: bool) None[source]
linkml.utils.mergeutils.merge_enums(schema: linkml_runtime.linkml_model.meta.SchemaDefinition, target: linkml_runtime.linkml_model.meta.EnumDefinition, source: linkml_runtime.linkml_model.meta.EnumDefinition, at_end: bool = False) None[source]

Merge the slots in source into target

Parameters
  • schema – Containing schema

  • target – mergee

  • source – enum to merge

  • at_end – True means add mergee to the end. False to the front

linkml.utils.mergeutils.merge_namespaces(target: linkml_runtime.linkml_model.meta.SchemaDefinition, mergee: linkml_runtime.linkml_model.meta.SchemaDefinition, namespaces) None[source]

Add the mergee namespace definitions to target

Parameters
  • target

  • mergee

  • namespaces

Returns

linkml.utils.mergeutils.merge_schemas(target: linkml_runtime.linkml_model.meta.SchemaDefinition, mergee: linkml_runtime.linkml_model.meta.SchemaDefinition, imported_from: Optional[str] = None, namespaces: Optional[linkml_runtime.utils.namespaces.Namespaces] = None, merge_imports: bool = True) None[source]

Merge mergee into target

linkml.utils.mergeutils.merge_slots(target: Union[linkml_runtime.linkml_model.meta.SlotDefinition, linkml_runtime.linkml_model.meta.TypeDefinition], source: Union[linkml_runtime.linkml_model.meta.SlotDefinition, linkml_runtime.linkml_model.meta.TypeDefinition], skip: Optional[List[Union[linkml_runtime.linkml_model.meta.SlotDefinitionName, linkml_runtime.linkml_model.meta.TypeDefinitionName]]] = None, inheriting: bool = True) None[source]

Merge slot source into target

Parameters
  • target – slot to merge into

  • source – slot to be merged from

  • skip – Properties to not merge (used to prevent provenance such as ‘inherited from’ from propagating)

  • inheriting – True means source is the parent. False means that everything gets copied

linkml.utils.mergeutils.set_from_schema(schema: linkml_runtime.linkml_model.meta.SchemaDefinition) None[source]
linkml.utils.mergeutils.slot_usage_name(usage_name: linkml_runtime.linkml_model.meta.SlotDefinitionName, owning_class: linkml_runtime.linkml_model.meta.ClassDefinition) linkml_runtime.linkml_model.meta.SlotDefinitionName[source]

Synthesize a unique name for an overridden slot

Parameters
  • usage_name

  • owning_class

Returns

Synthesized name

linkml.utils.rawloader module

linkml.utils.rawloader.load_raw_schema(data: Union[str, dict, TextIO], source_file: Optional[str] = None, source_file_date: Optional[str] = None, source_file_size: Optional[int] = None, base_dir: Optional[str] = None, merge_modules: Optional[bool] = True, emit_metadata: Optional[bool] = True) linkml_runtime.linkml_model.meta.SchemaDefinition[source]

Load and flatten SchemaDefinition from a file name, a URL or a block of text

@param data: URL, file name or block of text YAML Object or open file handle @param source_file: Source file name for the schema if data is type TextIO @param source_file_date: timestamp of source file if data is type TextIO @param source_file_size: size of source file if data is type TextIO @param base_dir: Working directory or base URL of sources @param merge_modules: True means combine modules into one source, false means keep separate @param emit_metadata: True means add source file info to the output @return: Un-processed Schema Definition object

linkml.utils.rawloader.mrf(self, field_name: str) None[source]

linkml.utils.schemaloader module

class linkml.utils.schemaloader.SchemaLoader(data: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition, dict], base_dir: Optional[str] = None, namespaces: Optional[linkml_runtime.utils.namespaces.Namespaces] = None, useuris: Optional[bool] = None, importmap: Optional[Mapping[str, str]] = None, logger: Optional[logging.Logger] = None, mergeimports: Optional[bool] = True, emit_metadata: Optional[bool] = True, source_file_date: Optional[str] = None, source_file_size: Optional[int] = None)[source]

Bases: object

check_prefix(prefix_or_curie_or_uri: str) None[source]
check_prefixes() None[source]

Iterate over the entire schema checking all prefixes

logger_warning(warning: str, loc_str: Optional[Union[str, linkml_runtime.utils.yamlutils.TypedNode, Iterator[linkml_runtime.utils.yamlutils.TypedNode]]]) None[source]
merge_class(cls: linkml_runtime.linkml_model.meta.ClassDefinition, merged_classes: List[linkml_runtime.linkml_model.meta.ClassDefinitionName]) None[source]

Merge parent class information into target class

Parameters
  • cls – target class

  • merged_classes – list of class names that have been merged. Used to do distal ancestor resolution

merge_enum(enum: linkml_runtime.linkml_model.meta.EnumDefinition, merged_enums: List[linkml_runtime.linkml_model.meta.EnumDefinitionName]) None[source]

Merge parent enumeration information into target enum

Parameters
  • enum – target enumeration

  • merged_enums – list of enum names that have been merged. Used to do distal ancestor resolution

merge_slot(slot: linkml_runtime.linkml_model.meta.SlotDefinition, merged_slots: List[linkml_runtime.linkml_model.meta.SlotDefinitionName]) None[source]

Merge parent slot information into target slot

Parameters
  • slot – target slot

  • merged_slots – list of slot names that have been merged. Used to do a distal ancestor resolution

merge_type(typ: linkml_runtime.linkml_model.meta.TypeDefinition, merged_types: List[linkml_runtime.linkml_model.meta.TypeDefinitionName]) None[source]

Merge parent type information into target type :param typ: target type :param merged_types: list of type names that have bee merged.

process_slot_usage_definitions()[source]

Slot usages can be used to completely define slots. Iterate over the class hierarchy finding all slot definitions that are introduced strictly as usages and add them to the slots component

process_slot_usages(cls: linkml_runtime.linkml_model.meta.ClassDefinition) None[source]

Connect any slot usage items

Parameters

cls – class to process

Returns

usage item

static raise_value_error(error: str, loc_str: Optional[Union[linkml_runtime.utils.yamlutils.TypedNode, str]] = None) None[source]
static raise_value_errors(error: str, loc_str: Optional[Union[str, linkml_runtime.utils.yamlutils.TypedNode, Iterator[linkml_runtime.utils.yamlutils.TypedNode]]]) None[source]
resolve() linkml_runtime.linkml_model.meta.SchemaDefinition[source]

Reconcile a loaded schema, applying is_a, mixins, apply_to’s and other such things. Also validate the content and load a SchemaSynopsis entry

Returns

Fully resolved definition

schema_errors() List[str][source]
slot_definition_for(slotname: linkml_runtime.linkml_model.meta.SlotDefinitionName, cls: linkml_runtime.linkml_model.meta.ClassDefinition) Optional[linkml_runtime.linkml_model.meta.SlotDefinition][source]

Find the most proximal definition for slotname in the context of cls

static slot_name_for(slot: linkml_runtime.linkml_model.meta.SlotDefinition) str[source]
validate_item_names(typ: str, names: List[str]) None[source]

linkml.utils.schemasynopsis module

class linkml.utils.schemasynopsis.SchemaSynopsis(schema: linkml_runtime.linkml_model.meta.SchemaDefinition, typerefs: Dict[linkml_runtime.linkml_model.meta.TypeDefinitionName, linkml.utils.typereferences.References] = <factory>, slotrefs: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, linkml.utils.typereferences.References] = <factory>, classrefs: Dict[linkml_runtime.linkml_model.meta.ClassDefinitionName, linkml.utils.typereferences.References] = <factory>, subsetrefs: Dict[linkml_runtime.linkml_model.meta.SubsetDefinitionName, linkml.utils.typereferences.References] = <factory>, enumrefs: Dict[linkml_runtime.linkml_model.meta.EnumDefinitionName, linkml.utils.typereferences.References] = <factory>, typebases: Dict[str, Set[linkml_runtime.linkml_model.meta.TypeDefinitionName]] = <factory>, typeofs: Dict[linkml_runtime.linkml_model.meta.TypeDefinitionName, linkml_runtime.linkml_model.meta.TypeDefinitionName] = <factory>, slotclasses: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = <factory>, definingslots: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = <factory>, slotusages: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = <factory>, owners: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]] = <factory>, inverses: Dict[str, Set[str]] = <factory>, ownslots: Dict[linkml_runtime.linkml_model.meta.ClassDefinitionName, Set[linkml_runtime.linkml_model.meta.SlotDefinitionName]] = <factory>, codesets: Dict[rdflib.term.URIRef, Set[linkml_runtime.linkml_model.meta.EnumDefinitionName]] = <factory>, roots: linkml.utils.typereferences.References = <factory>, isarefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References] = <factory>, mixinrefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References] = <factory>, mixins: linkml.utils.typereferences.References = <factory>, abstracts: linkml.utils.typereferences.References = <factory>, applytos: linkml.utils.typereferences.References = <factory>, applytorefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References] = <factory>, rangerefs: Dict[linkml_runtime.linkml_model.meta.ElementName, Set[linkml_runtime.linkml_model.meta.SlotDefinitionName]] = <factory>, inschema: Dict[str, linkml.utils.typereferences.References] = <factory>, **_kwargs)[source]

Bases: object

abstracts: linkml.utils.typereferences.References
add_ref(fromtype: linkml.utils.typereferences.RefType, fromname: linkml_runtime.linkml_model.meta.ElementName, totype: linkml.utils.typereferences.RefType, toname: linkml_runtime.linkml_model.meta.ElementName) None[source]

Add an inverse reference, indicating that to type/name is referenced by from type/name

Parameters
  • fromtype – Referencer type

  • fromname – Referencer name

  • totype – Referencee type

  • toname – Referencee name

Returns

applytorefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References]
applytos: linkml.utils.typereferences.References
classrefs: Dict[linkml_runtime.linkml_model.meta.ClassDefinitionName, linkml.utils.typereferences.References]
codesets: Dict[rdflib.term.URIRef, Set[linkml_runtime.linkml_model.meta.EnumDefinitionName]]
definingslots: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]]
enumrefs: Dict[linkml_runtime.linkml_model.meta.EnumDefinitionName, linkml.utils.typereferences.References]
errors() List[str][source]
inschema: Dict[str, linkml.utils.typereferences.References]
inverses: Dict[str, Set[str]]
isarefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References]
mixinrefs: Dict[linkml_runtime.linkml_model.meta.DefinitionName, linkml.utils.typereferences.References]
mixins: linkml.utils.typereferences.References
owners: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]]
ownslots: Dict[linkml_runtime.linkml_model.meta.ClassDefinitionName, Set[linkml_runtime.linkml_model.meta.SlotDefinitionName]]
rangerefs: Dict[linkml_runtime.linkml_model.meta.ElementName, Set[linkml_runtime.linkml_model.meta.SlotDefinitionName]]
roots: linkml.utils.typereferences.References
schema: linkml_runtime.linkml_model.meta.SchemaDefinition
slotclasses: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]]
slotrefs: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, linkml.utils.typereferences.References]
slotusages: Dict[linkml_runtime.linkml_model.meta.SlotDefinitionName, Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]]
subsetrefs: Dict[linkml_runtime.linkml_model.meta.SubsetDefinitionName, linkml.utils.typereferences.References]
summarize_class_definition(k: linkml_runtime.linkml_model.meta.ClassDefinitionName, v: linkml_runtime.linkml_model.meta.ClassDefinition) None[source]

Summarize class definition element

Parameters
  • k – Class name

  • v – Class definition

Returns

summarize_definition(typ: linkml.utils.typereferences.RefType, k: linkml_runtime.linkml_model.meta.DefinitionName, v: linkml_runtime.linkml_model.meta.Definition) None[source]

Summarize slot and class definitions

Parameters
  • typ – type (slot or class)

  • k – name

  • v – definition

Returns

summarize_element(typ: linkml.utils.typereferences.RefType, k: linkml_runtime.linkml_model.meta.ElementName, v: linkml_runtime.linkml_model.meta.Element) None[source]

Summarize element level items

Parameters
  • typ – element type

  • k – element name

  • v – element deffinition

Returns

summarize_enum_definition(k: linkml_runtime.linkml_model.meta.EnumDefinitionName, v: linkml_runtime.linkml_model.meta.EnumDefinition)[source]

Summarize enum definition

Parameters
  • k – Enum name

  • v – Enum definition

Returns

summarize_slot_definition(k: linkml_runtime.linkml_model.meta.SlotDefinitionName, v: linkml_runtime.linkml_model.meta.SlotDefinition) None[source]

Summarize a slot definition :param k: slot name :param v: slot definition :return:

summarize_type_definition(k: linkml_runtime.linkml_model.meta.TypeDefinitionName, v: linkml_runtime.linkml_model.meta.TypeDefinition)[source]

Summarize type definition

Parameters
  • k – Type name

  • v – Type definition

Returns

summary() str[source]
typebases: Dict[str, Set[linkml_runtime.linkml_model.meta.TypeDefinitionName]]
typeofs: Dict[linkml_runtime.linkml_model.meta.TypeDefinitionName, linkml_runtime.linkml_model.meta.TypeDefinitionName]
typerefs: Dict[linkml_runtime.linkml_model.meta.TypeDefinitionName, linkml.utils.typereferences.References]
linkml.utils.schemasynopsis.empty_references() dataclasses.field[source]

linkml.utils.sqltransformer_old module

linkml.utils.typereferences module

class linkml.utils.typereferences.RefType(name: str)[source]

Bases: object

name: str
class linkml.utils.typereferences.References(classrefs: typing.Set[linkml_runtime.linkml_model.meta.ClassDefinitionName] = <factory>, slotrefs: typing.Set[linkml_runtime.linkml_model.meta.SlotDefinitionName] = <factory>, typerefs: typing.Set[linkml_runtime.linkml_model.meta.TypeDefinitionName] = <factory>, subsetrefs: typing.Set[linkml_runtime.linkml_model.meta.SubsetDefinitionName] = <factory>, enumrefs: typing.Set[linkml_runtime.linkml_model.meta.EnumDefinitionName] = <factory>)[source]

Bases: object

Summary of references to a given class. The reference class is the key to the dictionary carrying classrefs

addref(fromtype: linkml.utils.typereferences.RefType, fromname: linkml_runtime.linkml_model.meta.ElementName) None[source]
classrefs: Set[linkml_runtime.linkml_model.meta.ClassDefinitionName]
enumrefs: Set[linkml_runtime.linkml_model.meta.EnumDefinitionName]
slotrefs: Set[linkml_runtime.linkml_model.meta.SlotDefinitionName]
subsetrefs: Set[linkml_runtime.linkml_model.meta.SubsetDefinitionName]
typerefs: Set[linkml_runtime.linkml_model.meta.TypeDefinitionName]
update(other: linkml.utils.typereferences.References) None[source]

linkml.utils.validation module

linkml.utils.validation.validate_object(data: linkml_runtime.utils.yamlutils.YAMLRoot, schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], target_class: Optional[Type[linkml_runtime.utils.yamlutils.YAMLRoot]] = None, closed: bool = True)[source]

validates instance data against a schema

Parameters
  • data – LinkML instance to be validates

  • schema – LinkML schema

  • target_class – class in schema to validate against

  • closed

Returns

Module contents