Skip to content

Commit

Permalink
Fix wrong space names and transformation names (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregertw authored Dec 1, 2023
1 parent 70bffdc commit e340ce7
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ jobs:
- name: "Build the templates"
run: cdf-tk build --build-dir=./build --env=demo ./demo_project
# be careful, this works as promised
- name: "Delete existing resources including data"
run: |
cdf-tk clean --env=demo ./build
#- name: "Delete existing resources including data"
# run: |
# cdf-tk clean --env=demo ./build
- name: "Verify and create access rights"
run: cdf-tk auth verify
- name: "Allow some time for data modeling to finish syncing of deletions"
run: |
sleep 30
- name: "Deploy the templates"
run: |
cdf-tk deploy --env=demo ./build
cdf-tk deploy --drop --drop-data --env=demo ./build
- name: "Run transformations and other post-processing"
run: |
poetry run python ./demo/postproc.py
2 changes: 1 addition & 1 deletion CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [TBD]
## [0.1.0a3] - 2023-12-01

### Changed

Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.1.0a2"
__version__ = "0.1.0a3"
__template_version__ = "0.2.0"
2 changes: 1 addition & 1 deletion cognite_toolkit/cdf_tk/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ def load_datamodel(
ToolGlobals.failed = True
return
print(
f" Created {len(items.changed)} unchanged {type_}(s) that could have been skipped (--drop specified)."
f" Created {len(items.unchanged)} unchanged {type_}(s) that could have been skipped (--drop specified)."
)

if delete_removed and not drop:
Expand Down
18 changes: 10 additions & 8 deletions cognite_toolkit/cdf_tk/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ def check_yaml_semantics(parsed: Any, filepath_src: Path, filepath_build: Path,
if resource_type == "auth":
parts = ext_id.split("_")
if len(parts) < 2:
if verbose and ext_id == "applications-configuration":
print(
" [bold green]INFO:[/] the group applications-configuration does not follow the recommended '_' based namespacing because Infield expects this specific name."
)
if ext_id == "applications-configuration":
if verbose:
print(
" [bold green]INFO:[/] the group applications-configuration does not follow the recommended '_' based namespacing because Infield expects this specific name."
)
else:
print(
f" [bold yellow]WARNING:[/] the group {filepath_src} has a name [bold]{ext_id}[/] without the recommended '_' based namespacing."
Expand Down Expand Up @@ -227,10 +228,11 @@ def check_yaml_semantics(parsed: Any, filepath_src: Path, filepath_build: Path,
f" [bold yellow]WARNING:[/] the space {filepath_src} has an externalId [bold]{ext_id}[/] without the recommended '_' based namespacing."
)
elif parts[0] != "sp":
if verbose and (ext_id == "cognite_app_data" or ext_id == "APM_SourceData" or ext_id == "APM_Config"):
print(
f" [bold green]INFO:[/] the space {ext_id} does not follow the recommended '_' based namespacing because Infield expects this specific name."
)
if ext_id == "cognite_app_data" or ext_id == "APM_SourceData" or ext_id == "APM_Config":
if verbose:
print(
f" [bold green]INFO:[/] the space {ext_id} does not follow the recommended '_' based namespacing because Infield expects this specific name."
)
else:
print(
f" [bold yellow]WARNING:[/] the space {filepath_src} has an externalId [bold]{ext_id}[/] without the recommended 'sp_' based prefix."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ destination:
space: cdf_core
externalId: Asset
version: 'v1'
instanceSpace: 'space_infield_{{default_location}}_source'
instanceSpace: 'space_asset_{{default_location}}_source'
type: nodes
ignoreNullFields: true
shared: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ destination:
externalId: APM_SourceData
version: "1"
destinationType: APM_Activity
instanceSpace: 'space_infield_{{default_location}}_source'
instanceSpace: 'space_asset_{{default_location}}_source'
type: instances
ignoreNullFields: true
shared: true
Expand Down
22 changes: 14 additions & 8 deletions demo/postproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ def run() -> None:
print("Doing post-processing activities for demo project...")
ToolGlobals = CDFToolConfig(client_name="cdf-project-templates")
try:
print("Running oid-load-asset-hierarchy...")
ToolGlobals.client.transformations.run(transformation_external_id="oid-load-asset-hierarchy")
print("Running sync_workorders_to_apm_activities...")
ToolGlobals.client.transformations.run(transformation_external_id="sync_workorders_to_apm_activities")
print("Running tr_asset_oid_workmate_asset_hierarchy...")
ToolGlobals.client.transformations.run(transformation_external_id="tr_asset_oid_workmate_asset_hierarchy")
print("Running tr_workorder_oid_workmate_infield_sync_workorders_to_apm_activities...")
ToolGlobals.client.transformations.run(
transformation_external_id="tr_workorder_oid_workmate_infield_sync_workorders_to_apm_activities"
)
# Wait until assets are in the hierarchy
time.sleep(10.0)
print("Running sync_assets_from_hierarchy_to_apm...")
ToolGlobals.client.transformations.run(transformation_external_id="sync_assets_from_hierarchy_to_apm")
print("Running tr_asset_oid_workmate_infield_sync_assets_from_hierarchy_to_apm...")
ToolGlobals.client.transformations.run(
transformation_external_id="tr_asset_oid_workmate_infield_sync_assets_from_hierarchy_to_apm"
)
# Wait until assets are in data models
time.sleep(10.0)
print("Running sync_asset_parents_from_hierarchy_to_apm...")
ToolGlobals.client.transformations.run(transformation_external_id="sync_asset_parents_from_hierarchy_to_apm")
print("Running tr_asset_oid_workmate_infield_sync_asset_parents_from_hierarchy_to_apm...")
ToolGlobals.client.transformations.run(
transformation_external_id="tr_asset_oid_workmate_infield_sync_asset_parents_from_hierarchy_to_apm"
)
except Exception as e:
log.error(f"Failed to run post-processing activities for demo project:\n{e}")
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cognite_toolkit"
version = "0.1.0a2"
version = "0.1.0a3"
description = "Official Cognite Data Fusion tool for project templates and configuration deployment"
authors = ["Cognite AS <[email protected]>"]
license = "Apache-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Transformation:
tokenUri: ${IDP_TOKEN_URL}
- dataSetId: 999
destination:
instanceSpace: space_infield_oid_source
instanceSpace: space_asset_oid_source
type: nodes
view:
externalId: Asset
Expand Down Expand Up @@ -452,7 +452,7 @@ Transformation:
externalId: APM_SourceData
space: APM_SourceData
version: '1'
instanceSpace: space_infield_oid_source
instanceSpace: space_asset_oid_source
type: instances
destinationOidcCredentials:
audience: ${IDP_AUDIENCE}
Expand Down

0 comments on commit e340ce7

Please sign in to comment.