-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEAT-666] 😈Mapping include connections (#876)
* docs: enums * build; freeze mistune * linting * feat: support reading url * refactor: catch_issues return issues * refactor; removed unused parameters * refactor; remove unused * refactor; moved logic out of NeatSession * tests: updated test * fix: DMS import bug * build: changelog * refactor; simplification * refactor; proper error * refactor; do not require you need to see resource * fix: introduced bug * tests: stipulate test * Linting and static code checks * refactor; renaming * tests: fix test * refactor; reset * build: changelog entry * style: fix typo * fix: writing model to zip * refactor: update cognite-core * fix: bug in DMSImporter * refactor: removed unused * refactor; introduced subclasses * refactor: split out enterprise * refactor; split out solution * refactor; split out data-product * fix: adjustment * refactor; cleanup ToExtension * refactor: combine init param * refactor; move out * fix; introduced bug * refactor: reduce lines * refactor; clean up ToSolutionModel * refactor cleanup data product * build: changelog * refactor: drop neat id from columns * fix: drop neatId * refactor; increase flexibility of data product * tests: extending to mock client * refactor: inherit filter * tests: extending test and fixing bug * tests: regen * tests: refactor * tests; extend test to include data product * build: changelog * fix: ensure valid model * build: changelog * tests: regen * tests: updated * feat; automatically include path and root when mapping to asset parent * refactor: regen * Ãrefactor; added readonly properties * fix: skip readonly properties * fix; proper implementation * build; changelog * test: regen * refactor: review feedback * build: upgrade toolkit to 0.3.23 * build: upgrade modules * build: upgrade to toolkit 0.3 * build: added missin acl\ * docs; document the to solution model parameters * refactor; switch to container filter * fix: deterministic * tests: regen * tests: regen * tests: regen * build: changelog * feat; first draft connection to literal * build: changelog * tests: include in test * tests: regen * tests: added missing step * test: regen * fix: typo * tests: extending wind farm with sequence rows * refactor; update test data * feat: introduced neat sequence * feat: factory method * feat: first pass of updating extractor * tests: updated test data * refactor; update example * feat: implemented unpacking * refactor: column as list * tests: updated test * fix: keep order * Ãdocs; document new * build: changelog * refactor: move out special handling to sequence extractor * refactor: introduce extra parameter * tests: extend test * tests: as write instead * feat; implemented unpacking of sequences * refactor: finish implementation * tests: include sequence in classic to dms test * refactor: renaming * refactor: added connections to classic core mapping * refactor; update excel to yaml script * refactor; regen yaml file * Ãrefactor: update rules mapper to include new properties * fix: skip suffixing in transformation * fix: updating enums * refactor; regen * refacotor added dummy property * fix: include GUID container * tests: regen * tests: updated test case * build: changelog --------- Co-authored-by: doctrino <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,196 additions
and
428 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,25 @@ | ||
from datetime import datetime, timezone | ||
|
||
from cognite.neat import NeatSession, get_cognite_client | ||
from pathlib import Path | ||
from rich import print | ||
|
||
from cognite.neat._rules.exporters import YAMLExporter | ||
from cognite.neat._rules.importers import ExcelImporter | ||
from cognite.neat._rules.transformers import VerifyDMSRules | ||
from cognite.neat._store._provenance import Change | ||
|
||
THIS_FOLDER = Path(__file__).resolve().parent | ||
|
||
XLSX_FILE = THIS_FOLDER / "core_classic_mapping.xlsx" | ||
|
||
TARGET_FILE = THIS_FOLDER.parent / "cognite" / "neat" / "_rules" / "models" / "mapping" / "_classic2core.yaml" | ||
|
||
def main() -> None: | ||
client = get_cognite_client(".env") | ||
neat = NeatSession(client) | ||
|
||
issues = neat.read.excel(XLSX_FILE) | ||
if issues.has_errors: | ||
neat.inspect.issues() | ||
return | ||
def main() -> None: | ||
read_rules = ExcelImporter(XLSX_FILE).to_rules() | ||
print(f"[bold green]Read {XLSX_FILE.name}[/bold green]") | ||
# Redoing the .verify to skip the validation step. | ||
start = datetime.now(timezone.utc) | ||
transformer = VerifyDMSRules("continue", validate=False) | ||
source_id, last_unverified_rule = neat._state.data_model.last_unverified_rule | ||
result = transformer.transform(last_unverified_rule) | ||
end = datetime.now(timezone.utc) | ||
issues = result.issues | ||
if issues.has_errors: | ||
neat.inspect.issues() | ||
return | ||
|
||
dms_rules = VerifyDMSRules(validate=False).transform(read_rules) | ||
print("[bold green]Verified[/bold green]") | ||
# change = Change.from_rules_activity( | ||
# result.rules, | ||
# transformer.agent, | ||
# start, | ||
# end, | ||
# f"Verified data model {source_id} as {result.rules.metadata.identifier}", | ||
# neat._state.data_model.provenance.source_entity(source_id) | ||
# or neat._state.data_model.provenance.target_entity(source_id), | ||
# ) | ||
# | ||
# neat._state.data_model.write(result.rules, change) | ||
|
||
neat.to.yaml(TARGET_FILE, format="neat") | ||
|
||
YAMLExporter().export_to_file(dms_rules, TARGET_FILE) | ||
print(f"[bold green]Wrote {TARGET_FILE.name}[/bold green]") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.