cognite-neat 0.109.4__tar.gz → 0.111.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/PKG-INFO +1 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_alpha.py +8 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/_api/schema.py +43 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/data_classes/schema.py +4 -4
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_constants.py +15 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/__init__.py +4 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_base.py +8 -16
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +48 -19
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +23 -17
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +15 -17
- cognite_neat-0.111.0/cognite/neat/_graph/extractors/_dict.py +102 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_dms.py +27 -40
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_dms_graph.py +30 -3
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_iodd.py +3 -3
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_mock_graph_generator.py +9 -7
- cognite_neat-0.111.0/cognite/neat/_graph/extractors/_raw.py +67 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/loaders/_base.py +20 -4
- cognite_neat-0.111.0/cognite/neat/_graph/loaders/_rdf2dms.py +735 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/queries/_base.py +163 -133
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/__init__.py +1 -3
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_classic_cdf.py +6 -22
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_rdfpath.py +2 -49
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/__init__.py +1 -6
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/_base.py +21 -252
- cognite_neat-0.111.0/cognite/neat/_issues/_contextmanagers.py +46 -0
- cognite_neat-0.111.0/cognite/neat/_issues/_factory.py +69 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/errors/__init__.py +20 -4
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/errors/_external.py +7 -0
- cognite_neat-0.111.0/cognite/neat/_issues/errors/_wrapper.py +89 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/formatters.py +4 -4
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/__init__.py +3 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/_properties.py +8 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/user_modeling.py +12 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/_constants.py +12 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/_shared.py +3 -2
- cognite_neat-0.111.0/cognite/neat/_rules/analysis/__init__.py +3 -0
- cognite_neat-0.111.0/cognite/neat/_rules/analysis/_base.py +556 -0
- cognite_neat-0.111.0/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_rules2excel.py +3 -9
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_rules2instance_template.py +2 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_rules2ontology.py +5 -4
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_base.py +2 -47
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dms2rules.py +7 -10
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +2 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +66 -26
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/_shared.py +1 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_spreadsheet2rules.py +12 -9
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/_base_rules.py +0 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/data_types.py +7 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/dms/_exporter.py +9 -8
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/dms/_rules.py +29 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/dms/_rules_input.py +9 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/dms/_validation.py +115 -5
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_loaders.py +1 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_multi_value.py +2 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_single_value.py +8 -3
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_wrapped.py +2 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/information/_rules.py +18 -17
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/information/_rules_input.py +3 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/information/_validation.py +66 -17
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/transformers/__init__.py +8 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/transformers/_converters.py +234 -44
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/transformers/_verification.py +5 -10
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_base.py +6 -4
- cognite_neat-0.111.0/cognite/neat/_session/_explore.py +39 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_inspect.py +25 -6
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_prepare.py +12 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_read.py +88 -20
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_set.py +7 -1
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_show.py +11 -123
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_state.py +6 -2
- cognite_neat-0.111.0/cognite/neat/_session/_subset.py +64 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_to.py +177 -19
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_store/_graph_store.py +9 -246
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/rdf_.py +36 -5
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/spreadsheet.py +44 -1
- cognite_neat-0.111.0/cognite/neat/_utils/text.py +255 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/upload.py +2 -0
- cognite_neat-0.111.0/cognite/neat/_version.py +2 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/pyproject.toml +2 -2
- cognite_neat-0.109.4/cognite/neat/_graph/loaders/_rdf2dms.py +0 -642
- cognite_neat-0.109.4/cognite/neat/_graph/queries/_construct.py +0 -187
- cognite_neat-0.109.4/cognite/neat/_graph/queries/_shared.py +0 -173
- cognite_neat-0.109.4/cognite/neat/_issues/errors/_wrapper.py +0 -11
- cognite_neat-0.109.4/cognite/neat/_rules/analysis/__init__.py +0 -4
- cognite_neat-0.109.4/cognite/neat/_rules/analysis/_base.py +0 -385
- cognite_neat-0.109.4/cognite/neat/_rules/analysis/_dms.py +0 -57
- cognite_neat-0.109.4/cognite/neat/_rules/analysis/_information.py +0 -249
- cognite_neat-0.109.4/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- cognite_neat-0.109.4/cognite/neat/_rules/models/_rdfpath.py +0 -372
- cognite_neat-0.109.4/cognite/neat/_utils/text.py +0 -168
- cognite_neat-0.109.4/cognite/neat/_version.py +0 -2
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/LICENSE +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/README.md +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/_api/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/_api/data_modeling_loaders.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/_api_client.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/data_classes/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/data_classes/data_modeling.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/data_classes/neat_sequence.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_client/testing.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/_shared.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/loaders/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/queries/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_iodd.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_prune_graph.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/transformers/_value_type.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/errors/_general.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/errors/_properties.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/errors/_resources.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/_external.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/_models.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_issues/warnings/_resources.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/catalog/classic_model.xlsx +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/catalog/hello_world_pump.xlsx +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/_imf2rules.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_rdf/_owl2rules.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/_base_input.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/_types.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/information/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/mapping/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/mapping/_classic2core.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/models/mapping/_classic2core.yaml +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/transformers/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_rules/transformers/_mapping.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_collector.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_create.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_drop.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_fix.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_mapping.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_session/exceptions.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_store/_provenance.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_store/_rules_store.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_store/exceptions.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/auth.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/auxiliary.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/graph_transformations_report.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/io_.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/py.typed +0 -0
|
@@ -13,3 +13,11 @@ class AlphaFlags:
|
|
|
13
13
|
manual_rules_edit = AlphaWarning("enable_manual_edit")
|
|
14
14
|
same_space_properties_only_export = AlphaWarning("same-space-properties-only")
|
|
15
15
|
standardize_naming = AlphaWarning("standardize_naming")
|
|
16
|
+
standardize_space_and_version = AlphaWarning("standardize_space_and_version")
|
|
17
|
+
data_model_subsetting = AlphaWarning("data_model_subsetting")
|
|
18
|
+
ontology_read = AlphaWarning("ontology_read")
|
|
19
|
+
imf_read = AlphaWarning("imf_read")
|
|
20
|
+
dexpi_read = AlphaWarning("dexpi_read")
|
|
21
|
+
aml_read = AlphaWarning("aml_read")
|
|
22
|
+
csv_read = AlphaWarning("csv_read")
|
|
23
|
+
to_ontology = AlphaWarning("to_ontology")
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
from collections
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from collections.abc import Iterable, Sequence
|
|
3
|
+
from graphlib import CycleError, TopologicalSorter
|
|
2
4
|
from typing import TYPE_CHECKING
|
|
3
5
|
|
|
4
6
|
from cognite.client import data_modeling as dm
|
|
5
7
|
|
|
6
8
|
from cognite.neat._client.data_classes.data_modeling import ContainerApplyDict, SpaceApplyDict, ViewApplyDict
|
|
7
9
|
from cognite.neat._client.data_classes.schema import DMSSchema
|
|
10
|
+
from cognite.neat._constants import is_hierarchy_property
|
|
8
11
|
from cognite.neat._issues.errors import NeatValueError
|
|
9
12
|
|
|
10
13
|
if TYPE_CHECKING:
|
|
@@ -110,3 +113,42 @@ class SchemaAPI:
|
|
|
110
113
|
views=view_write,
|
|
111
114
|
containers=container_write,
|
|
112
115
|
)
|
|
116
|
+
|
|
117
|
+
@staticmethod
|
|
118
|
+
def get_hierarchical_properties(
|
|
119
|
+
views: Iterable[dm.View | dm.ViewApply],
|
|
120
|
+
) -> dict[dm.ViewId, set[str]]:
|
|
121
|
+
"""Sorts the views by container constraints."""
|
|
122
|
+
hierarchical_properties_by_view_id: dict[dm.ViewId, set[str]] = defaultdict(set)
|
|
123
|
+
for view in views:
|
|
124
|
+
for prop_id, prop in (view.properties or {}).items():
|
|
125
|
+
if not isinstance(prop, dm.MappedProperty | dm.MappedPropertyApply):
|
|
126
|
+
continue
|
|
127
|
+
if is_hierarchy_property(prop.container, prop.container_property_identifier):
|
|
128
|
+
hierarchical_properties_by_view_id[view.as_id()].add(prop_id)
|
|
129
|
+
return hierarchical_properties_by_view_id
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def get_view_order_by_direct_relation_constraints(views: Iterable[dm.View]) -> list[dm.ViewId]:
|
|
133
|
+
"""Sorts the views by container constraints."""
|
|
134
|
+
view_sequence = list(views)
|
|
135
|
+
view_ids_by_container: dict[dm.ContainerId, set[dm.ViewId]] = defaultdict(set)
|
|
136
|
+
for view in view_sequence:
|
|
137
|
+
for container_id in view.referenced_containers():
|
|
138
|
+
view_ids_by_container[container_id].add(view.as_id())
|
|
139
|
+
|
|
140
|
+
view_by_dependency: dict[dm.ViewId, set[dm.ViewId]] = {}
|
|
141
|
+
for view in view_sequence:
|
|
142
|
+
view_id = view.as_id()
|
|
143
|
+
view_by_dependency[view_id] = set()
|
|
144
|
+
for prop in view.properties.values():
|
|
145
|
+
if (
|
|
146
|
+
isinstance(prop, dm.MappedProperty)
|
|
147
|
+
and isinstance(prop.type, dm.DirectRelation)
|
|
148
|
+
and prop.type.container
|
|
149
|
+
):
|
|
150
|
+
view_by_dependency[view_id].update(view_ids_by_container[prop.type.container])
|
|
151
|
+
try:
|
|
152
|
+
return list(TopologicalSorter(view_by_dependency).static_order())
|
|
153
|
+
except CycleError as e:
|
|
154
|
+
raise NeatValueError("Cycle in direct relation constraints") from e
|
|
@@ -34,7 +34,7 @@ from cognite.neat._issues.warnings import (
|
|
|
34
34
|
FileTypeUnexpectedWarning,
|
|
35
35
|
ResourcesDuplicatedWarning,
|
|
36
36
|
)
|
|
37
|
-
from cognite.neat._utils.text import
|
|
37
|
+
from cognite.neat._utils.text import to_camel_case
|
|
38
38
|
|
|
39
39
|
if sys.version_info >= (3, 11):
|
|
40
40
|
from typing import Self
|
|
@@ -167,7 +167,7 @@ class DMSSchema:
|
|
|
167
167
|
if "." not in filename.stem:
|
|
168
168
|
continue
|
|
169
169
|
resource_type = filename.stem.rsplit(".", 1)[-1]
|
|
170
|
-
if attr_name := cls._FIELD_NAME_BY_RESOURCE_TYPE.get(resource_type):
|
|
170
|
+
if attr_name := cls._FIELD_NAME_BY_RESOURCE_TYPE.get(resource_type.casefold()):
|
|
171
171
|
data.setdefault(attr_name, [])
|
|
172
172
|
context.setdefault(attr_name, [])
|
|
173
173
|
try:
|
|
@@ -238,7 +238,7 @@ class DMSSchema:
|
|
|
238
238
|
data_dict = data
|
|
239
239
|
loaded: dict[str, Any] = {}
|
|
240
240
|
for attr in fields(cls):
|
|
241
|
-
if items := data_dict.get(attr.name) or data_dict.get(
|
|
241
|
+
if items := data_dict.get(attr.name) or data_dict.get(to_camel_case(attr.name)):
|
|
242
242
|
if attr.name == "data_model":
|
|
243
243
|
if isinstance(items, list) and len(items) > 1:
|
|
244
244
|
try:
|
|
@@ -320,7 +320,7 @@ class DMSSchema:
|
|
|
320
320
|
cls_fields = sorted(fields(self), key=lambda f: f.name) if sort else fields(self)
|
|
321
321
|
for attr in cls_fields:
|
|
322
322
|
if items := getattr(self, attr.name):
|
|
323
|
-
key =
|
|
323
|
+
key = to_camel_case(attr.name) if camel_case else attr.name
|
|
324
324
|
if isinstance(items, CogniteResourceDict):
|
|
325
325
|
if sort:
|
|
326
326
|
output[key] = [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import re
|
|
1
2
|
from collections.abc import Mapping
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import TYPE_CHECKING
|
|
@@ -69,7 +70,9 @@ EXAMPLE_RULES = PACKAGE_DIRECTORY / "_rules" / "examples"
|
|
|
69
70
|
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "_graph" / "examples"
|
|
70
71
|
EXAMPLE_WORKFLOWS = PACKAGE_DIRECTORY / "_workflows" / "examples"
|
|
71
72
|
|
|
72
|
-
DEFAULT_SPACE_URI = "http://purl.org/cognite/{space}#"
|
|
73
|
+
DEFAULT_SPACE_URI = "http://purl.org/cognite/space/{space}#"
|
|
74
|
+
SPACE_URI_PATTERN = re.compile(r"http://purl.org/cognite/space/(?P<space>[^#]+)#$")
|
|
75
|
+
DEFAULT_RAW_URI = "http://purl.org/cognite/raw#"
|
|
73
76
|
DEFAULT_NAMESPACE = Namespace("http://purl.org/cognite/neat/")
|
|
74
77
|
CDF_NAMESPACE = Namespace("https://cognitedata.com/")
|
|
75
78
|
DEFAULT_BASE_URI = URIRef(DEFAULT_NAMESPACE)
|
|
@@ -164,11 +167,22 @@ READONLY_PROPERTIES_BY_CONTAINER: Mapping[dm.ContainerId, frozenset[str]] = {
|
|
|
164
167
|
dm.ContainerId("cdf_cdm", "CogniteFile"): frozenset({"isUploaded", "uploadedTime"}),
|
|
165
168
|
}
|
|
166
169
|
|
|
170
|
+
HIERARCHICAL_PROPERTIES_BY_CONTAINER: Mapping[dm.ContainerId, frozenset[str]] = {
|
|
171
|
+
dm.ContainerId("cdf_cdm", "CogniteAsset"): frozenset({"assetHierarchy_parent"})
|
|
172
|
+
}
|
|
173
|
+
|
|
167
174
|
|
|
168
175
|
def is_readonly_property(container: dm.ContainerId, property_: str) -> bool:
|
|
169
176
|
return container in READONLY_PROPERTIES_BY_CONTAINER and property_ in READONLY_PROPERTIES_BY_CONTAINER[container]
|
|
170
177
|
|
|
171
178
|
|
|
179
|
+
def is_hierarchy_property(container: dm.ContainerId, property_: str) -> bool:
|
|
180
|
+
return (
|
|
181
|
+
container in HIERARCHICAL_PROPERTIES_BY_CONTAINER
|
|
182
|
+
and property_ in HIERARCHICAL_PROPERTIES_BY_CONTAINER[container]
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
172
186
|
DMS_RESERVED_PROPERTIES = frozenset(
|
|
173
187
|
{
|
|
174
188
|
"createdTime",
|
|
@@ -11,10 +11,12 @@ from ._classic_cdf._relationships import RelationshipsExtractor
|
|
|
11
11
|
from ._classic_cdf._sequences import SequencesExtractor
|
|
12
12
|
from ._classic_cdf._timeseries import TimeSeriesExtractor
|
|
13
13
|
from ._dexpi import DexpiExtractor
|
|
14
|
+
from ._dict import DictExtractor
|
|
14
15
|
from ._dms import DMSExtractor
|
|
15
16
|
from ._dms_graph import DMSGraphExtractor
|
|
16
17
|
from ._iodd import IODDExtractor
|
|
17
18
|
from ._mock_graph_generator import MockGraphGenerator
|
|
19
|
+
from ._raw import RAWExtractor
|
|
18
20
|
from ._rdf_file import RdfFileExtractor
|
|
19
21
|
|
|
20
22
|
__all__ = [
|
|
@@ -25,12 +27,14 @@ __all__ = [
|
|
|
25
27
|
"DMSGraphExtractor",
|
|
26
28
|
"DataSetExtractor",
|
|
27
29
|
"DexpiExtractor",
|
|
30
|
+
"DictExtractor",
|
|
28
31
|
"EventsExtractor",
|
|
29
32
|
"FilesExtractor",
|
|
30
33
|
"IODDExtractor",
|
|
31
34
|
"KnowledgeGraphExtractor",
|
|
32
35
|
"LabelsExtractor",
|
|
33
36
|
"MockGraphGenerator",
|
|
37
|
+
"RAWExtractor",
|
|
34
38
|
"RdfFileExtractor",
|
|
35
39
|
"RelationshipsExtractor",
|
|
36
40
|
"SequencesExtractor",
|
{cognite_neat-0.109.4 → cognite_neat-0.111.0}/cognite/neat/_graph/extractors/_classic_cdf/_base.py
RENAMED
|
@@ -61,8 +61,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
61
61
|
Args:
|
|
62
62
|
items (Iterable[T_CogniteResource]): An iterable of classic resource.
|
|
63
63
|
namespace (Namespace, optional): The namespace to use. Defaults to DEFAULT_NAMESPACE.
|
|
64
|
-
to_type (Callable[[T_CogniteResource], str | None], optional): A function to convert an item to a type.
|
|
65
|
-
Defaults to None. If None or if the function returns None, the asset will be set to the default type.
|
|
66
64
|
total (int, optional): The total number of items to load. If passed, you will get a progress bar if rich
|
|
67
65
|
is installed. Defaults to None.
|
|
68
66
|
limit (int, optional): The maximal number of items to load. Defaults to None. This is typically used for
|
|
@@ -87,7 +85,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
87
85
|
self,
|
|
88
86
|
items: Iterable[T_CogniteResource],
|
|
89
87
|
namespace: Namespace | None = None,
|
|
90
|
-
to_type: Callable[[T_CogniteResource], str | None] | None = None,
|
|
91
88
|
total: int | None = None,
|
|
92
89
|
limit: int | None = None,
|
|
93
90
|
unpack_metadata: bool = True,
|
|
@@ -99,7 +96,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
99
96
|
):
|
|
100
97
|
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
101
98
|
self.items = items
|
|
102
|
-
self.to_type = to_type
|
|
103
99
|
self.total = total
|
|
104
100
|
self.limit = min(limit, total) if limit and total else limit
|
|
105
101
|
self.unpack_metadata = unpack_metadata
|
|
@@ -161,7 +157,7 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
161
157
|
if self._log_urirefs and hasattr(item, "external_id"):
|
|
162
158
|
self._uriref_by_external_id[item.external_id] = id_
|
|
163
159
|
|
|
164
|
-
type_ = self._get_rdf_type(
|
|
160
|
+
type_ = self._get_rdf_type()
|
|
165
161
|
|
|
166
162
|
# Set rdf type
|
|
167
163
|
triples: list[Triple] = [(id_, RDF.type, self.namespace[type_])]
|
|
@@ -215,16 +211,14 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
215
211
|
if value and (self.skip_metadata_values is None or value.casefold() not in self.skip_metadata_values):
|
|
216
212
|
yield (
|
|
217
213
|
id_,
|
|
218
|
-
self.namespace[key],
|
|
214
|
+
self.namespace[urllib.parse.quote(key)],
|
|
219
215
|
Literal(string_to_ideal_type(value)),
|
|
220
216
|
)
|
|
221
217
|
else:
|
|
222
218
|
yield id_, self.namespace.metadata, Literal(json.dumps(metadata), datatype=XSD._NS["json"])
|
|
223
219
|
|
|
224
|
-
def _get_rdf_type(self
|
|
220
|
+
def _get_rdf_type(self) -> str:
|
|
225
221
|
type_ = self._default_rdf_type
|
|
226
|
-
if self.to_type:
|
|
227
|
-
type_ = self.to_type(item) or type_
|
|
228
222
|
if self.prefix:
|
|
229
223
|
type_ = f"{self.prefix}{type_}"
|
|
230
224
|
return self._SPACE_PATTERN.sub("_", type_)
|
|
@@ -263,7 +257,11 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
263
257
|
"created_time",
|
|
264
258
|
"last_updated_time",
|
|
265
259
|
} and isinstance(raw, int):
|
|
266
|
-
|
|
260
|
+
try:
|
|
261
|
+
return Literal(datetime.fromtimestamp(raw / 1000, timezone.utc), datatype=XSD.dateTime)
|
|
262
|
+
except (OSError, ValueError) as e:
|
|
263
|
+
warnings.warn(NeatValueWarning(f"Failed to convert timestamp {raw} to datetime: {e!s}"), stacklevel=2)
|
|
264
|
+
return Literal(raw)
|
|
267
265
|
elif key == "labels":
|
|
268
266
|
from ._labels import LabelsExtractor
|
|
269
267
|
|
|
@@ -284,7 +282,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
284
282
|
client: CogniteClient,
|
|
285
283
|
data_set_external_id: str,
|
|
286
284
|
namespace: Namespace | None = None,
|
|
287
|
-
to_type: Callable[[T_CogniteResource], str | None] | None = None,
|
|
288
285
|
limit: int | None = None,
|
|
289
286
|
unpack_metadata: bool = True,
|
|
290
287
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -297,7 +294,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
297
294
|
return cls(
|
|
298
295
|
items,
|
|
299
296
|
namespace,
|
|
300
|
-
to_type,
|
|
301
297
|
total,
|
|
302
298
|
limit,
|
|
303
299
|
unpack_metadata,
|
|
@@ -321,7 +317,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
321
317
|
client: CogniteClient,
|
|
322
318
|
root_asset_external_id: str,
|
|
323
319
|
namespace: Namespace | None = None,
|
|
324
|
-
to_type: Callable[[T_CogniteResource], str | None] | None = None,
|
|
325
320
|
limit: int | None = None,
|
|
326
321
|
unpack_metadata: bool = True,
|
|
327
322
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -334,7 +329,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
334
329
|
return cls(
|
|
335
330
|
items,
|
|
336
331
|
namespace,
|
|
337
|
-
to_type,
|
|
338
332
|
total,
|
|
339
333
|
limit,
|
|
340
334
|
unpack_metadata,
|
|
@@ -357,7 +351,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
357
351
|
cls,
|
|
358
352
|
file_path: str | Path,
|
|
359
353
|
namespace: Namespace | None = None,
|
|
360
|
-
to_type: Callable[[T_CogniteResource], str | None] | None = None,
|
|
361
354
|
limit: int | None = None,
|
|
362
355
|
unpack_metadata: bool = True,
|
|
363
356
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -370,7 +363,6 @@ class ClassicCDFBaseExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
370
363
|
return cls(
|
|
371
364
|
items,
|
|
372
365
|
namespace,
|
|
373
|
-
to_type,
|
|
374
366
|
total,
|
|
375
367
|
limit,
|
|
376
368
|
unpack_metadata,
|
|
@@ -16,12 +16,10 @@ from cognite.neat._issues.warnings import CDFAuthWarning, NeatValueWarning
|
|
|
16
16
|
from cognite.neat._rules._shared import ReadRules
|
|
17
17
|
from cognite.neat._rules.catalog import classic_model
|
|
18
18
|
from cognite.neat._rules.models import InformationInputRules, InformationRules
|
|
19
|
-
from cognite.neat._rules.models._rdfpath import Entity as RDFPathEntity
|
|
20
|
-
from cognite.neat._rules.models._rdfpath import RDFPath, SingleProperty
|
|
21
19
|
from cognite.neat._shared import Triple
|
|
22
20
|
from cognite.neat._utils.collection_ import chunker, iterate_progress_bar
|
|
23
21
|
from cognite.neat._utils.rdf_ import remove_namespace_from_uri
|
|
24
|
-
from cognite.neat._utils.text import
|
|
22
|
+
from cognite.neat._utils.text import to_snake_case
|
|
25
23
|
|
|
26
24
|
from ._assets import AssetsExtractor
|
|
27
25
|
from ._base import ClassicCDFBaseExtractor, InstanceIdPrefix
|
|
@@ -104,6 +102,8 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
104
102
|
limit_per_type: int | None = None,
|
|
105
103
|
prefix: str | None = None,
|
|
106
104
|
identifier: typing.Literal["id", "externalId"] = "id",
|
|
105
|
+
unpack_metadata: bool = False,
|
|
106
|
+
skip_sequence_rows: bool = False,
|
|
107
107
|
):
|
|
108
108
|
self._client = client
|
|
109
109
|
if sum([bool(data_set_external_id), bool(root_asset_external_id)]) != 1:
|
|
@@ -113,7 +113,7 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
113
113
|
self._namespace = namespace or CLASSIC_CDF_NAMESPACE
|
|
114
114
|
self._extractor_args = dict(
|
|
115
115
|
namespace=self._namespace,
|
|
116
|
-
unpack_metadata=
|
|
116
|
+
unpack_metadata=unpack_metadata,
|
|
117
117
|
as_write=True,
|
|
118
118
|
camel_case=True,
|
|
119
119
|
limit=limit_per_type,
|
|
@@ -123,6 +123,7 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
123
123
|
self._identifier = identifier
|
|
124
124
|
self._prefix = prefix
|
|
125
125
|
self._limit_per_type = limit_per_type
|
|
126
|
+
self._skip_sequence_rows = skip_sequence_rows
|
|
126
127
|
|
|
127
128
|
self._uris_by_external_id_by_type: dict[InstanceIdPrefix, dict[str, URIRef]] = defaultdict(dict)
|
|
128
129
|
self._source_external_ids_by_type: dict[InstanceIdPrefix, set[str]] = defaultdict(set)
|
|
@@ -135,6 +136,29 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
135
136
|
self._extracted_data_sets = False
|
|
136
137
|
self._asset_external_ids_by_id: dict[int, str] = {}
|
|
137
138
|
self._dataset_external_ids_by_id: dict[int, str] = {}
|
|
139
|
+
self.neat_prefix_by_predicate_uri: dict[URIRef, str] = {
|
|
140
|
+
self._namespace["dataSetId"]: InstanceIdPrefix.data_set,
|
|
141
|
+
self._namespace["assetId"]: InstanceIdPrefix.asset,
|
|
142
|
+
self._namespace["assetIds"]: InstanceIdPrefix.asset,
|
|
143
|
+
self._namespace["parentId"]: InstanceIdPrefix.asset,
|
|
144
|
+
self._namespace["rootId"]: InstanceIdPrefix.asset,
|
|
145
|
+
self._namespace["labels"]: InstanceIdPrefix.label,
|
|
146
|
+
}
|
|
147
|
+
self.neat_prefix_by_type_uri: dict[URIRef, str] = {}
|
|
148
|
+
for extractor_cls, type_prefix in [
|
|
149
|
+
(AssetsExtractor, InstanceIdPrefix.asset),
|
|
150
|
+
(TimeSeriesExtractor, InstanceIdPrefix.time_series),
|
|
151
|
+
(SequencesExtractor, InstanceIdPrefix.sequence),
|
|
152
|
+
(EventsExtractor, InstanceIdPrefix.event),
|
|
153
|
+
(FilesExtractor, InstanceIdPrefix.file),
|
|
154
|
+
(RelationshipsExtractor, InstanceIdPrefix.relationship),
|
|
155
|
+
(LabelsExtractor, InstanceIdPrefix.label),
|
|
156
|
+
(DataSetExtractor, InstanceIdPrefix.data_set),
|
|
157
|
+
]:
|
|
158
|
+
rdf_type = extractor_cls._default_rdf_type # type: ignore[attr-defined]
|
|
159
|
+
if prefix:
|
|
160
|
+
rdf_type = f"{prefix}{rdf_type}"
|
|
161
|
+
self.neat_prefix_by_type_uri[self._namespace[rdf_type]] = type_prefix
|
|
138
162
|
|
|
139
163
|
def _get_activity_names(self) -> list[str]:
|
|
140
164
|
activities = [data_access_object.extractor_cls.__name__ for data_access_object in self._classic_node_types] + [
|
|
@@ -194,13 +218,14 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
194
218
|
for prop in verified.properties:
|
|
195
219
|
prop_id = prop.property_
|
|
196
220
|
if is_snake_case:
|
|
197
|
-
prop_id =
|
|
198
|
-
prop.instance_source =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
)
|
|
203
|
-
|
|
221
|
+
prop_id = to_snake_case(prop_id)
|
|
222
|
+
prop.instance_source = [self._namespace[prop_id]]
|
|
223
|
+
for cls_ in verified.classes:
|
|
224
|
+
cls_id = cls_.class_.suffix
|
|
225
|
+
if is_snake_case:
|
|
226
|
+
cls_id = to_snake_case(cls_id)
|
|
227
|
+
cls_.instance_source = self._namespace[cls_id]
|
|
228
|
+
|
|
204
229
|
return verified
|
|
205
230
|
|
|
206
231
|
@property
|
|
@@ -238,14 +263,14 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
238
263
|
|
|
239
264
|
def _extract_core_start_nodes(self):
|
|
240
265
|
for core_node in self._classic_node_types:
|
|
266
|
+
kwargs = self._extractor_args.copy()
|
|
267
|
+
if core_node.extractor_cls == SequencesExtractor and self._skip_sequence_rows:
|
|
268
|
+
kwargs["skip_rows"] = True
|
|
269
|
+
|
|
241
270
|
if self._data_set_external_id:
|
|
242
|
-
extractor = core_node.extractor_cls.from_dataset(
|
|
243
|
-
self._client, self._data_set_external_id, **self._extractor_args
|
|
244
|
-
)
|
|
271
|
+
extractor = core_node.extractor_cls.from_dataset(self._client, self._data_set_external_id, **kwargs)
|
|
245
272
|
elif self._root_asset_external_id:
|
|
246
|
-
extractor = core_node.extractor_cls.from_hierarchy(
|
|
247
|
-
self._client, self._root_asset_external_id, **self._extractor_args
|
|
248
|
-
)
|
|
273
|
+
extractor = core_node.extractor_cls.from_hierarchy(self._client, self._root_asset_external_id, **kwargs)
|
|
249
274
|
else:
|
|
250
275
|
raise ValueError("Exactly one of data_set_external_id or root_asset_external_id must be set.")
|
|
251
276
|
|
|
@@ -274,7 +299,9 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
274
299
|
# This is a private attribute, but we need to set it to log the target nodes.
|
|
275
300
|
extractor._log_target_nodes = True
|
|
276
301
|
if self._identifier == "id":
|
|
277
|
-
extractor.
|
|
302
|
+
extractor._uri_by_external_id_by_type = self._uris_by_external_id_by_type
|
|
303
|
+
elif self._identifier == "externalId":
|
|
304
|
+
extractor.lookup_dataset_external_id = self._lookup_dataset
|
|
278
305
|
|
|
279
306
|
yield from extractor.extract()
|
|
280
307
|
|
|
@@ -331,7 +358,9 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
331
358
|
def _extract_labels(self):
|
|
332
359
|
for chunk in self._chunk(list(self._labels), description="Extracting labels"):
|
|
333
360
|
label_iterator = self._client.labels.retrieve(external_id=list(chunk), ignore_unknown_ids=True)
|
|
334
|
-
|
|
361
|
+
extractor = LabelsExtractor(label_iterator, **self._extractor_args)
|
|
362
|
+
extractor.lookup_dataset_external_id = self._lookup_dataset
|
|
363
|
+
yield from extractor.extract()
|
|
335
364
|
|
|
336
365
|
def _extract_data_sets(self):
|
|
337
366
|
for chunk in self._chunk(list(self._data_set_ids), description="Extracting data sets"):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
import warnings
|
|
3
3
|
from collections import defaultdict
|
|
4
|
-
from collections.abc import
|
|
4
|
+
from collections.abc import Iterable, Set
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
@@ -26,7 +26,6 @@ class RelationshipsExtractor(ClassicCDFBaseExtractor[Relationship]):
|
|
|
26
26
|
self,
|
|
27
27
|
items: Iterable[Relationship],
|
|
28
28
|
namespace: Namespace | None = None,
|
|
29
|
-
to_type: Callable[[Relationship], str | None] | None = None,
|
|
30
29
|
total: int | None = None,
|
|
31
30
|
limit: int | None = None,
|
|
32
31
|
unpack_metadata: bool = True,
|
|
@@ -46,7 +45,6 @@ class RelationshipsExtractor(ClassicCDFBaseExtractor[Relationship]):
|
|
|
46
45
|
super().__init__(
|
|
47
46
|
to_iterate,
|
|
48
47
|
namespace=namespace,
|
|
49
|
-
to_type=to_type,
|
|
50
48
|
total=total,
|
|
51
49
|
limit=limit,
|
|
52
50
|
unpack_metadata=unpack_metadata,
|
|
@@ -56,7 +54,7 @@ class RelationshipsExtractor(ClassicCDFBaseExtractor[Relationship]):
|
|
|
56
54
|
prefix=prefix,
|
|
57
55
|
identifier=identifier,
|
|
58
56
|
)
|
|
59
|
-
self.
|
|
57
|
+
self._uri_by_external_id_by_type: dict[InstanceIdPrefix, dict[str, URIRef]] = defaultdict(dict)
|
|
60
58
|
self._target_triples: list[tuple[URIRef, URIRef, str, str]] = []
|
|
61
59
|
|
|
62
60
|
def _log_target_nodes_if_set(self, item: Relationship) -> Relationship:
|
|
@@ -67,25 +65,33 @@ class RelationshipsExtractor(ClassicCDFBaseExtractor[Relationship]):
|
|
|
67
65
|
return item
|
|
68
66
|
|
|
69
67
|
def _item2triples_special_cases(self, id_: URIRef, dumped: dict[str, Any]) -> list[Triple]:
|
|
70
|
-
if self.identifier == "externalId":
|
|
71
|
-
return []
|
|
72
68
|
triples: list[Triple] = []
|
|
73
69
|
if (source_external_id := dumped.pop("sourceExternalId")) and "sourceType" in dumped:
|
|
74
70
|
source_type = dumped["sourceType"]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
source_prefix = InstanceIdPrefix.from_str(source_type)
|
|
72
|
+
if self.identifier == "id":
|
|
73
|
+
try:
|
|
74
|
+
source_uri = self._uri_by_external_id_by_type[source_prefix][source_external_id]
|
|
75
|
+
except KeyError:
|
|
76
|
+
warnings.warn(
|
|
77
|
+
NeatValueWarning(f"Missing externalId {source_external_id} for {source_type}"), stacklevel=2
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
triples.append((id_, self.namespace["sourceExternalId"], source_uri))
|
|
81
|
+
elif self.identifier == "externalId":
|
|
82
|
+
triples.append(
|
|
83
|
+
(id_, self.namespace["sourceExternalId"], self.namespace[f"{source_prefix}{source_external_id}"])
|
|
82
84
|
)
|
|
83
|
-
else:
|
|
84
|
-
triples.append((id_, self.namespace["sourceExternalId"], source_uri))
|
|
85
85
|
if (target_external_id := dumped.pop("targetExternalId")) and "targetType" in dumped:
|
|
86
86
|
target_type = dumped["targetType"]
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if self.identifier == "id":
|
|
88
|
+
# We do not yet have the target nodes, so we log them for later extraction.
|
|
89
|
+
self._target_triples.append((id_, self.namespace["targetExternalId"], target_type, target_external_id))
|
|
90
|
+
elif self.identifier == "externalId":
|
|
91
|
+
target_prefix = InstanceIdPrefix.from_str(target_type)
|
|
92
|
+
triples.append(
|
|
93
|
+
(id_, self.namespace["targetExternalId"], self.namespace[f"{target_prefix}{target_external_id}"])
|
|
94
|
+
)
|
|
89
95
|
return triples
|
|
90
96
|
|
|
91
97
|
@classmethod
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
import json
|
|
3
3
|
import typing
|
|
4
|
-
from collections.abc import
|
|
4
|
+
from collections.abc import Iterable, Set
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
@@ -21,8 +21,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
21
21
|
Args:
|
|
22
22
|
items (Iterable[T_CogniteResource]): An iterable of classic resource.
|
|
23
23
|
namespace (Namespace, optional): The namespace to use. Defaults to DEFAULT_NAMESPACE.
|
|
24
|
-
to_type (Callable[[T_CogniteResource], str | None], optional): A function to convert an item to a type.
|
|
25
|
-
Defaults to None. If None or if the function returns None, the asset will be set to the default type.
|
|
26
24
|
total (int, optional): The total number of items to load. If passed, you will get a progress bar if rich
|
|
27
25
|
is installed. Defaults to None.
|
|
28
26
|
limit (int, optional): The maximal number of items to load. Defaults to None. This is typically used for
|
|
@@ -46,7 +44,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
46
44
|
self,
|
|
47
45
|
items: Iterable[NeatSequence],
|
|
48
46
|
namespace: Namespace | None = None,
|
|
49
|
-
to_type: Callable[[NeatSequence], str | None] | None = None,
|
|
50
47
|
total: int | None = None,
|
|
51
48
|
limit: int | None = None,
|
|
52
49
|
unpack_metadata: bool = True,
|
|
@@ -60,7 +57,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
60
57
|
super().__init__(
|
|
61
58
|
items,
|
|
62
59
|
namespace,
|
|
63
|
-
to_type,
|
|
64
60
|
total,
|
|
65
61
|
limit,
|
|
66
62
|
unpack_metadata,
|
|
@@ -78,7 +74,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
78
74
|
client: CogniteClient,
|
|
79
75
|
data_set_external_id: str,
|
|
80
76
|
namespace: Namespace | None = None,
|
|
81
|
-
to_type: Callable[[NeatSequence], str | None] | None = None,
|
|
82
77
|
limit: int | None = None,
|
|
83
78
|
unpack_metadata: bool = True,
|
|
84
79
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -87,12 +82,12 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
87
82
|
prefix: str | None = None,
|
|
88
83
|
identifier: typing.Literal["id", "externalId"] = "id",
|
|
89
84
|
unpack_columns: bool = False,
|
|
85
|
+
skip_rows: bool = False,
|
|
90
86
|
):
|
|
91
|
-
total, items = cls._handle_no_access(lambda: cls._from_dataset(client, data_set_external_id))
|
|
87
|
+
total, items = cls._handle_no_access(lambda: cls._from_dataset(client, data_set_external_id, skip_rows))
|
|
92
88
|
return cls(
|
|
93
89
|
items,
|
|
94
90
|
namespace,
|
|
95
|
-
to_type,
|
|
96
91
|
total,
|
|
97
92
|
limit,
|
|
98
93
|
unpack_metadata,
|
|
@@ -110,7 +105,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
110
105
|
client: CogniteClient,
|
|
111
106
|
root_asset_external_id: str,
|
|
112
107
|
namespace: Namespace | None = None,
|
|
113
|
-
to_type: Callable[[NeatSequence], str | None] | None = None,
|
|
114
108
|
limit: int | None = None,
|
|
115
109
|
unpack_metadata: bool = True,
|
|
116
110
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -119,12 +113,12 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
119
113
|
prefix: str | None = None,
|
|
120
114
|
identifier: typing.Literal["id", "externalId"] = "id",
|
|
121
115
|
unpack_columns: bool = False,
|
|
116
|
+
skip_rows: bool = False,
|
|
122
117
|
):
|
|
123
|
-
total, items = cls._handle_no_access(lambda: cls._from_hierarchy(client, root_asset_external_id))
|
|
118
|
+
total, items = cls._handle_no_access(lambda: cls._from_hierarchy(client, root_asset_external_id, skip_rows))
|
|
124
119
|
return cls(
|
|
125
120
|
items,
|
|
126
121
|
namespace,
|
|
127
|
-
to_type,
|
|
128
122
|
total,
|
|
129
123
|
limit,
|
|
130
124
|
unpack_metadata,
|
|
@@ -141,7 +135,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
141
135
|
cls,
|
|
142
136
|
file_path: str | Path,
|
|
143
137
|
namespace: Namespace | None = None,
|
|
144
|
-
to_type: Callable[[NeatSequence], str | None] | None = None,
|
|
145
138
|
limit: int | None = None,
|
|
146
139
|
unpack_metadata: bool = True,
|
|
147
140
|
skip_metadata_values: Set[str] | None = DEFAULT_SKIP_METADATA_VALUES,
|
|
@@ -155,7 +148,6 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
155
148
|
return cls(
|
|
156
149
|
items,
|
|
157
150
|
namespace,
|
|
158
|
-
to_type,
|
|
159
151
|
total,
|
|
160
152
|
limit,
|
|
161
153
|
unpack_metadata,
|
|
@@ -169,23 +161,29 @@ class SequencesExtractor(ClassicCDFBaseExtractor[NeatSequence]):
|
|
|
169
161
|
|
|
170
162
|
@classmethod
|
|
171
163
|
def _from_dataset(
|
|
172
|
-
cls, client: CogniteClient, data_set_external_id: str
|
|
164
|
+
cls, client: CogniteClient, data_set_external_id: str, skip_rows: bool = False
|
|
173
165
|
) -> tuple[int | None, Iterable[NeatSequence]]:
|
|
174
166
|
total = client.sequences.aggregate_count(
|
|
175
167
|
filter=SequenceFilter(data_set_ids=[{"externalId": data_set_external_id}])
|
|
176
168
|
)
|
|
177
169
|
items = client.sequences(data_set_external_ids=data_set_external_id)
|
|
178
|
-
|
|
170
|
+
if skip_rows:
|
|
171
|
+
return total, (NeatSequence.from_cognite_sequence(seq) for seq in items)
|
|
172
|
+
else:
|
|
173
|
+
return total, cls._lookup_rows(items, client)
|
|
179
174
|
|
|
180
175
|
@classmethod
|
|
181
176
|
def _from_hierarchy(
|
|
182
|
-
cls, client: CogniteClient, root_asset_external_id: str
|
|
177
|
+
cls, client: CogniteClient, root_asset_external_id: str, skip_rows: bool = False
|
|
183
178
|
) -> tuple[int | None, Iterable[NeatSequence]]:
|
|
184
179
|
total = client.sequences.aggregate_count(
|
|
185
180
|
filter=SequenceFilter(asset_subtree_ids=[{"externalId": root_asset_external_id}])
|
|
186
181
|
)
|
|
187
182
|
items = client.sequences(asset_subtree_external_ids=[root_asset_external_id])
|
|
188
|
-
|
|
183
|
+
if skip_rows:
|
|
184
|
+
return total, (NeatSequence.from_cognite_sequence(seq) for seq in items)
|
|
185
|
+
else:
|
|
186
|
+
return total, cls._lookup_rows(items, client)
|
|
189
187
|
|
|
190
188
|
@classmethod
|
|
191
189
|
def _from_file(cls, file_path: str | Path) -> tuple[int | None, Iterable[NeatSequence]]:
|