Skip to content

Commit

Permalink
File metadata update (#365)
Browse files Browse the repository at this point in the history
* fix file metadata update

* bump version

* fixing update logic
  • Loading branch information
rsjr authored Sep 18, 2024
1 parent 818db7a commit db19499
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## 7.4.6

### Fixed

* Fix file metadata update

## 7.4.5

### Removed
Expand Down
2 changes: 1 addition & 1 deletion cognite/extractorutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
Cognite extractor utils is a Python package that simplifies the development of new extractors.
"""

__version__ = "7.4.5"
__version__ = "7.4.6"
from .base import Extractor
8 changes: 8 additions & 0 deletions cognite/extractorutils/uploader/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ def _upload_empty(
file_meta, url = self._create_cdm(instance_id=node_id)
else:
file_meta, url = self.cdf_client.files.create(file_metadata=file_meta, overwrite=self.overwrite_existing)
# trigger update after creation (upsert =P)
basic_attributes = set(["externalId", "name"])
attr = set(file_meta.dump().keys())
diff = attr - basic_attributes

if len(diff) >= 1 and "externalId" in attr:
file_meta = self.cdf_client.files.update(file_meta)

return file_meta, url

def _upload_bytes(self, size: int, file: BinaryIO, file_meta: FileMetadataOrCogniteExtractorFile) -> None:
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-extractor-utils"
version = "7.4.5"
version = "7.4.6"
description = "Utilities for easier development of extractors for CDF"
authors = ["Mathias Lohne <mathias.lohne@cognite.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit db19499

Please sign in to comment.