diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..eebc71dd24 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.1/envs/dbo diff --git a/BRANCH.md b/BRANCH.md new file mode 100644 index 0000000000..e0a17918fb --- /dev/null +++ b/BRANCH.md @@ -0,0 +1,12 @@ +For managing our fork, there are primarily 3 branches we will be working with. + +1. upstream/master - This is the upstream package that we want to get all our public improvements in eventually +2. main - This is our internal shadow of upstream/master, it should be 1:1. This is what we should make branches off of for changes we want to go upstream +3. onboard-main - This is our final copy of digital buildings with all of the upstream changes, pending upstream changes, and any other changes that aren't compatible with the upstream/master + +Workflow for making improvements: +1. Branch off of main +2. make changes +3. pull-request into upstream/master + +Upon acceptance and merge, we will update our internal main and subsequently update our onboard-main. If there are changes we NEED in onboard-main, we can accelerate part of the cycle and pull-request into onboard-main at the same time as we PR into upstream/master. When it does get accepted, it should result in a noop merge and everything will be healthy again. But complications will arise if changes get made to the PR after the PR lands in onboard-main, hence this not being the standard workflow. diff --git a/tools/validators/instance_validator/ontology_dump.py b/tools/validators/instance_validator/ontology_dump.py new file mode 100755 index 0000000000..80cfafaa77 --- /dev/null +++ b/tools/validators/instance_validator/ontology_dump.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +import csv + +from validate import generate_universe + +universe = generate_universe.BuildUniverse() +types_by_ns = universe.entity_type_universe.type_namespaces_map +rows = [] + +for namespace, entities in types_by_ns.items(): + print(f"\n-- working on namespace '{namespace}'--\n") + + # if namespace == 'HVAC': + # __import__("IPython").embed() + + for entity_name, entity in entities.valid_types_map.items(): + print(f"Entity '{entity_name}'") + + # if entity_name == 'AHU_BSPC_CO2M_DX4SC_ECON_EFSS_EFVSC_FDPM4X_HTSC_MOAFC_OAFC_SFSS_SFVSC_SSPC': + # __import__("IPython").embed() + + entity_row = { + 'guid': entity.guid, + 'namespace': namespace, + 'name': entity_name, + 'is_canonical': entity.is_canonical, + 'is_abstract': entity.is_abstract, + 'description': entity.description, + 'parents': "|".join([p.typename for p in entity.parent_names.values()]), + } + + # many canonical types don't define any new fields, they mix-in existing abstract + # types e.g. AHU_BSPC_CO2M_DX4SC_ECON_EFSS_EFVSC_FDPM4X_HTSC_MOAFC_OAFC_SFSS_SFVSC_SSPC + if not entity.local_field_names: + canonical_row = { + **entity_row, + 'dbo.point_type': None, + 'field_optional': None, + } + rows.append(canonical_row) + + for field_name, field in entity.local_field_names.items(): + increment = field.field.increment + field_row = { + **entity_row, + 'dbo.point_type': field.field.field, + 'dbo.point_type_increment': increment, + 'field_optional': field.optional, + } + rows.append(field_row) + +if rows: + rows.sort(key=lambda r: r['guid']) + + with open('flat_ontology.csv', 'w', newline='', encoding='utf-8') as f: + writer = csv.DictWriter(f, rows[0].keys(), delimiter=',', lineterminator='\n', quoting=csv.QUOTE_MINIMAL) + writer.writeheader() + writer.writerows(rows) +else: + sys.stderr.write( + "No rows generated, ensure the validator is installed & updated (tools/validators/ontology_validator/README.md)")