Skip to content

Commit

Permalink
fix(#1516): restore read_only to copied dataset (#1520)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2f2fabb)
  • Loading branch information
frascuchon committed May 30, 2022
1 parent 63f7bee commit 5b9cf0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/rubrix/server/commons/es_wrapper.py
Expand Up @@ -492,6 +492,7 @@ def clone_index(self, index: str, clone_to: str, override: bool = True):
)
finally:
self.index_read_only(index, read_only=index_read_only)
self.index_read_only(clone_to, read_only=index_read_only)

def is_index_read_only(self, index: str) -> bool:
"""
Expand Down Expand Up @@ -533,7 +534,9 @@ def index_read_only(self, index: str, read_only: bool):
"""
self.__client__.indices.put_settings(
index=index, body={"settings": {"index.blocks.write": read_only}}
index=index,
body={"settings": {"index.blocks.write": read_only}},
ignore=404,
)

def create_field_mapping(
Expand Down
16 changes: 8 additions & 8 deletions tests/client/test_api.py
Expand Up @@ -371,21 +371,21 @@ def test_dataset_copy(mocked_client):
mocked_client.delete(f"/api/datasets/{dataset_copy}")
mocked_client.delete(f"/api/datasets/{dataset_copy}?workspace={other_workspace}")

api.log(
rb.TextClassificationRecord(
id=0,
inputs="This is the record input",
annotation_agent="test",
annotation=["T"],
),
name=dataset,
record = rb.TextClassificationRecord(
id=0,
inputs="This is the record input",
annotation_agent="test",
annotation=["T"],
)
api.log(record, name=dataset)
api.copy(dataset, name_of_copy=dataset_copy)
df = api.load(name=dataset)
df_copy = api.load(name=dataset_copy)

assert df.equals(df_copy)

api.log(record, name=dataset_copy)

with pytest.raises(AlreadyExistsApiError):
api.copy(dataset, name_of_copy=dataset_copy)
with pytest.raises(NotFoundApiError, match=other_workspace):
Expand Down

0 comments on commit 5b9cf0e

Please sign in to comment.