Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/evo-blockmodels/src/evo/blockmodels/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ async def _update_columns(
geometry_change: bool | None = None,
fill_subblocks: bool | None = None,
tags: dict[str, dict[str, Any]] | None = None,
update_type: models.UpdateType = models.UpdateType.replace
) -> Version:
if self._cache is None:
raise CacheNotConfiguredException(
Expand Down Expand Up @@ -850,9 +851,9 @@ async def _update_columns(
update_data_lite=models.UpdateDataLite(
models.UpdateDataLite1(
columns=columns,
update_type=models.UpdateType.replace,
update_type=update_type,
geometry_change=geometry_change,
**({} if fill_subblocks is None else {"fill_subblocks": fill_subblocks}),
fill_subblocks=fill_subblocks,
)
),
additional_headers=self._preview_headers(),
Expand All @@ -868,6 +869,7 @@ async def update_block_model_columns(
delete_columns: set[str] | None = None,
units: dict[str, str] | None = None,
tags: dict[str, dict[str, Any]] | None = None,
update_type: models.UpdateType = models.UpdateType.replace
) -> Version:
"""Add, update, or delete regular block model columns.

Expand All @@ -883,11 +885,12 @@ async def update_block_model_columns(
:param units: A dictionary mapping column names within `data` to units.
:param tags: A dictionary mapping new column names to their tags object. Column tags are a preview feature; the
client must be constructed with ``preview=True`` to use them.
:param: update_type: Provide the type of update. Either 'replace' or 'merge' (default: replace)
:raises CacheNotConfiguredException: If the cache is not configured.
:return: The new version of the block model with the added columns.
"""
return await self._update_columns(
bm_id, data, new_columns, update_columns, delete_columns, units, geometry_change=None, tags=tags
bm_id, data, new_columns, update_columns, delete_columns, units, geometry_change=None, tags=tags, update_type=update_type,
)

async def update_subblocked_columns(
Expand All @@ -901,6 +904,7 @@ async def update_subblocked_columns(
geometry_change: bool = False,
fill_subblocks: bool | None = None,
tags: dict[str, dict[str, Any]] | None = None,
update_type: models.UpdateType = models.UpdateType.replace
) -> Version:
"""Add, update, or delete sub-blocked block model columns.

Expand All @@ -925,6 +929,7 @@ async def update_subblocked_columns(
the block model's own ``fill_subblocks`` setting is used.
:param tags: A dictionary mapping new column names to their tags object. Column tags are a preview feature; the
client must be constructed with ``preview=True`` to use them.
:param: update_type: Provide the type of update. Either 'replace' or 'merge' (default: replace)
"""
return await self._update_columns(
bm_id,
Expand All @@ -936,6 +941,7 @@ async def update_subblocked_columns(
geometry_change=geometry_change,
fill_subblocks=fill_subblocks,
tags=tags,
update_type=update_type
)

async def update_column_metadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3230,7 +3230,7 @@ class UpdateDataLite1(CustomBaseModel):
"""
Lineage of the block model update
"""
update_type: UpdateType = "merge"
update_type: UpdateType = UpdateType.merge
"""

Behaviour of the update, for blocks that are omitted from the update file.
Expand Down Expand Up @@ -3283,7 +3283,7 @@ class UpdateDataLite2(CustomBaseModel):
"""
Lineage of the block model update
"""
update_type: UpdateType = "merge"
update_type: UpdateType = UpdateType.merge
"""

Behaviour of the update, for blocks that are omitted from the update file.
Expand Down
20 changes: 4 additions & 16 deletions packages/evo-blockmodels/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from evo.common.data import HTTPHeaderDict, RequestMethod
from evo.common.test_tools import BASE_URL, MockResponse, TestWithConnector, TestWithStorage
from evo.common.utils import get_header_metadata
from utils import JobPollingRequestHandler
from utils import DEFAULT_EXPECTED_HEADERS, JobPollingRequestHandler

BM_UUID = uuid.uuid4()
GOOSE_UUID = uuid.uuid4()
Expand Down Expand Up @@ -276,11 +276,7 @@ def _assert_create_request(
comment=comment,
fill_subblocks=fill_subblocks,
).model_dump(mode="json", exclude_unset=True),
headers={
"Authorization": "Bearer <not-a-real-token>",
"Content-Type": "application/json",
"Accept": "application/json",
},
headers=DEFAULT_EXPECTED_HEADERS,
)

async def test_create_block_model(self) -> None:
Expand Down Expand Up @@ -457,11 +453,7 @@ async def test_create_block_model_with_data(self) -> None:
method=RequestMethod.PATCH,
path=f"{self.base_path}/block-models/{BM_UUID}/blocks",
body=expected_update_body.model_dump(mode="json", exclude_unset=True),
headers={
"Authorization": "Bearer <not-a-real-token>",
"Content-Type": "application/json",
"Accept": "application/json",
},
headers=DEFAULT_EXPECTED_HEADERS,
)
self.assertEqual(bm.id, BM_UUID)

Expand Down Expand Up @@ -559,11 +551,7 @@ async def test_create_subblocked_model_with_data(self) -> None:
method=RequestMethod.PATCH,
path=f"{self.base_path}/block-models/{BM_UUID}/blocks",
body=expected_update_body.model_dump(mode="json", exclude_unset=True),
headers={
"Authorization": "Bearer <not-a-real-token>",
"Content-Type": "application/json",
"Accept": "application/json",
},
headers=DEFAULT_EXPECTED_HEADERS,
)
self.assertEqual(bm.id, BM_UUID)

Expand Down
Loading