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

Add cleaned option #48

Merged
merged 2 commits into from
Dec 6, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion alephclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,15 @@ def _bulk_chunk(
entityset_id: Optional[str] = None,
force: bool = False,
unsafe: bool = False,
cleaned: bool = False
):
for attempt in count(1):
url = self._make_url(f"collections/{collection_id}/_bulk")
params = {"unsafe": unsafe, "entityset_id": entityset_id}
params = {"entityset_id": entityset_id}
if unsafe:
params['safe'] = not unsafe
if cleaned:
params['clean'] = not cleaned
try:
response = self.session.post(url, json=chunk, params=params)
response.raise_for_status()
Expand Down
7 changes: 6 additions & 1 deletion alephclient/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ def read_json_stream(stream):
"--force", is_flag=True, default=False, help="continue after server errors"
)
@click.option(
"--unsafe", is_flag=True, default=False, help="disable server-side validation"
"--unsafe", is_flag=True, default=False, help="allow references to archive hashes"
)
@click.option(
"--cleaned", is_flag=True, default=False, help="disable server-side validation for all types"
)
@click.pass_context
def write_entities(
Expand All @@ -265,6 +268,7 @@ def write_entities(
chunksize=1000,
force=False,
unsafe=False,
cleaned=False
):
"""Read entities from standard input and index them."""
api = ctx.obj["api"]
Expand All @@ -288,6 +292,7 @@ def read_json_stream(stream):
chunk_size=chunksize,
unsafe=unsafe,
force=force,
cleaned=cleaned,
entityset_id=entityset_id,
)
except AlephException as exc:
Expand Down