Skip to content

Commit

Permalink
Release 0.3.22 (#1297)
Browse files Browse the repository at this point in the history
# Description

Please describe the change you have made.

## Checklist

- [ ] Tests added/updated.
- [ ] Run Demo Job Locally.
- [ ] Documentation updated.
- [ ] Changelogs updated in
[CHANGELOG.cdf-tk.md](https://github.com/cognitedata/toolkit/blob/main/CHANGELOG.cdf-tk.md).
- [ ] Template changelogs updated in
[CHANGELOG.templates.md](https://github.com/cognitedata/toolkit/blob/main/CHANGELOG.templates.md).
- [ ] Version bumped.

[_version.py](https://github.com/cognitedata/toolkit/blob/main/cognite/cognite_toolkit/_version.py)
and

[pyproject.toml](https://github.com/cognitedata/toolkit/blob/main/pyproject.toml)
per [semantic versioning](https://semver.org/).
  • Loading branch information
doctrino authored Dec 12, 2024
2 parents 82c9d69 + dca90b7 commit c797f03
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.3.22] - 2024-12-12

### Fixed

- Deploying `GraphQL` is no longer sensitive to the newlines inside of directives.
- Functions are no longer always redeployed if `indexUrl` or `extraIndexUrls` are set in the `Function` resource.

## [0.3.21] - 2024-12-11

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.3.22] - 2024-12-12

No changes to templates.

## [0.3.21] - 2024-12-11

No changes to templates.
Expand Down
2 changes: 1 addition & 1 deletion cdf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ dump = true
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
2 changes: 1 addition & 1 deletion cognite_toolkit/_builtin_modules/cdf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_env = "<DEFAULT_ENV_PLACEHOLDER>"
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"


[plugins]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from __future__ import annotations

import re
import sys
from collections import defaultdict
from collections.abc import Hashable, Iterable, Sequence
from functools import lru_cache
Expand Down Expand Up @@ -1175,6 +1176,8 @@ def create(self, items: GraphQLDataModelWriteList) -> list[DMLApplyResult]:
print(LowSeverityWarning(f"Description is above limit for {item_id}. Truncating..."))
description = description[: 1024 - len(suffix) + 1 - 3] + "..."
description += f" {suffix}"
if "--verbose" in sys.argv:
print(f"Deploying GraphQL schema {item_id}")

created = self.client.dml.apply_dml(
item.as_id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def _are_equal(
local_dumped["metadata"][self._MetadataKey.secret_hash] = calculate_secure_hash(local_dumped["secrets"])
local_dumped["secrets"] = {k: "***" for k in local_dumped["secrets"]}

# Only in write (request) format of the function
local_dumped.pop("indexUrl", None)
local_dumped.pop("extraIndexUrls", None)

return self._return_are_equal(local_dumped, cdf_dumped, return_dumped)

def _is_activated(self, action: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_cdf_tk/utils/graphql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _standardize(cls, content: list[str]) -> str:
for last, current, next_ in zip(content, content[1:], content[2:]):
if current == "\n" and last in ")}]" and next_ in "({[":
standardized.append(",")
elif current == "\n" and last in "({[":
elif current == "\n" and last in ":({[":
continue
elif current == "\n" and next_ in ")}]":
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
pool:
vmImage: 'ubuntu-latest'
container:
image: 'cognite/toolkit:0.3.21'
image: 'cognite/toolkit:0.3.22'
env:
CDF_CLUSTER: $(CDF_CLUSTER)
CDF_PROJECT: $(CDF_PROJECT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
pool:
vmImage: 'ubuntu-latest'
container:
image: 'cognite/toolkit:0.3.21'
image: 'cognite/toolkit:0.3.22'
env:
CDF_CLUSTER: $(CDF_CLUSTER)
CDF_PROJECT: $(CDF_PROJECT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
environment: dev
name: Deploy Dry Run
container:
image: cognite/toolkit:0.3.21
image: cognite/toolkit:0.3.22
env:
CDF_CLUSTER: ${{ vars.CDF_CLUSTER }}
CDF_PROJECT: ${{ vars.CDF_PROJECT }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
environment: dev
name: Deploy
container:
image: cognite/toolkit:0.3.21
image: cognite/toolkit:0.3.22
env:
CDF_CLUSTER: ${{ vars.CDF_CLUSTER }}
CDF_PROJECT: ${{ vars.CDF_PROJECT }}
Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.21"
__version__ = "0.3.22"
3 changes: 1 addition & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.3.21"
version = "0.3.22"
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 @@ -4,4 +4,4 @@ project: pytest-project
type: dev
selected:
- modules
cdf_toolkit_version: 0.3.21
cdf_toolkit_version: 0.3.22
2 changes: 1 addition & 1 deletion tests/data/cdf_toml_data/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"

[plugins]
graphql = true
Expand Down
2 changes: 1 addition & 1 deletion tests/data/complete_org/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
runtime: 'py311'
functionPath: './src/handler.py'
# Data set id for the zip file with the code that is uploaded.
dataSetExternalId: 'ds_timeseries_{{example_variable}}'
dataSetExternalId: 'ds_timeseries_{{example_variable}}'
indexUrl: https://pypi.org/simple
2 changes: 1 addition & 1 deletion tests/data/complete_org_alpha_flags/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
2 changes: 1 addition & 1 deletion tests/data/project_no_cognite_modules/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
2 changes: 1 addition & 1 deletion tests/data/project_with_bad_modules/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
2 changes: 1 addition & 1 deletion tests/data/project_with_duplicates/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"
2 changes: 1 addition & 1 deletion tests/data/run_data/cdf.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[modules]
# This is the version of the modules. It should not be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.3.21"
version = "0.3.22"

[modules.packages]
cdf_infield = [
Expand Down
21 changes: 21 additions & 0 deletions tests/test_unit/test_cdf_tk/test_loaders/test_function_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,24 @@ def test_are_equals_secret_changing(self, cdf_tool_mock: CDFToolConfig, tmp_path
"secret1": "value1",
"secret2": "value2",
}, "Original object should not be modified"

def test_are_equals_index_url_set(self, cdf_tool_mock: CDFToolConfig, tmp_path: Path) -> None:
local_function = FunctionWrite(
name="my_function",
file_id=123,
external_id="my_function",
index_url="http://my-index-url",
)
cdf_function = Function(
name="my_function",
file_id=123,
external_id="my_function",
metadata={
FunctionLoader._MetadataKey.function_hash: calculate_directory_hash(tmp_path / "my_function"),
},
)
loader = FunctionLoader.create_loader(cdf_tool_mock, tmp_path)

are_equal = loader.are_equal(local_function, cdf_function, return_dumped=False)

assert are_equal is True
33 changes: 32 additions & 1 deletion tests/test_unit/test_cdf_tk/test_utils/test_graphql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,31 @@
set(),
id="Type with comments",
),
pytest.param(
"""type Alarm @view (rawFilter:
{equals : {property: ["PSI-COR-ALL-DMD", "AlarmEventMessage", "journal"], value: "Alarm"}}
)
{
journal:String @mapping(container: "AlarmEventMessage")
dataOwner:AlarmEventMessageDataOwner @mapping(container: "AlarmEventMessage")
aemTimeStamp: Timestamp @mapping(container: "AlarmEventMessage")
pointTag:String @mapping(container: "AlarmEventMessage")
pointTagDesc:String @mapping(container: "AlarmEventMessage")
psiUnit:String @mapping(container: "AlarmEventMessage")
code:String @mapping(container: "AlarmEventMessage")
alarmType:String @mapping(container: "AlarmEventMessage")
alarmState:String @mapping(container: "AlarmEventMessage")
priority:String @mapping(container: "AlarmEventMessage")
limit:Int @mapping(container: "AlarmEventMessage")
value:String @mapping(container: "AlarmEventMessage")
sourceAlarm:String @mapping(container: "AlarmEventMessage")
alarmEnableStatus:String @mapping(container: "AlarmEventMessage")
}""",
DATA_MODEL,
{ViewId(SPACE, "Alarm", None)},
set(),
id="Type with raw filter",
),
]

DirectiveTestCases = [
Expand Down Expand Up @@ -258,7 +283,13 @@
}
)""",
_ViewDirective(space="cdf_cdm", version="v1"),
)
),
pytest.param(
"""view (rawFilter:
{equals : {property: ["PSI-COR-ALL-DMD", "AlarmEventMessage", "journal"], value: "Alarm"}}
)""",
_ViewDirective(),
),
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Function:
externalId: fn_first_function
fileId: -1
functionPath: ./src/handler.py
indexUrl: https://pypi.org/simple
metadata:
cdf-toolkit-function-hash: a63720560f48030aaf994e92b02b1de1932514aa79b3115ced9d65fba8440aff
cdf-toolkit-secret-hash: d218376a8813e2bb96b70b9f3df07157b0b58f18f3667c64e500032095f4f2cb0f1679ed7034189009131ce2e77cc363d840b478d94d8525cad7d9830a78e129
Expand Down

0 comments on commit c797f03

Please sign in to comment.