architxt.generator#
Generator of instances.
Functions
|
Generate a collection tree. |
|
Generate a group tree structure with the given name and elements. |
|
Generate a database instance as a tree, based on the given groups and relations schema. |
|
Generate a relation tree structure based on the given parameters. |
- architxt.generator.gen_collection(name, elements)[source]#
Generate a collection tree.
- Parameters:
- Return type:
- Returns:
A tree representing the collection.
>>> from architxt.tree import Tree >>> elems = [Tree('Element1', []), Tree('Element2', [])] >>> collection_tree = gen_collection('Collection', elems) >>> print(collection_tree) (COLL::Collection (Element1 ) (Element2 ))
- architxt.generator.gen_group(schema, name)[source]#
Generate a group tree structure with the given name and elements.
- Parameters:
- Return type:
- Returns:
The generated group tree.
>>> from architxt.schema import Group >>> group = Group(name='Fruits', entities={'Apple', 'Banana', 'Cherry'}) >>> schema = Schema.from_description(groups={group}) >>> group_tree = gen_group(schema, 'Fruits') >>> print(group_tree) (GROUP::Fruits (ENT::Apple data) (ENT::Banana data) (ENT::Cherry data))
- architxt.generator.gen_instance(schema, *, size=200, generate_collections=True)[source]#
Generate a database instance as a tree, based on the given groups and relations schema.
- Parameters:
- Return type:
- Returns:
A tree representing the generated instance.
- architxt.generator.gen_relation(schema, name)[source]#
Generate a relation tree structure based on the given parameters.
- Parameters:
- Return type:
- Returns:
The generated relation tree.
>>> from architxt.schema import Group, Relation >>> schema = Schema.from_description( ... groups={ ... Group(name='Fruits', entities={'Apple', 'Banana'}), ... Group(name='Colors', entities={'Red', 'Blue'}), ... }, ... relations={Relation(name='Preference', left='Fruits', right='Colors')} ... ) >>> relation_tree = gen_relation(schema, 'Preference') >>> print(relation_tree) (REL::Preference (GROUP::Fruits (ENT::Apple data) (ENT::Banana data)) (GROUP::Colors (ENT::Blue data) (ENT::Red data)))