Skip to content

Commit

Permalink
Release 0.2.0b1 (#585)
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 May 30, 2024
2 parents a15c12a + a70ae17 commit 6835881
Show file tree
Hide file tree
Showing 35 changed files with 441 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
#- id: trailing-whitespace

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.40.0
rev: v0.41.0
hooks:
- id: markdownlint

Expand Down
16 changes: 15 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@
"program": "./cognite_toolkit/cognite_modules/examples/cdf_data_pipeline_files_valhall/functions/fn_workflow_files_oid_fileshare_annotation/handler.py",
"console": "integratedTerminal",
"justMyCode": false
}
},
{
"name": "Python: init",
"type": "debugpy",
"request": "launch",
"program": "./cdf-tk-dev.py",
"args": [
"init",
//"--dry-run",
//"--env=local",
//"--include=transformations"
],
"console": "integratedTerminal",
"justMyCode": false
},
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ Changes are grouped as follows:
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [0.2.0b1] - 2024-05-20

### Added

- Support for loading `nodes` with `APICall` arguments. The typical use case is when `node types` are part of a
data model, and the default `APICall` arguments works well.

### Fixed

- Error message displayed to console on failed `cdf-tk deploy` command could be modified. This is now fixed.
- Using display name instead of folder name on a failed `cdf-tk deploy` or `cdf-tk clean` command. For example,
if `datapoints subscription` was failing the error message would be `Failure to load/deploy timeseries as expected`,
now it is `Failure to load/deploy timeseries.subscription as expected`.
- Unique display names for all resource types.
- Fixed bug when deploying extraction pipeline config, when none existed from before:
`There is no config stored for the extraction pipeline`.

### Changed

- In `config.[env].yaml`, in the `environment` section, `selected_modules_and_packages` is renamed to `selected`.
The old names will still work, but will trigger a deprecation warning.

## [0.2.0a5] - 2024-05-28

### Added
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.templates.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.2.0b1] - 2024-05-20

### Fixed

- Removed illegal characters from `DatapointSubscriptoin` description in
`cognite_modules/examples/my_example_module`.

## [0.2.0a5] - 2024-05-28

### Added
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ It supports three different modes of operation:
bundled with templates useful for getting started with Cognite Data Fusion, as well as for specific use cases
delivered by Cognite or its partners. You can also create your own templates and share them.

## Usage

Install the Toolkit by running:

```bash
pip install cognite-toolkit
```

Then run `cdf-tk --help` to get started with the interactive command-line tool.

## For more information

More details about the tool can be found at
Expand Down
2 changes: 1 addition & 1 deletion cdf-tk-dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
name="local",
project="<my-project>",
build_type="dev",
selected_modules_and_packages=["cdf_demo_infield", "cdf_oid_example_data"],
selected=["cdf_demo_infield", "cdf_oid_example_data"],
)
).load_defaults(REPO_ROOT / "cognite_toolkit")
(REPO_ROOT / "cognite_toolkit" / "config.local.yaml").write_text(config_init.dump_yaml_with_comments())
Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_api/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
name="not used",
project="not used",
build_type="not used",
selected_modules_and_packages=[],
selected=[],
)


Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_api/modules_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _build(self, modules: Sequence[ModuleMeta], verbose: bool) -> None:
name=self._build_env,
project=self._project_name,
build_type=self._build_env,
selected_modules_and_packages=[module.name for module in modules],
selected=[module.name for module in modules],
),
filepath=Path(""),
variables=variables,
Expand Down
7 changes: 6 additions & 1 deletion cognite_toolkit/_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
NodeLoader,
TransformationLoader,
)
from cognite_toolkit._cdf_tk.prototypes import featureflag
from cognite_toolkit._cdf_tk.templates import (
COGNITE_MODULES,
)
Expand Down Expand Up @@ -89,6 +90,10 @@ def app() -> NoReturn:
# --- Main entry point ---
# Users run 'app()' directly, but that doesn't allow us to control excepton handling:
try:
if featureflag.enabled("FF_INTERACTIVE_INIT"):
from cognite_toolkit._cdf_tk.prototypes.interactive_init import InteractiveInit

