cognite-neat 0.87.4__py3-none-any.whl → 0.88.0__py3-none-any.whl
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/_version.py +1 -1
- cognite/neat/app/api/data_classes/rest.py +0 -19
- cognite/neat/app/api/explorer.py +6 -4
- cognite/neat/app/api/routers/crud.py +11 -21
- cognite/neat/app/api/routers/workflows.py +24 -94
- cognite/neat/graph/extractors/_classic_cdf/_assets.py +8 -2
- cognite/neat/graph/extractors/_mock_graph_generator.py +2 -2
- cognite/neat/graph/loaders/_base.py +17 -12
- cognite/neat/graph/loaders/_rdf2asset.py +223 -58
- cognite/neat/graph/loaders/_rdf2dms.py +1 -1
- cognite/neat/graph/stores/_base.py +5 -0
- cognite/neat/rules/analysis/_asset.py +31 -1
- cognite/neat/rules/importers/_inference2rules.py +31 -35
- cognite/neat/rules/models/information/_rules.py +1 -1
- cognite/neat/workflows/steps/data_contracts.py +17 -43
- cognite/neat/workflows/steps/lib/current/graph_extractor.py +28 -24
- cognite/neat/workflows/steps/lib/current/graph_loader.py +4 -21
- cognite/neat/workflows/steps/lib/current/graph_store.py +18 -134
- cognite/neat/workflows/steps_registry.py +5 -7
- {cognite_neat-0.87.4.dist-info → cognite_neat-0.88.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.87.4.dist-info → cognite_neat-0.88.0.dist-info}/RECORD +24 -132
- cognite/neat/app/api/routers/core.py +0 -91
- cognite/neat/app/api/routers/data_exploration.py +0 -336
- cognite/neat/app/api/routers/rules.py +0 -203
- cognite/neat/legacy/__init__.py +0 -0
- cognite/neat/legacy/graph/__init__.py +0 -3
- cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -20182
- cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +0 -20163
- cognite/neat/legacy/graph/examples/__init__.py +0 -10
- cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- cognite/neat/legacy/graph/exceptions.py +0 -90
- cognite/neat/legacy/graph/extractors/__init__.py +0 -6
- cognite/neat/legacy/graph/extractors/_base.py +0 -14
- cognite/neat/legacy/graph/extractors/_dexpi.py +0 -44
- cognite/neat/legacy/graph/extractors/_graph_capturing_sheet.py +0 -403
- cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +0 -361
- cognite/neat/legacy/graph/loaders/__init__.py +0 -23
- cognite/neat/legacy/graph/loaders/_asset_loader.py +0 -511
- cognite/neat/legacy/graph/loaders/_base.py +0 -67
- cognite/neat/legacy/graph/loaders/_exceptions.py +0 -85
- cognite/neat/legacy/graph/loaders/core/__init__.py +0 -0
- cognite/neat/legacy/graph/loaders/core/labels.py +0 -58
- cognite/neat/legacy/graph/loaders/core/models.py +0 -136
- cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +0 -1046
- cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +0 -559
- cognite/neat/legacy/graph/loaders/rdf_to_dms.py +0 -309
- cognite/neat/legacy/graph/loaders/validator.py +0 -87
- cognite/neat/legacy/graph/models.py +0 -6
- cognite/neat/legacy/graph/stores/__init__.py +0 -13
- cognite/neat/legacy/graph/stores/_base.py +0 -400
- cognite/neat/legacy/graph/stores/_graphdb_store.py +0 -52
- cognite/neat/legacy/graph/stores/_memory_store.py +0 -43
- cognite/neat/legacy/graph/stores/_oxigraph_store.py +0 -151
- cognite/neat/legacy/graph/stores/_oxrdflib.py +0 -247
- cognite/neat/legacy/graph/stores/_rdf_to_graph.py +0 -42
- cognite/neat/legacy/graph/transformations/__init__.py +0 -0
- cognite/neat/legacy/graph/transformations/entity_matcher.py +0 -101
- cognite/neat/legacy/graph/transformations/query_generator/__init__.py +0 -3
- cognite/neat/legacy/graph/transformations/query_generator/sparql.py +0 -575
- cognite/neat/legacy/graph/transformations/transformer.py +0 -322
- cognite/neat/legacy/rules/__init__.py +0 -0
- cognite/neat/legacy/rules/analysis.py +0 -231
- cognite/neat/legacy/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- cognite/neat/legacy/rules/examples/Rules-Nordic44.xlsx +0 -0
- cognite/neat/legacy/rules/examples/__init__.py +0 -18
- cognite/neat/legacy/rules/examples/power-grid-containers.yaml +0 -124
- cognite/neat/legacy/rules/examples/power-grid-example.xlsx +0 -0
- cognite/neat/legacy/rules/examples/power-grid-model.yaml +0 -224
- cognite/neat/legacy/rules/examples/rules-template.xlsx +0 -0
- cognite/neat/legacy/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- cognite/neat/legacy/rules/examples/skos-rules.xlsx +0 -0
- cognite/neat/legacy/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- cognite/neat/legacy/rules/examples/wind-energy.owl +0 -1511
- cognite/neat/legacy/rules/exceptions.py +0 -2972
- cognite/neat/legacy/rules/exporters/__init__.py +0 -20
- cognite/neat/legacy/rules/exporters/_base.py +0 -45
- cognite/neat/legacy/rules/exporters/_core/__init__.py +0 -5
- cognite/neat/legacy/rules/exporters/_core/rules2labels.py +0 -24
- cognite/neat/legacy/rules/exporters/_rules2dms.py +0 -885
- cognite/neat/legacy/rules/exporters/_rules2excel.py +0 -213
- cognite/neat/legacy/rules/exporters/_rules2graphql.py +0 -183
- cognite/neat/legacy/rules/exporters/_rules2ontology.py +0 -524
- cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +0 -748
- cognite/neat/legacy/rules/exporters/_rules2rules.py +0 -105
- cognite/neat/legacy/rules/exporters/_rules2triples.py +0 -38
- cognite/neat/legacy/rules/exporters/_validation.py +0 -146
- cognite/neat/legacy/rules/importers/__init__.py +0 -22
- cognite/neat/legacy/rules/importers/_base.py +0 -66
- cognite/neat/legacy/rules/importers/_dict2rules.py +0 -158
- cognite/neat/legacy/rules/importers/_dms2rules.py +0 -194
- cognite/neat/legacy/rules/importers/_graph2rules.py +0 -308
- cognite/neat/legacy/rules/importers/_json2rules.py +0 -39
- cognite/neat/legacy/rules/importers/_owl2rules/__init__.py +0 -3
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +0 -239
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +0 -260
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +0 -217
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2rules.py +0 -290
- cognite/neat/legacy/rules/importers/_spreadsheet2rules.py +0 -45
- cognite/neat/legacy/rules/importers/_xsd2rules.py +0 -20
- cognite/neat/legacy/rules/importers/_yaml2rules.py +0 -39
- cognite/neat/legacy/rules/models/__init__.py +0 -5
- cognite/neat/legacy/rules/models/_base.py +0 -151
- cognite/neat/legacy/rules/models/raw_rules.py +0 -316
- cognite/neat/legacy/rules/models/rdfpath.py +0 -237
- cognite/neat/legacy/rules/models/rules.py +0 -1289
- cognite/neat/legacy/rules/models/tables.py +0 -9
- cognite/neat/legacy/rules/models/value_types.py +0 -118
- cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +0 -89
- cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -152
- cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -139
- cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -270
- cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +0 -65
- cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -116
- cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +0 -67
- cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -64
- cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -95
- cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -111
- cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -270
- cognite/neat/workflows/migration/__init__.py +0 -0
- cognite/neat/workflows/migration/steps.py +0 -91
- cognite/neat/workflows/migration/wf_manifests.py +0 -33
- cognite/neat/workflows/steps/lib/legacy/__init__.py +0 -7
- cognite/neat/workflows/steps/lib/legacy/graph_contextualization.py +0 -82
- cognite/neat/workflows/steps/lib/legacy/graph_extractor.py +0 -746
- cognite/neat/workflows/steps/lib/legacy/graph_loader.py +0 -606
- cognite/neat/workflows/steps/lib/legacy/graph_store.py +0 -307
- cognite/neat/workflows/steps/lib/legacy/graph_transformer.py +0 -58
- cognite/neat/workflows/steps/lib/legacy/rules_exporter.py +0 -511
- cognite/neat/workflows/steps/lib/legacy/rules_importer.py +0 -612
- {cognite_neat-0.87.4.dist-info → cognite_neat-0.88.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.87.4.dist-info → cognite_neat-0.88.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.87.4.dist-info → cognite_neat-0.88.0.dist-info}/entry_points.txt +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.88.0"
|
|
@@ -16,25 +16,6 @@ class RuleRequest(BaseModel):
|
|
|
16
16
|
rule: str
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class UploadToCdfRequest(BaseModel):
|
|
20
|
-
file_name: str = ""
|
|
21
|
-
file_type: str = "workflow"
|
|
22
|
-
comments: str = ""
|
|
23
|
-
author: str = ""
|
|
24
|
-
tag: str = ""
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class DownloadFromCdfRequest(BaseModel):
|
|
28
|
-
file_name: str = ""
|
|
29
|
-
file_type: str = "workflow"
|
|
30
|
-
version: str = ""
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class LoadGraphRequest(BaseModel):
|
|
34
|
-
graph_source_template_name: str
|
|
35
|
-
source_location: str
|
|
36
|
-
|
|
37
|
-
|
|
38
19
|
class RunWorkflowRequest(BaseModel):
|
|
39
20
|
name: str
|
|
40
21
|
config: dict
|
cognite/neat/app/api/explorer.py
CHANGED
|
@@ -10,7 +10,12 @@ from cognite import neat
|
|
|
10
10
|
from cognite.neat.app.api.asgi.metrics import prometheus_app
|
|
11
11
|
from cognite.neat.app.api.configuration import NEAT_APP, UI_PATH
|
|
12
12
|
from cognite.neat.app.api.context_manager import lifespan
|
|
13
|
-
from cognite.neat.app.api.routers import
|
|
13
|
+
from cognite.neat.app.api.routers import (
|
|
14
|
+
configuration,
|
|
15
|
+
crud,
|
|
16
|
+
metrics,
|
|
17
|
+
workflows,
|
|
18
|
+
)
|
|
14
19
|
from cognite.neat.app.api.utils.logging import EndpointFilter
|
|
15
20
|
|
|
16
21
|
app = FastAPI(title="Neat", lifespan=lifespan)
|
|
@@ -45,10 +50,7 @@ app.mount("/data", StaticFiles(directory=NEAT_APP.config.data_store_path), name=
|
|
|
45
50
|
app.include_router(configuration.router)
|
|
46
51
|
app.include_router(metrics.router)
|
|
47
52
|
app.include_router(workflows.router)
|
|
48
|
-
app.include_router(rules.router)
|
|
49
53
|
app.include_router(crud.router)
|
|
50
|
-
app.include_router(data_exploration.router)
|
|
51
|
-
app.include_router(core.router)
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
# General routes
|
|
@@ -14,28 +14,13 @@ from cognite.neat.workflows.utils import get_file_hash
|
|
|
14
14
|
router = APIRouter()
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@router.get("/api/cdf/neat-resources")
|
|
18
|
-
def get_neat_resources(resource_type: str | None = None):
|
|
19
|
-
if NEAT_APP.cdf_store is None:
|
|
20
|
-
return {"error": "NeatApp is not initialized"}
|
|
21
|
-
if resource_type is None:
|
|
22
|
-
return {"error": "Resource type is not specified"}
|
|
23
|
-
result = NEAT_APP.cdf_store.get_list_of_resources_from_cdf(resource_type=resource_type)
|
|
24
|
-
logging.debug(f"Got {len(result)} resources")
|
|
25
|
-
return {"result": result}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@router.post("/api/cdf/init-neat-resources")
|
|
29
|
-
def init_neat_cdf_resources(resource_type: str | None = None):
|
|
30
|
-
if NEAT_APP.cdf_store is None:
|
|
31
|
-
return {"error": "NeatApp is not initialized"}
|
|
32
|
-
NEAT_APP.cdf_store.init_cdf_resources(resource_type=resource_type)
|
|
33
|
-
return {"result": "ok"}
|
|
34
|
-
|
|
35
|
-
|
|
36
17
|
@router.post("/api/file/upload/{workflow_name}/{file_type}/{step_id}/{action}")
|
|
37
18
|
async def file_upload_handler(
|
|
38
|
-
files: list[UploadFile],
|
|
19
|
+
files: list[UploadFile],
|
|
20
|
+
workflow_name: str,
|
|
21
|
+
file_type: str,
|
|
22
|
+
step_id: str,
|
|
23
|
+
action: str,
|
|
39
24
|
) -> dict[str, str]:
|
|
40
25
|
if NEAT_APP.cdf_store is None or NEAT_APP.workflow_manager is None:
|
|
41
26
|
return {"error": "NeatApp is not initialized"}
|
|
@@ -91,7 +76,12 @@ async def file_upload_handler(
|
|
|
91
76
|
if workflow is None:
|
|
92
77
|
return {"error": f"Workflow {workflow_name} not found"}
|
|
93
78
|
flow_msg = FlowMessage(
|
|
94
|
-
payload={
|
|
79
|
+
payload={
|
|
80
|
+
"file_name": file_name,
|
|
81
|
+
"hash": file_version,
|
|
82
|
+
"full_path": full_path,
|
|
83
|
+
"file_type": file_type,
|
|
84
|
+
}
|
|
95
85
|
)
|
|
96
86
|
start_step_id = None if step_id == "none" else step_id
|
|
97
87
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import shutil
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
from typing import cast
|
|
5
4
|
|
|
6
5
|
from fastapi import APIRouter, Depends, HTTPException, Request, UploadFile
|
|
7
6
|
from fastapi.responses import FileResponse, JSONResponse
|
|
8
7
|
|
|
9
8
|
from cognite.neat.app.api.configuration import NEAT_APP
|
|
10
|
-
from cognite.neat.app.api.data_classes.rest import
|
|
9
|
+
from cognite.neat.app.api.data_classes.rest import (
|
|
10
|
+
RunWorkflowRequest,
|
|
11
|
+
)
|
|
11
12
|
from cognite.neat.workflows import WorkflowFullStateReport
|
|
12
13
|
from cognite.neat.workflows.base import WorkflowDefinition
|
|
13
|
-
from cognite.neat.workflows.migration.wf_manifests import migrate_wf_manifest
|
|
14
14
|
from cognite.neat.workflows.model import FlowMessage
|
|
15
|
-
from cognite.neat.workflows.steps.data_contracts import
|
|
15
|
+
from cognite.neat.workflows.steps.data_contracts import NeatGraph
|
|
16
16
|
from cognite.neat.workflows.steps.step_model import DataContract
|
|
17
|
-
from cognite.neat.workflows.utils import get_file_hash
|
|
18
17
|
|
|
19
18
|
router = APIRouter()
|
|
20
19
|
|
|
@@ -27,7 +26,11 @@ def start_workflow(request: RunWorkflowRequest):
|
|
|
27
26
|
start_status = NEAT_APP.workflow_manager.start_workflow_instance(
|
|
28
27
|
request.name, sync=request.sync, flow_msg=FlowMessage()
|
|
29
28
|
)
|
|
30
|
-
result = {
|
|
29
|
+
result = {
|
|
30
|
+
"workflow_instance": None,
|
|
31
|
+
"is_success": start_status.is_success,
|
|
32
|
+
"status_text": start_status.status_text,
|
|
33
|
+
}
|
|
31
34
|
return {"result": result}
|
|
32
35
|
|
|
33
36
|
|
|
@@ -58,25 +61,6 @@ def get_workflow_files(workflow_name: str):
|
|
|
58
61
|
return {"files": workflow.get_list_of_workflow_artifacts()}
|
|
59
62
|
|
|
60
63
|
|
|
61
|
-
@router.post("/api/workflow/package/{workflow_name}")
|
|
62
|
-
def package_workflow(workflow_name: str):
|
|
63
|
-
if NEAT_APP.cdf_store is None:
|
|
64
|
-
return {"error": "NeatApp is not initialized"}
|
|
65
|
-
package_file = NEAT_APP.cdf_store.package_workflow(workflow_name)
|
|
66
|
-
hash_ = get_file_hash(NEAT_APP.config.workflows_store_path / package_file)
|
|
67
|
-
return {"package": package_file, "hash": hash_}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@router.post("/api/workflow/context-cleanup/{workflow_name}")
|
|
71
|
-
def cleanup_workflow_data(workflow_name: str):
|
|
72
|
-
if NEAT_APP.cdf_store is None:
|
|
73
|
-
return {"error": "NeatApp is not initialized"}
|
|
74
|
-
workflow = NEAT_APP.workflow_manager.get_workflow(workflow_name)
|
|
75
|
-
if workflow is not None:
|
|
76
|
-
workflow.cleanup_workflow_context()
|
|
77
|
-
return {"result": "ok"}
|
|
78
|
-
|
|
79
|
-
|
|
80
64
|
@router.post("/api/workflow/create")
|
|
81
65
|
def create_new_workflow(request: WorkflowDefinition):
|
|
82
66
|
if NEAT_APP.workflow_manager is None:
|
|
@@ -95,30 +79,24 @@ def delete_workflow(workflow_name: str):
|
|
|
95
79
|
return {"result": "ok"}
|
|
96
80
|
|
|
97
81
|
|
|
98
|
-
@router.get("/api/workflow/executions")
|
|
99
|
-
def get_list_of_workflow_executions():
|
|
100
|
-
return {"executions": NEAT_APP.cdf_store.get_list_of_workflow_executions_from_cdf()}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
@router.get("/api/workflow/detailed-execution-report/{execution_id}")
|
|
104
|
-
def get_detailed_execution(execution_id: str):
|
|
105
|
-
if NEAT_APP.cdf_store is None:
|
|
106
|
-
return {"error": "NeatApp is not initialized"}
|
|
107
|
-
return {"report": NEAT_APP.cdf_store.get_detailed_workflow_execution_report_from_cdf(execution_id)}
|
|
108
|
-
|
|
109
|
-
|
|
110
82
|
@router.post("/api/workflow/reload-workflows")
|
|
111
83
|
def reload_workflows():
|
|
112
84
|
NEAT_APP.workflow_manager.load_workflows_from_storage()
|
|
113
85
|
NEAT_APP.triggers_manager.reload_all_triggers()
|
|
114
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
"result": "ok",
|
|
88
|
+
"workflows": NEAT_APP.workflow_manager.get_list_of_workflows(),
|
|
89
|
+
}
|
|
115
90
|
|
|
116
91
|
|
|
117
92
|
@router.post("/api/workflow/reload-single-workflow/{workflow_name}")
|
|
118
93
|
def reload_single_workflows(workflow_name: str):
|
|
119
94
|
NEAT_APP.workflow_manager.load_single_workflow_from_storage(workflow_name)
|
|
120
95
|
NEAT_APP.triggers_manager.reload_all_triggers()
|
|
121
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
"result": "ok",
|
|
98
|
+
"workflows": NEAT_APP.workflow_manager.get_list_of_workflows(),
|
|
99
|
+
}
|
|
122
100
|
|
|
123
101
|
|
|
124
102
|
@router.get("/api/workflow/workflow-definition/{workflow_name}")
|
|
@@ -152,58 +130,6 @@ def update_workflow_definition(workflow_name: str, request: WorkflowDefinition):
|
|
|
152
130
|
return {"result": "ok"}
|
|
153
131
|
|
|
154
132
|
|
|
155
|
-
@router.post("/api/workflow/upload-wf-to-cdf/{workflow_name}")
|
|
156
|
-
def upload_workflow_to_cdf(workflow_name: str, request: UploadToCdfRequest):
|
|
157
|
-
if NEAT_APP.cdf_store is None:
|
|
158
|
-
return {"error": "NeatApp is not initialized"}
|
|
159
|
-
NEAT_APP.cdf_store.save_workflow_to_cdf(
|
|
160
|
-
workflow_name, changed_by=request.author, comments=request.comments, tag=request.tag
|
|
161
|
-
)
|
|
162
|
-
return {"result": "ok"}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
@router.post("/api/workflow/upload-rules-cdf/{workflow_name}")
|
|
166
|
-
def upload_rules_to_cdf(workflow_name: str, request: UploadToCdfRequest):
|
|
167
|
-
if NEAT_APP.cdf_store is None:
|
|
168
|
-
return {"error": "NeatApp is not initialized"}
|
|
169
|
-
file_path = Path(NEAT_APP.config.rules_store_path, request.file_name)
|
|
170
|
-
NEAT_APP.cdf_store.save_resource_to_cdf(
|
|
171
|
-
workflow_name, "neat-wf-rules", file_path, changed_by=request.author, comments=request.comments
|
|
172
|
-
)
|
|
173
|
-
return {"result": "ok"}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@router.post("/api/workflow/download-wf-from-cdf")
|
|
177
|
-
def download_wf_from_cdf(request: DownloadFromCdfRequest):
|
|
178
|
-
if NEAT_APP.cdf_store is None:
|
|
179
|
-
return {"error": "NeatApp is not initialized"}
|
|
180
|
-
NEAT_APP.cdf_store.load_workflows_from_cdf(request.file_name, request.version)
|
|
181
|
-
return {"result": "ok"}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
@router.post("/api/workflow/download-rules-from-cdf")
|
|
185
|
-
def download_rules_to_cdf(request: DownloadFromCdfRequest):
|
|
186
|
-
if NEAT_APP.cdf_store is None:
|
|
187
|
-
return {"error": "NeatApp is not initialized"}
|
|
188
|
-
NEAT_APP.cdf_store.load_rules_file_from_cdf(request.file_name, request.version)
|
|
189
|
-
return {"file_name": request.file_name, "hash": request.version}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
@router.post("/api/workflow/migrate-workflow")
|
|
193
|
-
def migrate_workflow():
|
|
194
|
-
return migrate_wf_manifest(NEAT_APP.config.data_store_path)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
@router.get("/api/workflow/pre-cdf-assets/{workflow_name}")
|
|
198
|
-
def get_pre_cdf_assets(workflow_name: str):
|
|
199
|
-
if NEAT_APP.workflow_manager is None:
|
|
200
|
-
return {"error": "Workflow Manager is not initialized"}
|
|
201
|
-
workflow = NEAT_APP.workflow_manager.get_workflow(workflow_name)
|
|
202
|
-
if workflow is None:
|
|
203
|
-
return {"assets": []}
|
|
204
|
-
return {"assets": workflow.data["CategorizedAssets"]}
|
|
205
|
-
|
|
206
|
-
|
|
207
133
|
@router.get("/api/workflow/context/{workflow_name}")
|
|
208
134
|
def get_context(workflow_name: str):
|
|
209
135
|
if NEAT_APP.workflow_manager is None:
|
|
@@ -228,8 +154,8 @@ def get_context_object(workflow_name: str, object_name: str):
|
|
|
228
154
|
if object_name not in context:
|
|
229
155
|
return {"error": f"Item {object_name} is not found in workflow context"}
|
|
230
156
|
|
|
231
|
-
if object_name == "
|
|
232
|
-
return {"object": cast(
|
|
157
|
+
if object_name == "NeatGraph":
|
|
158
|
+
return {"object": cast(NeatGraph, context[object_name]).graph.type_}
|
|
233
159
|
|
|
234
160
|
cobject = context[object_name]
|
|
235
161
|
if isinstance(cobject, DataContract):
|
|
@@ -285,7 +211,11 @@ def http_trigger_start_workflow(workflow_name: str, step_id: str, request: Reque
|
|
|
285
211
|
|
|
286
212
|
@router.post("/api/workflow/{workflow_name}/resume/{step_id}/{instance_id}")
|
|
287
213
|
def http_trigger_resume_workflow(
|
|
288
|
-
workflow_name: str,
|
|
214
|
+
workflow_name: str,
|
|
215
|
+
step_id: str,
|
|
216
|
+
instance_id: str,
|
|
217
|
+
request: Request,
|
|
218
|
+
body: bytes = fast_api_depends,
|
|
289
219
|
):
|
|
290
220
|
if NEAT_APP.triggers_manager is None:
|
|
291
221
|
return JSONResponse(content={"error": "Triggers Manager is not initialized"}, status_code=400)
|
|
@@ -30,6 +30,8 @@ class AssetsExtractor(BaseExtractor):
|
|
|
30
30
|
limit the extraction to 1000 assets to test the setup.
|
|
31
31
|
unpack_metadata (bool, optional): Whether to unpack metadata. Defaults to False, which yields the metadata as
|
|
32
32
|
a JSON string.
|
|
33
|
+
skip_metadata_values (set[str] | frozenset[str] | None, optional): A set of values to skip when unpacking
|
|
34
|
+
metadata. Defaults to frozenset({"nan", "null", "none", ""}).
|
|
33
35
|
"""
|
|
34
36
|
|
|
35
37
|
_SPACE_PATTERN = re.compile(r"\s+")
|
|
@@ -42,6 +44,7 @@ class AssetsExtractor(BaseExtractor):
|
|
|
42
44
|
total: int | None = None,
|
|
43
45
|
limit: int | None = None,
|
|
44
46
|
unpack_metadata: bool = True,
|
|
47
|
+
skip_metadata_values: set[str] | frozenset[str] | None = frozenset({"nan", "null", "none", ""}),
|
|
45
48
|
):
|
|
46
49
|
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
47
50
|
self.assets = assets
|
|
@@ -49,6 +52,7 @@ class AssetsExtractor(BaseExtractor):
|
|
|
49
52
|
self.total = total
|
|
50
53
|
self.limit = min(limit, total) if limit and total else limit
|
|
51
54
|
self.unpack_metadata = unpack_metadata
|
|
55
|
+
self.skip_metadata_values = skip_metadata_values
|
|
52
56
|
|
|
53
57
|
@classmethod
|
|
54
58
|
def from_dataset(
|
|
@@ -162,7 +166,7 @@ class AssetsExtractor(BaseExtractor):
|
|
|
162
166
|
if asset.source:
|
|
163
167
|
triples.append((id_, self.namespace.source, Literal(asset.source)))
|
|
164
168
|
|
|
165
|
-
# properties ref creation and update
|
|
169
|
+
# properties' ref creation and update
|
|
166
170
|
triples.append(
|
|
167
171
|
(
|
|
168
172
|
id_,
|
|
@@ -193,7 +197,9 @@ class AssetsExtractor(BaseExtractor):
|
|
|
193
197
|
if asset.metadata:
|
|
194
198
|
if self.unpack_metadata:
|
|
195
199
|
for key, value in asset.metadata.items():
|
|
196
|
-
if value
|
|
200
|
+
if value and (
|
|
201
|
+
self.skip_metadata_values is None or value.casefold() not in self.skip_metadata_values
|
|
202
|
+
):
|
|
197
203
|
triples.append(
|
|
198
204
|
(
|
|
199
205
|
id_,
|
|
@@ -250,9 +250,9 @@ def _generate_mock_data_property_triples(
|
|
|
250
250
|
python_type = value_type.python
|
|
251
251
|
triples = []
|
|
252
252
|
for id_ in instance_ids:
|
|
253
|
-
if python_type
|
|
253
|
+
if python_type is int:
|
|
254
254
|
triples.append((id_, URIRef(namespace[property_]), Literal(random.randint(1, 1983))))
|
|
255
|
-
elif python_type
|
|
255
|
+
elif python_type is float:
|
|
256
256
|
triples.append((id_, URIRef(namespace[property_]), Literal(numpy.float32(random.uniform(1, 1983)))))
|
|
257
257
|
# generate string
|
|
258
258
|
else:
|
|
@@ -48,18 +48,23 @@ class BaseLoader(ABC, Generic[T_Output]):
|
|
|
48
48
|
class CDFLoader(BaseLoader[T_Output]):
|
|
49
49
|
_UPLOAD_BATCH_SIZE: ClassVar[int] = 1000
|
|
50
50
|
|
|
51
|
-
def load_into_cdf(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
def load_into_cdf(
|
|
52
|
+
self, client: CogniteClient, dry_run: bool = False, check_client: bool = True
|
|
53
|
+
) -> UploadResultList:
|
|
54
|
+
return UploadResultList(self.load_into_cdf_iterable(client, dry_run, check_client))
|
|
55
|
+
|
|
56
|
+
def load_into_cdf_iterable(
|
|
57
|
+
self, client: CogniteClient, dry_run: bool = False, check_client: bool = True
|
|
58
|
+
) -> Iterable[UploadResult]:
|
|
59
|
+
if check_client:
|
|
60
|
+
missing_capabilities = client.iam.verify_capabilities(self._get_required_capabilities())
|
|
61
|
+
if missing_capabilities:
|
|
62
|
+
upload_result = UploadResult[Hashable](name=type(self).__name__)
|
|
63
|
+
upload_result.issues.append(
|
|
64
|
+
FailedAuthorizationError(action="Upload to CDF", reason=str(missing_capabilities))
|
|
65
|
+
)
|
|
66
|
+
yield upload_result
|
|
67
|
+
return
|
|
63
68
|
|
|
64
69
|
issues = NeatIssueList[NeatIssue]()
|
|
65
70
|
items: list[T_Output] = []
|