Skip to content

Commit 7d4416d

Browse files
committed
Adds license headers and performs linting
1 parent 1a0b18a commit 7d4416d

4 files changed

Lines changed: 18 additions & 21 deletions

File tree

‎examples/opik_vs_elastic/helpers/indexing.py‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ def get_elasticsearch_client() -> ElasticsearchClient:
7878
"""Build a client from CLOUD_ID/ELASTICSEARCH_API_KEY or ES_URL/ES_HOST env vars."""
7979
cloud_id = os.getenv("CLOUD_ID")
8080
api_key = os.getenv("ELASTICSEARCH_API_KEY")
81-
host = (
82-
os.getenv("ES_URL")
83-
or os.getenv("ELASTICSEARCH_ENDPOINT")
84-
or os.getenv("ES_HOST")
85-
)
81+
host = os.getenv("ES_URL") or os.getenv("ELASTICSEARCH_ENDPOINT") or os.getenv("ES_HOST")
8682

8783
if cloud_id and api_key:
8884
es = Elasticsearch(cloud_id=cloud_id, api_key=api_key)
@@ -91,8 +87,6 @@ def get_elasticsearch_client() -> ElasticsearchClient:
9187
elif host:
9288
es = Elasticsearch(hosts=[host])
9389
else:
94-
raise ValueError(
95-
"Set CLOUD_ID + ELASTICSEARCH_API_KEY, or ES_URL/ES_HOST, to connect to Elasticsearch."
96-
)
90+
raise ValueError("Set CLOUD_ID + ELASTICSEARCH_API_KEY, or ES_URL/ES_HOST, to connect to Elasticsearch.")
9791

9892
return ElasticsearchClient(es=es)

‎examples/opik_vs_elastic/orca_helpers/opik_client.py‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
# or more contributor license agreements. Licensed under the Elastic License 2.0;
3+
# you may not use this file except in compliance with the Elastic License 2.0.
4+
15
"""Opik dataset client, mirroring and extending orca_helpers's opik_client.py.
26
37
orca_helpers's ``clients/opik_client.py`` only wraps ``get_dataset`` and
@@ -62,9 +66,7 @@ def list_datasets(
6266
Falls back to the client's default project when ``project_name`` is
6367
omitted.
6468
"""
65-
return self._sdk_client.get_datasets(
66-
max_results=max_results, project_name=project_name
67-
)
69+
return self._sdk_client.get_datasets(max_results=max_results, project_name=project_name)
6870

6971
def add_rows(
7072
self,
@@ -74,9 +76,7 @@ def add_rows(
7476
ignore_keys: list[str] | None = None,
7577
) -> None:
7678
"""Insert dataframe rows into a dataset, renaming/skipping columns."""
77-
dataset.insert_from_pandas(
78-
df, keys_mapping=keys_mapping, ignore_keys=ignore_keys
79-
)
79+
dataset.insert_from_pandas(df, keys_mapping=keys_mapping, ignore_keys=ignore_keys)
8080

8181
def get_rows(
8282
self,
@@ -88,9 +88,7 @@ def get_rows(
8888

8989
def dataset_url(self, dataset: Dataset) -> str:
9090
"""Build a UI URL for viewing this dataset in Opik."""
91-
return url_helpers.get_dataset_url_by_id(
92-
dataset_id=dataset.id, url_override=OpikConfig().url_override
93-
)
91+
return url_helpers.get_dataset_url_by_id(dataset_id=dataset.id, url_override=OpikConfig().url_override)
9492

9593
def project_url(self, project_name: str | None = None) -> str:
9694
"""Build a UI URL for viewing a project in Opik."""

‎examples/opik_vs_elastic/orca_helpers/scripts/index_kb_with_orca.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
# or more contributor license agreements. Licensed under the Elastic License 2.0;
3+
# you may not use this file except in compliance with the Elastic License 2.0.
4+
15
"""Index the Wix knowledge base into Elasticsearch using orca_helpers's real pipeline.
26
37
This mirrors orca_helpers's own ``orca_helpers.etl.indexing.cli`` so it runs the exact code the
@@ -40,10 +44,7 @@ def main() -> int:
4044

4145
es_client = get_elasticsearch_client()
4246
if es_client is None:
43-
raise RuntimeError(
44-
"Could not connect to Elasticsearch. Set CLOUD_ID + ELASTICSEARCH_API_KEY "
45-
"or ES_HOST."
46-
)
47+
raise RuntimeError("Could not connect to Elasticsearch. Set CLOUD_ID + ELASTICSEARCH_API_KEY or ES_HOST.")
4748

4849
indexing_config = IndexingConfig(gcs_root=GCS_ROOT, recreate_indices=True)
4950

‎examples/opik_vs_elastic/orca_helpers/scripts/register_datasets_opik.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
# or more contributor license agreements. Licensed under the Elastic License 2.0;
3+
# you may not use this file except in compliance with the Elastic License 2.0.
4+
15
"""Register the full Wix QA golden dataset into Opik.
26
37
Mirrors orca_helpers's dataset-registration pattern (see

0 commit comments

Comments
 (0)