_app.command("init")(InteractiveInit().interactive)
_app()
except ToolkitError as err:
print(f" [bold red]ERROR ([/][red]{type(err).__name__}[/][bold red]):[/] {err}")
Expand Down Expand Up @@ -453,7 +458,7 @@ def auth_verify(
raise ToolkitValidationError("Failure to verify access rights.")


@_app.command("init")
@_app.command("init" if not featureflag.enabled("FF_INTERACTIVE_INIT") else "_init")
def main_init(
ctx: typer.Context,
dry_run: Annotated[
Expand Down
3 changes: 2 additions & 1 deletion cognite_toolkit/_cdf_tk/_parameters/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def __sub__(self, other: AbstractSet) -> ParameterSet[T_Parameter]:


class ParameterSpecSet(ParameterSet[ParameterSpec]):
def __init__(self, iterable: Iterable[ParameterSpec] = ()) -> None:
def __init__(self, iterable: Iterable[ParameterSpec] = (), spec_name: str | None = None) -> None:
super().__init__(iterable)
self.is_complete = True
self.spec_name = spec_name

def required(self, level: int | None = None) -> ParameterSet[ParameterSpec]:
if level is None:
Expand Down
4 changes: 2 additions & 2 deletions cognite_toolkit/_cdf_tk/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def build_config(
if duplicate_modules := {
module_name: paths
for module_name, paths in module_parts_by_name.items()
if len(paths) > 1 and module_name in config.environment.selected_modules_and_packages
if len(paths) > 1 and module_name in config.environment.selected
}:
raise ToolkitDuplicatedModuleError(
f"Ambiguous module selected in config.{config.environment.name}.yaml:", duplicate_modules
)
system_config.validate_modules(available_modules, config.environment.selected_modules_and_packages)
system_config.validate_modules(available_modules, config.environment.selected)

selected_modules = config.get_selected_modules(system_config.packages, available_modules, verbose)

Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_cdf_tk/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def execute(
print(results.counts_table())
if results and results.has_uploads:
print(results.uploads_table())
raise ToolkitCleanResourceError(f"Failure to clean {loader_cls.folder_name} as expected.")
raise ToolkitCleanResourceError(f"Failure to clean {loader.display_name} as expected.")
if results.has_counts:
print(results.counts_table())
if results.has_uploads:
Expand Down
8 changes: 5 additions & 3 deletions cognite_toolkit/_cdf_tk/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def execute(
if drop or drop_data:
print(Panel("[bold]DEPLOYING resources...[/]"))
for loader_cls in ordered_loaders:
loader_instance = loader_cls.create_loader(ToolGlobals, build_dir)
result = self.deploy_resources(
loader_cls.create_loader(ToolGlobals, build_dir),
loader_instance,
ToolGlobals=ToolGlobals,
dry_run=dry_run,
has_done_drop=drop,
Expand All @@ -162,7 +163,7 @@ def execute(
print(results.counts_table())
if results and results.has_uploads:
print(results.uploads_table())
raise ToolkitDeployResourceError(f"Failure to load/deploy {loader_cls.folder_name} as expected.")
raise ToolkitDeployResourceError(f"Failure to load/deploy {loader_instance.display_name} as expected.")
if result:
results[result.name] = result
if ctx.obj.verbose:
Expand Down Expand Up @@ -366,7 +367,8 @@ def _create_resources(self, resources: T_CogniteResourceList, loader: ResourceLo
if e.code == 409:
self.warn(LowSeverityWarning("Resource(s) already exist(s), skipping creation."))
else:
print(f"[bold red]ERROR:[/] Failed to create resource(s).\n{e}")
print("[bold red]ERROR:[/] Failed to create resource(s).\n")
print(e)
return None
except CogniteDuplicatedError as e:
self.warn(
Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_cdf_tk/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def pull_command(
system_config = SystemYAML.load_from_directory(source_path, env)
config = BuildConfigYAML.load_from_directory(source_path, env)
config.set_environment_variables()
config.environment.selected_modules_and_packages = config.available_modules
config.environment.selected = config.available_modules
print(
Panel.fit(
f"[bold]Building all modules found in {config.filepath} (not only the modules under "
Expand Down
2 changes: 1 addition & 1 deletion cognite_toolkit/_cdf_tk/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run_local_function(
continue
for path in function_dir.iterdir():
if path.is_dir() and path.name == external_id:
config.environment.selected_modules_and_packages = [module_from_path(path)]
config.environment.selected = [module_from_path(path)]
found = True
break

Expand Down
Loading

0 comments on commit 6835881

Please sign in to comment.