Skip to content

Commit

Permalink
Release 0.4.4 (#1441)
Browse files Browse the repository at this point in the history
# Description

Please describe the change you have made.

## Checklist

- [ ] Prefixed the PR title with the Jira issue number on the form
`[CDF-12345]`.
- [ ] 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).


[CDF-12345]:
https://cognitedata.atlassian.net/browse/CDF-12345?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
doctrino authored Feb 5, 2025
2 parents 655fd15 + ec058e0 commit a908ad1
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.4.4] - 2025-02-05

### Fixed

- Deploying functions containing files that are not `utf-8` encoded no longer raises a `UnicodeDecodeError`.

## [0.4.3] - 2025-02-04

### 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.4.4] - 2025-02-05

No changes to templates.

## [0.4.3] - 2025-02-04

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 @@ -16,4 +16,4 @@ dump = true
[modules]
# This is the version of the modules. It should'n be changed manually.
# It will be updated by the 'cdf module upgrade' command.
version = "0.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"


[plugins]
Expand Down
5 changes: 4 additions & 1 deletion cognite_toolkit/_cdf_tk/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@ def _replace_variables(
self.console(f"Processing file {source_path.name}...")

content = safe_read(source_path)
source = SourceLocationEager(source_path, calculate_str_or_file_hash(content, shorten=True))
# We cannot use the content as the basis for hash as this have been encoded.
# Instead, we use the source path, which will hash the bytes of the file directly,
# which is what we do in the deploy step to verify that the source file has not changed.
source = SourceLocationEager(source_path, calculate_str_or_file_hash(source_path, shorten=True))

content = variables.replace(content, source_path.suffix)

Expand Down
14 changes: 5 additions & 9 deletions cognite_toolkit/_cdf_tk/utils/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,11 @@ def calculate_secure_hash(item: dict[str, Any]) -> str:


def calculate_str_or_file_hash(content: str | Path, shorten: bool = False) -> str:
sha256_hash = hashlib.sha256()
if isinstance(content, Path):
content = content.read_text("utf-8")
# Get rid of Windows line endings to make the hash consistent across platforms.
sha256_hash.update(content.encode("utf-8").replace(b"\r\n", b"\n"))
calculated = sha256_hash.hexdigest()
if shorten:
return calculated[:8]
return calculated
if isinstance(content, str):
byte_content = content.encode("utf-8")
else:
byte_content = content.read_bytes()
return calculate_bytes_or_file_hash(byte_content, shorten)


def calculate_bytes_or_file_hash(content: bytes | Path, shorten: bool = False) -> str:
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.4.3'
image: 'cognite/toolkit:0.4.4'
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.4.3'
image: 'cognite/toolkit:0.4.4'
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.4.3
image: cognite/toolkit:0.4.4
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.4.3
image: cognite/toolkit:0.4.4
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.4.3"
__version__ = "0.4.4"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cognite_toolkit"
version = "0.4.3"
version = "0.4.4"
description = "Official Cognite Data Fusion tool for project templates and configuration deployment"
authors = [
{name ="Cognite AS", email="support@cognite.com"}
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.4.3
cdf_toolkit_version: 0.4.4
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.4.3"
version = "0.4.4"

[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.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"
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.4.3"
version = "0.4.4"

[modules.packages]
cdf_infield = [
Expand Down
1 change: 1 addition & 0 deletions tests/test_unit/test_cdf_tk/test_commands/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_build_valid_read_int_version(self) -> None:
source_filepath = MagicMock(spec=Path)
source_filepath.read_text.return_value = raw_yaml
source_filepath.suffix = ".yaml"
source_filepath.read_bytes.return_value = raw_yaml.encode("utf-8")

source_files = cmd._replace_variables(
[source_filepath], BuildVariables([]), TransformationLoader.folder_name, Path("my_module"), verbose=False
Expand Down

0 comments on commit a908ad1

Please sign in to comment.