Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#1516): restore read_only to copied dataset #1520

Merged
merged 1 commit into from May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/rubrix/server/elasticseach/client_wrapper.py
Expand Up @@ -503,6 +503,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 @@ -544,7 +545,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 @@ -373,21 +373,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