cognite-neat 0.85.7__tar.gz → 0.85.9__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.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/PKG-INFO +1 -1
- cognite_neat-0.85.9/cognite/neat/_version.py +1 -0
- cognite_neat-0.85.9/cognite/neat/graph/extractors/_classic_cdf/_assets.py +223 -0
- cognite_neat-0.85.9/cognite/neat/graph/extractors/_classic_cdf/_events.py +153 -0
- cognite_neat-0.85.9/cognite/neat/graph/extractors/_classic_cdf/_files.py +181 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_classic_cdf/_labels.py +20 -11
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_classic_cdf/_relationships.py +35 -20
- cognite_neat-0.85.9/cognite/neat/graph/extractors/_classic_cdf/_sequences.py +140 -0
- cognite_neat-0.85.9/cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +176 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_inference2rules.py +89 -23
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/data_types.py +1 -1
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/pyproject.toml +1 -1
- cognite_neat-0.85.7/cognite/neat/_version.py +0 -1
- cognite_neat-0.85.7/cognite/neat/graph/extractors/_classic_cdf/_assets.py +0 -131
- cognite_neat-0.85.7/cognite/neat/graph/extractors/_classic_cdf/_events.py +0 -123
- cognite_neat-0.85.7/cognite/neat/graph/extractors/_classic_cdf/_files.py +0 -137
- cognite_neat-0.85.7/cognite/neat/graph/extractors/_classic_cdf/_sequences.py +0 -102
- cognite_neat-0.85.7/cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +0 -128
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/LICENSE +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/README.md +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/configuration.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/explorer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/configuration.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/core.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/crud.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/data_exploration.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/metrics.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/routers/workflows.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/utils/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/utils/logging.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/main.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/monitoring/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/monitoring/metrics.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/index.html +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.LICENSE.txt +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.map +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/config.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/constants.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/_shared.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/_tracking/base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/_tracking/log.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/examples/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/issues/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/issues/loader.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/loaders/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/loaders/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/loaders/_rdf2asset.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/loaders/_rdf2dms.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/models.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/queries/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/queries/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/queries/_construct.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/queries/_shared.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/stores/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/stores/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/stores/_provenance.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/transformers/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/transformers/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/transformers/_classic_cdf.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/issues.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/examples/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/extractors/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/extractors/_graph_capturing_sheet.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/_asset_loader.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/_exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/core/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/core/labels.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/core/models.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/rdf_to_dms.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/loaders/validator.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/models.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_graphdb_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_memory_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_oxigraph_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/stores/_rdf_to_graph.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/transformations/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/transformations/entity_matcher.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/transformations/query_generator/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/transformations/query_generator/sparql.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/graph/transformations/transformer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/analysis.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/Rules-Nordic44.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/power-grid-containers.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/power-grid-example.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/power-grid-model.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/rules-template.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/skos-rules.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_core/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_core/rules2labels.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2graphql.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_rules2triples.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_dict2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_graph2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_json2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_xsd2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/raw_rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/rdfpath.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/tables.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/rules/models/value_types.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/py.typed +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/_shared.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/analysis/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/analysis/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/analysis/_information_rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/examples/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/dms.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/fileread.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/formatters.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/importing.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/spreadsheet.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/issues/spreadsheet_file.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_constants.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_types/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_types/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/_types/_field.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/_converter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/_rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/_rules_input.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/_serializer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/asset/_validation.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_converter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_exporter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_rules_input.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_schema.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_serializer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/dms/_validation.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/domain.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/entities.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/_converter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/_rules.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/_rules_input.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/_serializer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/information/_validation.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/rules/models/wrapped_entities.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/auth.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/auxiliary.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_classes.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_loaders/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_loaders/_base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_loaders/_data_modeling.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_loaders/_ingestion.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/cdf_loaders/data_classes.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/spreadsheet.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/text.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/upload.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/utils.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/utils/xml_.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/_exceptions.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/base.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/cdf_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/manager.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/migration/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/migration/steps.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/migration/wf_manifests.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/model.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/rules_exporter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/rules_importer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/current/rules_validator.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/__init__.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/graph_contextualization.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/graph_extractor.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/graph_loader.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/graph_store.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/graph_transformer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/rules_exporter.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/lib/legacy/rules_importer.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps/step_model.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/steps_registry.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/tasks.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/triggers.py +0 -0
- {cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/workflows/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.85.9"
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
from collections.abc import Callable, Iterable
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import cast
|
|
7
|
+
|
|
8
|
+
from cognite.client import CogniteClient
|
|
9
|
+
from cognite.client.data_classes import Asset, AssetFilter, AssetList
|
|
10
|
+
from rdflib import RDF, Literal, Namespace
|
|
11
|
+
|
|
12
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
13
|
+
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
14
|
+
from cognite.neat.graph.models import Triple
|
|
15
|
+
from cognite.neat.utils.utils import create_sha256_hash, string_to_ideal_type
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AssetsExtractor(BaseExtractor):
|
|
19
|
+
"""Extract data from Cognite Data Fusions Assets into Neat.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
assets (Iterable[Asset]): An iterable of assets.
|
|
23
|
+
namespace (Namespace, optional): The namespace to use. Defaults to DEFAULT_NAMESPACE.
|
|
24
|
+
to_type (Callable[[Asset], str | None], optional): A function to convert an asset to a type. Defaults to None.
|
|
25
|
+
If None or if the function returns None, the asset will be set to the default type "Asset".
|
|
26
|
+
total (int, optional): The total number of assets to load. If passed, you will get a progress bar if rich
|
|
27
|
+
is installed. Defaults to None.
|
|
28
|
+
limit (int, optional): The maximal number of assets to load. Defaults to None. This is typically used for
|
|
29
|
+
testing setup of the extractor. For example, if you are extracting 100 000 assets, you might want to
|
|
30
|
+
limit the extraction to 1000 assets to test the setup.
|
|
31
|
+
unpack_metadata (bool, optional): Whether to unpack metadata. Defaults to False, which yields the metadata as
|
|
32
|
+
a JSON string.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
_SPACE_PATTERN = re.compile(r"\s+")
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
assets: Iterable[Asset],
|
|
40
|
+
namespace: Namespace | None = None,
|
|
41
|
+
to_type: Callable[[Asset], str | None] | None = None,
|
|
42
|
+
total: int | None = None,
|
|
43
|
+
limit: int | None = None,
|
|
44
|
+
unpack_metadata: bool = True,
|
|
45
|
+
):
|
|
46
|
+
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
47
|
+
self.assets = assets
|
|
48
|
+
self.to_type = to_type
|
|
49
|
+
self.total = total
|
|
50
|
+
self.limit = min(limit, total) if limit and total else limit
|
|
51
|
+
self.unpack_metadata = unpack_metadata
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def from_dataset(
|
|
55
|
+
cls,
|
|
56
|
+
client: CogniteClient,
|
|
57
|
+
data_set_external_id: str,
|
|
58
|
+
namespace: Namespace | None = None,
|
|
59
|
+
to_type: Callable[[Asset], str | None] | None = None,
|
|
60
|
+
limit: int | None = None,
|
|
61
|
+
unpack_metadata: bool = True,
|
|
62
|
+
):
|
|
63
|
+
total = client.assets.aggregate_count(filter=AssetFilter(data_set_ids=[{"externalId": data_set_external_id}]))
|
|
64
|
+
|
|
65
|
+
return cls(
|
|
66
|
+
cast(
|
|
67
|
+
Iterable[Asset],
|
|
68
|
+
client.assets(data_set_external_ids=data_set_external_id),
|
|
69
|
+
),
|
|
70
|
+
namespace,
|
|
71
|
+
to_type,
|
|
72
|
+
total,
|
|
73
|
+
limit,
|
|
74
|
+
unpack_metadata=unpack_metadata,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_hierarchy(
|
|
79
|
+
cls,
|
|
80
|
+
client: CogniteClient,
|
|
81
|
+
root_asset_external_id: str,
|
|
82
|
+
namespace: Namespace | None = None,
|
|
83
|
+
to_type: Callable[[Asset], str | None] | None = None,
|
|
84
|
+
limit: int | None = None,
|
|
85
|
+
unpack_metadata: bool = True,
|
|
86
|
+
):
|
|
87
|
+
total = client.assets.aggregate_count(
|
|
88
|
+
filter=AssetFilter(asset_subtree_ids=[{"externalId": root_asset_external_id}])
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return cls(
|
|
92
|
+
cast(
|
|
93
|
+
Iterable[Asset],
|
|
94
|
+
client.assets(asset_subtree_external_ids=root_asset_external_id),
|
|
95
|
+
),
|
|
96
|
+
namespace,
|
|
97
|
+
to_type,
|
|
98
|
+
total,
|
|
99
|
+
limit,
|
|
100
|
+
unpack_metadata=unpack_metadata,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def from_file(
|
|
105
|
+
cls,
|
|
106
|
+
file_path: str,
|
|
107
|
+
namespace: Namespace | None = None,
|
|
108
|
+
to_type: Callable[[Asset], str] | None = None,
|
|
109
|
+
limit: int | None = None,
|
|
110
|
+
unpack_metadata: bool = True,
|
|
111
|
+
):
|
|
112
|
+
return cls(
|
|
113
|
+
AssetList.load(Path(file_path).read_text()),
|
|
114
|
+
namespace,
|
|
115
|
+
to_type,
|
|
116
|
+
limit,
|
|
117
|
+
unpack_metadata=unpack_metadata,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def extract(self) -> Iterable[Triple]:
|
|
121
|
+
"""Extracts an asset with the given asset_id."""
|
|
122
|
+
if self.total:
|
|
123
|
+
try:
|
|
124
|
+
from rich.progress import track
|
|
125
|
+
except ModuleNotFoundError:
|
|
126
|
+
to_iterate = self.assets
|
|
127
|
+
else:
|
|
128
|
+
to_iterate = track(
|
|
129
|
+
self.assets,
|
|
130
|
+
total=self.limit or self.total,
|
|
131
|
+
description="Extracting Assets",
|
|
132
|
+
)
|
|
133
|
+
else:
|
|
134
|
+
to_iterate = self.assets
|
|
135
|
+
for no, asset in enumerate(to_iterate):
|
|
136
|
+
yield from self._asset2triples(asset)
|
|
137
|
+
if self.limit and no >= self.limit:
|
|
138
|
+
break
|
|
139
|
+
|
|
140
|
+
def _asset2triples(self, asset: Asset) -> list[Triple]:
|
|
141
|
+
"""Converts an asset to triples."""
|
|
142
|
+
id_ = self.namespace[f"Asset_{asset.id}"]
|
|
143
|
+
|
|
144
|
+
# Set rdf type
|
|
145
|
+
type_ = "Asset"
|
|
146
|
+
if self.to_type:
|
|
147
|
+
type_ = self.to_type(asset) or type_
|
|
148
|
+
type_ = self._SPACE_PATTERN.sub("_", type_)
|
|
149
|
+
|
|
150
|
+
triples: list[Triple] = [(id_, RDF.type, self.namespace[type_])]
|
|
151
|
+
|
|
152
|
+
# Create attributes
|
|
153
|
+
if asset.name:
|
|
154
|
+
triples.append((id_, self.namespace.name, Literal(asset.name)))
|
|
155
|
+
|
|
156
|
+
if asset.description:
|
|
157
|
+
triples.append((id_, self.namespace.description, Literal(asset.description)))
|
|
158
|
+
|
|
159
|
+
if asset.external_id:
|
|
160
|
+
triples.append((id_, self.namespace.external_id, Literal(asset.external_id)))
|
|
161
|
+
|
|
162
|
+
if asset.source:
|
|
163
|
+
triples.append((id_, self.namespace.source, Literal(asset.source)))
|
|
164
|
+
|
|
165
|
+
# properties ref creation and update
|
|
166
|
+
triples.append(
|
|
167
|
+
(
|
|
168
|
+
id_,
|
|
169
|
+
self.namespace.created_time,
|
|
170
|
+
Literal(datetime.fromtimestamp(asset.created_time / 1000, timezone.utc)),
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
triples.append(
|
|
174
|
+
(
|
|
175
|
+
id_,
|
|
176
|
+
self.namespace.last_updated_time,
|
|
177
|
+
Literal(datetime.fromtimestamp(asset.last_updated_time / 1000, timezone.utc)),
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
if asset.labels:
|
|
182
|
+
for label in asset.labels:
|
|
183
|
+
# external_id can create ill-formed URIs, so we create websafe URIs
|
|
184
|
+
# since labels do not have internal ids, we use the external_id as the id
|
|
185
|
+
triples.append(
|
|
186
|
+
(
|
|
187
|
+
id_,
|
|
188
|
+
self.namespace.label,
|
|
189
|
+
self.namespace[f"Label_{create_sha256_hash(label.dump()['externalId'])}"],
|
|
190
|
+
)
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
if asset.metadata:
|
|
194
|
+
if self.unpack_metadata:
|
|
195
|
+
for key, value in asset.metadata.items():
|
|
196
|
+
if value:
|
|
197
|
+
triples.append(
|
|
198
|
+
(
|
|
199
|
+
id_,
|
|
200
|
+
self.namespace[key],
|
|
201
|
+
Literal(string_to_ideal_type(value)),
|
|
202
|
+
)
|
|
203
|
+
)
|
|
204
|
+
else:
|
|
205
|
+
triples.append((id_, self.namespace.metadata, Literal(json.dumps(asset.metadata))))
|
|
206
|
+
|
|
207
|
+
# Create connections:
|
|
208
|
+
if asset.parent_id:
|
|
209
|
+
triples.append((id_, self.namespace.parent, self.namespace[f"Asset_{asset.parent_id}"]))
|
|
210
|
+
|
|
211
|
+
if asset.root_id:
|
|
212
|
+
triples.append((id_, self.namespace.root, self.namespace[f"Asset_{asset.root_id}"]))
|
|
213
|
+
|
|
214
|
+
if asset.data_set_id:
|
|
215
|
+
triples.append(
|
|
216
|
+
(
|
|
217
|
+
id_,
|
|
218
|
+
self.namespace.dataset,
|
|
219
|
+
self.namespace[f"Dataset_{asset.data_set_id}"],
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
return triples
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from collections.abc import Iterable
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import cast
|
|
6
|
+
|
|
7
|
+
from cognite.client import CogniteClient
|
|
8
|
+
from cognite.client.data_classes import Event, EventList
|
|
9
|
+
from pydantic import AnyHttpUrl, ValidationError
|
|
10
|
+
from rdflib import RDF, Literal, Namespace, URIRef
|
|
11
|
+
|
|
12
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
13
|
+
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
14
|
+
from cognite.neat.graph.models import Triple
|
|
15
|
+
from cognite.neat.utils.utils import string_to_ideal_type
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class EventsExtractor(BaseExtractor):
|
|
19
|
+
"""Extract data from Cognite Data Fusions Events into Neat.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
events (Iterable[Event]): An iterable of events.
|
|
23
|
+
namespace (Namespace, optional): The namespace to use. Defaults to DEFAULT_NAMESPACE.
|
|
24
|
+
unpack_metadata (bool, optional): Whether to unpack metadata. Defaults to False, which yields the metadata as
|
|
25
|
+
a JSON string.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
events: Iterable[Event],
|
|
31
|
+
namespace: Namespace | None = None,
|
|
32
|
+
unpack_metadata: bool = True,
|
|
33
|
+
):
|
|
34
|
+
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
35
|
+
self.events = events
|
|
36
|
+
self.unpack_metadata = unpack_metadata
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def from_dataset(
|
|
40
|
+
cls,
|
|
41
|
+
client: CogniteClient,
|
|
42
|
+
data_set_external_id: str,
|
|
43
|
+
namespace: Namespace | None = None,
|
|
44
|
+
unpack_metadata: bool = True,
|
|
45
|
+
):
|
|
46
|
+
return cls(
|
|
47
|
+
cast(
|
|
48
|
+
Iterable[Event],
|
|
49
|
+
client.events(data_set_external_ids=data_set_external_id),
|
|
50
|
+
),
|
|
51
|
+
namespace,
|
|
52
|
+
unpack_metadata,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_file(
|
|
57
|
+
cls,
|
|
58
|
+
file_path: str,
|
|
59
|
+
namespace: Namespace | None = None,
|
|
60
|
+
unpack_metadata: bool = True,
|
|
61
|
+
):
|
|
62
|
+
return cls(EventList.load(Path(file_path).read_text()), namespace, unpack_metadata)
|
|
63
|
+
|
|
64
|
+
def extract(self) -> Iterable[Triple]:
|
|
65
|
+
"""Extract events as triples."""
|
|
66
|
+
for event in self.events:
|
|
67
|
+
yield from self._event2triples(event)
|
|
68
|
+
|
|
69
|
+
def _event2triples(self, event: Event) -> list[Triple]:
|
|
70
|
+
id_ = self.namespace[f"Event_{event.id}"]
|
|
71
|
+
|
|
72
|
+
# Set rdf type
|
|
73
|
+
triples: list[Triple] = [(id_, RDF.type, self.namespace.Event)]
|
|
74
|
+
|
|
75
|
+
# Create attributes
|
|
76
|
+
|
|
77
|
+
if event.external_id:
|
|
78
|
+
triples.append((id_, self.namespace.external_id, Literal(event.external_id)))
|
|
79
|
+
|
|
80
|
+
if event.source:
|
|
81
|
+
triples.append((id_, self.namespace.type, Literal(event.source)))
|
|
82
|
+
|
|
83
|
+
if event.type:
|
|
84
|
+
triples.append((id_, self.namespace.type, Literal(event.type)))
|
|
85
|
+
|
|
86
|
+
if event.subtype:
|
|
87
|
+
triples.append((id_, self.namespace.subtype, Literal(event.subtype)))
|
|
88
|
+
|
|
89
|
+
if event.metadata:
|
|
90
|
+
if self.unpack_metadata:
|
|
91
|
+
for key, value in event.metadata.items():
|
|
92
|
+
if value:
|
|
93
|
+
type_aware_value = string_to_ideal_type(value)
|
|
94
|
+
try:
|
|
95
|
+
triples.append((id_, self.namespace[key], URIRef(str(AnyHttpUrl(type_aware_value))))) # type: ignore
|
|
96
|
+
except ValidationError:
|
|
97
|
+
triples.append((id_, self.namespace[key], Literal(type_aware_value)))
|
|
98
|
+
else:
|
|
99
|
+
triples.append((id_, self.namespace.metadata, Literal(json.dumps(event.metadata))))
|
|
100
|
+
|
|
101
|
+
if event.description:
|
|
102
|
+
triples.append((id_, self.namespace.description, Literal(event.description)))
|
|
103
|
+
|
|
104
|
+
if event.created_time:
|
|
105
|
+
triples.append(
|
|
106
|
+
(
|
|
107
|
+
id_,
|
|
108
|
+
self.namespace.created_time,
|
|
109
|
+
Literal(datetime.fromtimestamp(event.created_time / 1000, timezone.utc)),
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if event.last_updated_time:
|
|
114
|
+
triples.append(
|
|
115
|
+
(
|
|
116
|
+
id_,
|
|
117
|
+
self.namespace.last_updated_time,
|
|
118
|
+
Literal(datetime.fromtimestamp(event.last_updated_time / 1000, timezone.utc)),
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
if event.start_time:
|
|
123
|
+
triples.append(
|
|
124
|
+
(
|
|
125
|
+
id_,
|
|
126
|
+
self.namespace.start_time,
|
|
127
|
+
Literal(datetime.fromtimestamp(event.start_time / 1000, timezone.utc)),
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
if event.end_time:
|
|
132
|
+
triples.append(
|
|
133
|
+
(
|
|
134
|
+
id_,
|
|
135
|
+
self.namespace.end_time,
|
|
136
|
+
Literal(datetime.fromtimestamp(event.end_time / 1000, timezone.utc)),
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
if event.data_set_id:
|
|
141
|
+
triples.append(
|
|
142
|
+
(
|
|
143
|
+
id_,
|
|
144
|
+
self.namespace.data_set_id,
|
|
145
|
+
self.namespace[f"Dataset_{event.data_set_id}"],
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
if event.asset_ids:
|
|
150
|
+
for asset_id in event.asset_ids:
|
|
151
|
+
triples.append((id_, self.namespace.asset, self.namespace[f"Asset_{asset_id}"]))
|
|
152
|
+
|
|
153
|
+
return triples
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from collections.abc import Iterable
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import cast
|
|
6
|
+
from urllib.parse import quote
|
|
7
|
+
|
|
8
|
+
from cognite.client import CogniteClient
|
|
9
|
+
from cognite.client.data_classes import FileMetadata, FileMetadataList
|
|
10
|
+
from pydantic import AnyHttpUrl, ValidationError
|
|
11
|
+
from rdflib import RDF, Literal, Namespace, URIRef
|
|
12
|
+
|
|
13
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
14
|
+
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
15
|
+
from cognite.neat.graph.models import Triple
|
|
16
|
+
from cognite.neat.utils.utils import string_to_ideal_type
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FilesExtractor(BaseExtractor):
|
|
20
|
+
"""Extract data from Cognite Data Fusions files metadata into Neat.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
files_metadata (Iterable[FileMetadata]): An iterable of files metadata.
|
|
24
|
+
namespace (Namespace, optional): The namespace to use. Defaults to DEFAULT_NAMESPACE.
|
|
25
|
+
unpack_metadata (bool, optional): Whether to unpack metadata. Defaults to False, which yields the metadata as
|
|
26
|
+
a JSON string.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
files_metadata: Iterable[FileMetadata],
|
|
32
|
+
namespace: Namespace | None = None,
|
|
33
|
+
unpack_metadata: bool = True,
|
|
34
|
+
):
|
|
35
|
+
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
36
|
+
self.files_metadata = files_metadata
|
|
37
|
+
self.unpack_metadata = unpack_metadata
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def from_dataset(
|
|
41
|
+
cls,
|
|
42
|
+
client: CogniteClient,
|
|
43
|
+
data_set_external_id: str,
|
|
44
|
+
namespace: Namespace | None = None,
|
|
45
|
+
unpack_metadata: bool = True,
|
|
46
|
+
):
|
|
47
|
+
return cls(
|
|
48
|
+
cast(
|
|
49
|
+
Iterable[FileMetadata],
|
|
50
|
+
client.files(data_set_external_ids=data_set_external_id),
|
|
51
|
+
),
|
|
52
|
+
namespace,
|
|
53
|
+
unpack_metadata,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_file(
|
|
58
|
+
cls,
|
|
59
|
+
file_path: str,
|
|
60
|
+
namespace: Namespace | None = None,
|
|
61
|
+
unpack_metadata: bool = True,
|
|
62
|
+
):
|
|
63
|
+
return cls(
|
|
64
|
+
FileMetadataList.load(Path(file_path).read_text()),
|
|
65
|
+
namespace,
|
|
66
|
+
unpack_metadata,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def extract(self) -> Iterable[Triple]:
|
|
70
|
+
"""Extract files metadata as triples."""
|
|
71
|
+
for event in self.files_metadata:
|
|
72
|
+
yield from self._file2triples(event)
|
|
73
|
+
|
|
74
|
+
def _file2triples(self, file: FileMetadata) -> list[Triple]:
|
|
75
|
+
id_ = self.namespace[f"File_{file.id}"]
|
|
76
|
+
|
|
77
|
+
# Set rdf type
|
|
78
|
+
triples: list[Triple] = [(id_, RDF.type, self.namespace.File)]
|
|
79
|
+
|
|
80
|
+
# Create attributes
|
|
81
|
+
|
|
82
|
+
if file.external_id:
|
|
83
|
+
triples.append((id_, self.namespace.external_id, Literal(file.external_id)))
|
|
84
|
+
|
|
85
|
+
if file.source:
|
|
86
|
+
triples.append((id_, self.namespace.type, Literal(file.source)))
|
|
87
|
+
|
|
88
|
+
if file.mime_type:
|
|
89
|
+
triples.append((id_, self.namespace.mime_type, Literal(file.mime_type)))
|
|
90
|
+
|
|
91
|
+
if file.uploaded:
|
|
92
|
+
triples.append((id_, self.namespace.uploaded, Literal(file.uploaded)))
|
|
93
|
+
|
|
94
|
+
if file.source:
|
|
95
|
+
triples.append((id_, self.namespace.source, Literal(file.source)))
|
|
96
|
+
|
|
97
|
+
if file.metadata:
|
|
98
|
+
if self.unpack_metadata:
|
|
99
|
+
for key, value in file.metadata.items():
|
|
100
|
+
if value:
|
|
101
|
+
type_aware_value = string_to_ideal_type(value)
|
|
102
|
+
try:
|
|
103
|
+
triples.append((id_, self.namespace[key], URIRef(str(AnyHttpUrl(type_aware_value))))) # type: ignore
|
|
104
|
+
except ValidationError:
|
|
105
|
+
triples.append((id_, self.namespace[key], Literal(type_aware_value)))
|
|
106
|
+
else:
|
|
107
|
+
triples.append((id_, self.namespace.metadata, Literal(json.dumps(file.metadata))))
|
|
108
|
+
|
|
109
|
+
if file.source_created_time:
|
|
110
|
+
triples.append(
|
|
111
|
+
(
|
|
112
|
+
id_,
|
|
113
|
+
self.namespace.source_created_time,
|
|
114
|
+
Literal(datetime.fromtimestamp(file.source_created_time / 1000, timezone.utc)),
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
if file.source_modified_time:
|
|
118
|
+
triples.append(
|
|
119
|
+
(
|
|
120
|
+
id_,
|
|
121
|
+
self.namespace.source_created_time,
|
|
122
|
+
Literal(datetime.fromtimestamp(file.source_modified_time / 1000, timezone.utc)),
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
if file.uploaded_time:
|
|
126
|
+
triples.append(
|
|
127
|
+
(
|
|
128
|
+
id_,
|
|
129
|
+
self.namespace.uploaded_time,
|
|
130
|
+
Literal(datetime.fromtimestamp(file.uploaded_time / 1000, timezone.utc)),
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if file.created_time:
|
|
135
|
+
triples.append(
|
|
136
|
+
(
|
|
137
|
+
id_,
|
|
138
|
+
self.namespace.created_time,
|
|
139
|
+
Literal(datetime.fromtimestamp(file.created_time / 1000, timezone.utc)),
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
if file.last_updated_time:
|
|
144
|
+
triples.append(
|
|
145
|
+
(
|
|
146
|
+
id_,
|
|
147
|
+
self.namespace.last_updated_time,
|
|
148
|
+
Literal(datetime.fromtimestamp(file.last_updated_time / 1000, timezone.utc)),
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
if file.labels:
|
|
153
|
+
for label in file.labels:
|
|
154
|
+
# external_id can create ill-formed URIs, so we create websafe URIs
|
|
155
|
+
# since labels do not have internal ids, we use the external_id as the id
|
|
156
|
+
triples.append(
|
|
157
|
+
(
|
|
158
|
+
id_,
|
|
159
|
+
self.namespace.label,
|
|
160
|
+
self.namespace[f"Label_{quote(label.dump()['externalId'])}"],
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
if file.security_categories:
|
|
165
|
+
for category in file.security_categories:
|
|
166
|
+
triples.append((id_, self.namespace.security_categories, Literal(category)))
|
|
167
|
+
|
|
168
|
+
if file.data_set_id:
|
|
169
|
+
triples.append(
|
|
170
|
+
(
|
|
171
|
+
id_,
|
|
172
|
+
self.namespace.data_set_id,
|
|
173
|
+
self.namespace[f"Dataset_{file.data_set_id}"],
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
if file.asset_ids:
|
|
178
|
+
for asset_id in file.asset_ids:
|
|
179
|
+
triples.append((id_, self.namespace.asset, self.namespace[f"Asset_{asset_id}"]))
|
|
180
|
+
|
|
181
|
+
return triples
|
{cognite_neat-0.85.7 → cognite_neat-0.85.9}/cognite/neat/graph/extractors/_classic_cdf/_labels.py
RENAMED
|
@@ -37,7 +37,11 @@ class LabelsExtractor(BaseExtractor):
|
|
|
37
37
|
namespace: Namespace | None = None,
|
|
38
38
|
):
|
|
39
39
|
return cls(
|
|
40
|
-
cast(
|
|
40
|
+
cast(
|
|
41
|
+
Iterable[LabelDefinition],
|
|
42
|
+
client.labels(data_set_external_ids=data_set_external_id),
|
|
43
|
+
),
|
|
44
|
+
namespace,
|
|
41
45
|
)
|
|
42
46
|
|
|
43
47
|
@classmethod
|
|
@@ -47,36 +51,41 @@ class LabelsExtractor(BaseExtractor):
|
|
|
47
51
|
def extract(self) -> Iterable[Triple]:
|
|
48
52
|
"""Extract labels as triples."""
|
|
49
53
|
for label in self.labels:
|
|
50
|
-
yield from self._labels2triples(label
|
|
54
|
+
yield from self._labels2triples(label)
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
def _labels2triples(cls, label: LabelDefinition, namespace: Namespace) -> list[Triple]:
|
|
56
|
+
def _labels2triples(self, label: LabelDefinition) -> list[Triple]:
|
|
54
57
|
if label.external_id:
|
|
55
|
-
id_ = namespace[f"Label_{create_sha256_hash(label.external_id)}"]
|
|
58
|
+
id_ = self.namespace[f"Label_{create_sha256_hash(label.external_id)}"]
|
|
56
59
|
|
|
57
60
|
# Set rdf type
|
|
58
|
-
triples: list[Triple] = [(id_, RDF.type, namespace.Label)]
|
|
61
|
+
triples: list[Triple] = [(id_, RDF.type, self.namespace.Label)]
|
|
59
62
|
|
|
60
63
|
# Create attributes
|
|
61
|
-
triples.append((id_, namespace.external_id, Literal(label.external_id)))
|
|
64
|
+
triples.append((id_, self.namespace.external_id, Literal(label.external_id)))
|
|
62
65
|
|
|
63
66
|
if label.name:
|
|
64
|
-
triples.append((id_, namespace.name, Literal(label.name)))
|
|
67
|
+
triples.append((id_, self.namespace.name, Literal(label.name)))
|
|
65
68
|
|
|
66
69
|
if label.description:
|
|
67
|
-
triples.append((id_, namespace.description, Literal(label.description)))
|
|
70
|
+
triples.append((id_, self.namespace.description, Literal(label.description)))
|
|
68
71
|
|
|
69
72
|
if label.created_time:
|
|
70
73
|
triples.append(
|
|
71
74
|
(
|
|
72
75
|
id_,
|
|
73
|
-
namespace.created_time,
|
|
76
|
+
self.namespace.created_time,
|
|
74
77
|
Literal(datetime.fromtimestamp(label.created_time / 1000, timezone.utc)),
|
|
75
78
|
)
|
|
76
79
|
)
|
|
77
80
|
|
|
78
81
|
if label.data_set_id:
|
|
79
|
-
triples.append(
|
|
82
|
+
triples.append(
|
|
83
|
+
(
|
|
84
|
+
id_,
|
|
85
|
+
self.namespace.data_set_id,
|
|
86
|
+
self.namespace[f"Dataset_{label.data_set_id}"],
|
|
87
|
+
)
|
|
88
|
+
)
|
|
80
89
|
|
|
81
90
|
return triples
|
|
82
91
|
return []
|