Skip to content

Commit

Permalink
[CDF-23025] 😑Skip non resource yaml on required kind (#1208)
Browse files Browse the repository at this point in the history
* fix: skip yaml files

* build: changelog

* fix: in correct location
  • Loading branch information
doctrino authored Nov 19, 2024
1 parent 05fcba3 commit f369564
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Changes are grouped as follows:
### Fixed

- [Alpha feature] `cdf deploy` will no longer deploy `GraphQL` resources if they are not changed.
- [Alpha feature] `cdf build` will no longer copy content `YAML` files to the build directory.

## [0.3.10] - 2024-11-14

Expand Down
6 changes: 6 additions & 0 deletions cognite_toolkit/_cdf_tk/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
ToolkitMissingModuleError,
ToolkitYAMLFormatError,
)
from cognite_toolkit._cdf_tk.feature_flags import Flags
from cognite_toolkit._cdf_tk.hints import ModuleDefinition, verify_module_directory
from cognite_toolkit._cdf_tk.loaders import (
ContainerLoader,
DataLoader,
DataModelLoader,
ExtractionPipelineConfigLoader,
FileLoader,
NodeLoader,
RawDatabaseLoader,
RawTableLoader,
Expand Down Expand Up @@ -314,6 +316,10 @@ def _build_module_resources(
# is warnings
self.warning_list.extend(destination)
continue
if Flags.REQUIRE_KIND.is_enabled() and destination.loader is FileLoader:
# This is a content file that we should not copy to the build directory.
continue

safe_write(destination.path, destination.content)
if issubclass(destination.loader, DataLoader):
continue
Expand Down
7 changes: 7 additions & 0 deletions cognite_toolkit/_cdf_tk/loaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
RESOURCE_LOADER_LIST = [loader for loader in LOADER_LIST if issubclass(loader, ResourceLoader)]
RESOURCE_CONTAINER_LOADER_LIST = [loader for loader in LOADER_LIST if issubclass(loader, ResourceContainerLoader)]
RESOURCE_DATA_LOADER_LIST = [loader for loader in LOADER_LIST if issubclass(loader, DataLoader)]
KINDS_BY_FOLDER_NAME: dict[str, set[str]] = {}
for loader in LOADER_LIST:
if loader.folder_name not in KINDS_BY_FOLDER_NAME:
KINDS_BY_FOLDER_NAME[loader.folder_name] = set()
KINDS_BY_FOLDER_NAME[loader.folder_name].add(loader.kind)
del loader # cleanup module namespace

if not Flags.STREAMLIT.is_enabled():
ResourceTypes: TypeAlias = Literal[
Expand Down Expand Up @@ -195,4 +201,5 @@ def get_loader(resource_dir: str, kind: str) -> type[Loader]:
"RESOURCE_LOADER_LIST",
"RESOURCE_CONTAINER_LOADER_LIST",
"RESOURCE_DATA_LOADER_LIST",
"KINDS_BY_FOLDER_NAME",
]

0 comments on commit f369564

Please sign in to comment.