databar 2.6.1__tar.gz → 2.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {databar-2.6.1/src/databar.egg-info → databar-2.7.0}/PKG-INFO +3 -2
  2. {databar-2.6.1 → databar-2.7.0}/README.md +2 -1
  3. {databar-2.6.1 → databar-2.7.0}/pyproject.toml +1 -1
  4. {databar-2.6.1 → databar-2.7.0}/src/databar/__init__.py +1 -1
  5. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/waterfalls.py +6 -4
  6. {databar-2.6.1 → databar-2.7.0}/src/databar/client.py +36 -22
  7. {databar-2.6.1 → databar-2.7.0}/src/databar/exceptions.py +6 -1
  8. {databar-2.6.1 → databar-2.7.0}/src/databar/models.py +2 -0
  9. {databar-2.6.1 → databar-2.7.0/src/databar.egg-info}/PKG-INFO +3 -2
  10. {databar-2.6.1 → databar-2.7.0}/tests/test_cli.py +1 -1
  11. {databar-2.6.1 → databar-2.7.0}/tests/test_client.py +31 -5
  12. {databar-2.6.1 → databar-2.7.0}/tests/test_new_features.py +16 -0
  13. {databar-2.6.1 → databar-2.7.0}/LICENSE +0 -0
  14. {databar-2.6.1 → databar-2.7.0}/setup.cfg +0 -0
  15. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/__init__.py +0 -0
  16. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/_auth.py +0 -0
  17. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/_guide.py +0 -0
  18. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/_oauth.py +0 -0
  19. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/_onboard.py +0 -0
  20. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/_output.py +0 -0
  21. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/app.py +0 -0
  22. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/enrichments.py +0 -0
  23. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/flows.py +0 -0
  24. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/tables.py +0 -0
  25. {databar-2.6.1 → databar-2.7.0}/src/databar/cli/tasks.py +0 -0
  26. {databar-2.6.1 → databar-2.7.0}/src/databar.egg-info/SOURCES.txt +0 -0
  27. {databar-2.6.1 → databar-2.7.0}/src/databar.egg-info/dependency_links.txt +0 -0
  28. {databar-2.6.1 → databar-2.7.0}/src/databar.egg-info/entry_points.txt +0 -0
  29. {databar-2.6.1 → databar-2.7.0}/src/databar.egg-info/requires.txt +0 -0
  30. {databar-2.6.1 → databar-2.7.0}/src/databar.egg-info/top_level.txt +0 -0
  31. {databar-2.6.1 → databar-2.7.0}/tests/test_oauth_login.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databar
3
- Version: 2.6.1
3
+ Version: 2.7.0
4
4
  Summary: Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai
5
5
  Author-email: "Databar.ai Team" <info@databar.ai>
6
6
  License: MIT License
@@ -174,7 +174,8 @@ for choice in choices.items:
174
174
  # List waterfalls
175
175
  waterfalls = client.list_waterfalls()
176
176
 
177
- # Run a waterfall (tries all providers in sequence)
177
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
178
+ # such as Apollo run only when you pass their id in `enrichments`)
178
179
  result = client.run_waterfall_sync(
179
180
  "email_getter",
180
181
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -119,7 +119,8 @@ for choice in choices.items:
119
119
  # List waterfalls
120
120
  waterfalls = client.list_waterfalls()
121
121
 
122
- # Run a waterfall (tries all providers in sequence)
122
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
123
+ # such as Apollo run only when you pass their id in `enrichments`)
123
124
  result = client.run_waterfall_sync(
124
125
  "email_getter",
125
126
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "databar"
7
- version = "2.6.1"
7
+ version = "2.7.0"
8
8
  description = "Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -110,7 +110,7 @@ from .models import (
110
110
  Folder,
111
111
  )
112
112
 
113
- __version__ = "2.6.1"
113
+ __version__ = "2.7.0"
114
114
  __all__ = [
115
115
  "DatabarClient",
116
116
  # exceptions
@@ -23,6 +23,8 @@ from ._output import OutputFormat, console, error, info, output
23
23
 
24
24
  app = typer.Typer(help="Search and run waterfall enrichments.")
25
25
 
26
+ PROVIDERS_HELP = "Comma-separated provider IDs (default: providers enabled by default)."
27
+
26
28
 
27
29
  @app.command("list")
28
30
  def list_waterfalls(
@@ -99,10 +101,10 @@ def get_waterfall(
99
101
  if w.available_enrichments:
100
102
  console.print("\n[bold]Available providers:[/bold]")
101
103
  rows = [
102
- {"id": e.id, "name": e.name, "price": e.price}
104
+ {"id": e.id, "name": e.name, "price": e.price, "default": "yes" if e.enabled_by_default else "no"}
103
105
  for e in w.available_enrichments
104
106
  ]
105
- output(rows, OutputFormat.TABLE, table_columns=["id", "name", "price"])
107
+ output(rows, OutputFormat.TABLE, table_columns=["id", "name", "price", "default"])
106
108
 
107
109
 
108
110
  @app.command("info", hidden=True)
@@ -118,7 +120,7 @@ def info_waterfall(
118
120
  def run_waterfall(
119
121
  identifier: str = typer.Argument(..., help="Waterfall identifier."),
120
122
  params_json: str = typer.Option(..., "--params", "-p", help='JSON params, e.g. \'{"linkedin_url":"https://..."}\''),
121
- providers: Optional[str] = typer.Option(None, "--providers", help="Comma-separated provider IDs (default: all)."),
123
+ providers: Optional[str] = typer.Option(None, "--providers", help=PROVIDERS_HELP),
122
124
  email_verifier: Optional[int] = typer.Option(None, "--email-verifier", help="Email verifier enrichment ID."),
123
125
  fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
124
126
  raw: bool = typer.Option(False, "--raw", help="Print raw result without formatting."),
@@ -160,7 +162,7 @@ def run_waterfall(
160
162
  def bulk_waterfall(
161
163
  identifier: str = typer.Argument(..., help="Waterfall identifier."),
162
164
  input_file: Path = typer.Option(..., "--input", "-i", help="CSV file with one row per input.", exists=True),
163
- providers: Optional[str] = typer.Option(None, "--providers", help="Comma-separated provider IDs (default: all)."),
165
+ providers: Optional[str] = typer.Option(None, "--providers", help=PROVIDERS_HELP),
164
166
  email_verifier: Optional[int] = typer.Option(None, "--email-verifier", help="Email verifier enrichment ID."),
165
167
  fmt: OutputFormat = typer.Option(OutputFormat.TABLE, "--format", "--output", "-f"),
166
168
  out: Optional[str] = typer.Option(None, "--out", "-o", help="Output file (for CSV format)."),
@@ -223,6 +223,18 @@ class DatabarClient:
223
223
  status_code=status,
224
224
  response_body=body,
225
225
  )
226
+ if status in (400, 422) and isinstance(body, dict) and isinstance(body.get("error"), str):
227
+ detail = body.get("detail")
228
+ message = detail if isinstance(detail, str) and detail else body["error"]
229
+ errors = body.get("fields")
230
+ if not isinstance(errors, list):
231
+ errors = body.get("rows") if isinstance(body.get("rows"), list) else []
232
+ raise DatabarValidationError(
233
+ message,
234
+ errors=errors,
235
+ status_code=status,
236
+ response_body=body,
237
+ )
226
238
  if status == 422:
227
239
  detail = body.get("detail", [])
228
240
  if isinstance(detail, list):
@@ -537,14 +549,12 @@ class DatabarClient:
537
549
  """
538
550
  Submit a waterfall run.
539
551
 
540
- If enrichments is None or empty, all available providers are used
541
- (auto-resolved from get_waterfall, same behavior as MCP).
552
+ If enrichments is None or empty, the server runs the waterfall's default
553
+ cascade: providers with ``enabled_by_default=True``, in configured order.
542
554
  """
543
- if not enrichments:
544
- waterfall = self.get_waterfall(identifier)
545
- enrichments = [e.id for e in waterfall.available_enrichments]
546
-
547
- payload: Dict[str, Any] = {"params": params, "enrichments": enrichments}
555
+ payload: Dict[str, Any] = {"params": params}
556
+ if enrichments:
557
+ payload["enrichments"] = enrichments
548
558
  if email_verifier is not None:
549
559
  payload["email_verifier"] = email_verifier
550
560
 
@@ -563,12 +573,12 @@ class DatabarClient:
563
573
  The polled result is aligned to the inputs: one element per input, in the
564
574
  same order as ``params``, with ``None`` for inputs that returned no data
565
575
  (``len(result) == len(params)``, ``result[i]`` ↔ ``params[i]``).
566
- """
567
- if not enrichments:
568
- waterfall = self.get_waterfall(identifier)
569
- enrichments = [e.id for e in waterfall.available_enrichments]
570
576
 
571
- payload: Dict[str, Any] = {"params": params, "enrichments": enrichments}
577
+ If enrichments is None or empty, the server runs the default cascade.
578
+ """
579
+ payload: Dict[str, Any] = {"params": params}
580
+ if enrichments:
581
+ payload["enrichments"] = enrichments
572
582
  if email_verifier is not None:
573
583
  payload["email_verifier"] = email_verifier
574
584
 
@@ -1007,8 +1017,8 @@ class DatabarClient:
1007
1017
  self,
1008
1018
  table_uuid: str,
1009
1019
  waterfall_identifier: str,
1010
- enrichments: List[int],
1011
- mapping: Dict[str, str],
1020
+ enrichments: Optional[List[int]] = None,
1021
+ mapping: Optional[Dict[str, str]] = None,
1012
1022
  email_verifier: Optional[int] = None,
1013
1023
  ) -> AddWaterfallResponse:
1014
1024
  """
@@ -1017,20 +1027,24 @@ class DatabarClient:
1017
1027
  Args:
1018
1028
  table_uuid: UUID of the table.
1019
1029
  waterfall_identifier: Waterfall slug (e.g. 'email_getter').
1020
- enrichments: List of enrichment (provider) IDs to use in the cascade.
1021
- mapping: Maps waterfall parameter names to column UUIDs or column names.
1022
- The API resolves names to UUIDs automatically.
1030
+ enrichments: Optional provider IDs, in cascade order. If None or empty,
1031
+ the server attaches the default cascade (providers with
1032
+ ``enabled_by_default=True``).
1033
+ mapping: Required. Maps waterfall parameter names to column UUIDs or
1034
+ column names. The API resolves names to UUIDs automatically.
1023
1035
  email_verifier: Optional enrichment ID for email verification.
1024
1036
 
1025
1037
  Returns:
1026
1038
  :class:`AddWaterfallResponse` with ``id`` and ``waterfall_name``.
1027
1039
  Use ``id`` with run_table_enrichment().
1028
1040
  """
1029
- payload: Dict[str, Any] = {
1030
- "waterfall": waterfall_identifier,
1031
- "enrichments": enrichments,
1032
- "mapping": mapping,
1033
- }
1041
+ # ponytail: mapping keeps its positional slot after enrichments so existing
1042
+ # positional callers don't break, hence the default + runtime check.
1043
+ if mapping is None:
1044
+ raise TypeError("add_waterfall() missing required argument: 'mapping'")
1045
+ payload: Dict[str, Any] = {"waterfall": waterfall_identifier, "mapping": mapping}
1046
+ if enrichments:
1047
+ payload["enrichments"] = enrichments
1034
1048
  if email_verifier is not None:
1035
1049
  payload["email_verifier"] = email_verifier
1036
1050
  data = self._request("POST", f"/table/{table_uuid}/add-waterfall", json=payload)
@@ -59,7 +59,12 @@ class DatabarGoneError(DatabarError):
59
59
 
60
60
 
61
61
  class DatabarValidationError(DatabarError):
62
- """Raised on 422 — request body failed schema validation."""
62
+ """Raised when the API rejected the input.
63
+
64
+ 400 is a business-rule failure (unknown column, bad enrichment param).
65
+ 422 is a schema failure (wrong JSON shape). Both use the same body:
66
+ ``{"error": "<CODE>", "detail": "<string>"}``.
67
+ """
63
68
 
64
69
  def __init__(
65
70
  self,
@@ -301,6 +301,8 @@ class WaterfallEnrichment(BaseModel):
301
301
  description: str
302
302
  price: Union[str, float]
303
303
  params: List[str]
304
+ # False = optional add-on, run only when its id is passed explicitly.
305
+ enabled_by_default: bool = True
304
306
 
305
307
 
306
308
  class Waterfall(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databar
3
- Version: 2.6.1
3
+ Version: 2.7.0
4
4
  Summary: Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai
5
5
  Author-email: "Databar.ai Team" <info@databar.ai>
6
6
  License: MIT License
@@ -174,7 +174,8 @@ for choice in choices.items:
174
174
  # List waterfalls
175
175
  waterfalls = client.list_waterfalls()
176
176
 
177
- # Run a waterfall (tries all providers in sequence)
177
+ # Run a waterfall (tries the default providers in sequence; optional add-ons
178
+ # such as Apollo run only when you pass their id in `enrichments`)
178
179
  result = client.run_waterfall_sync(
179
180
  "email_getter",
180
181
  {"linkedin_url": "https://linkedin.com/in/alice"},
@@ -759,7 +759,7 @@ def test_task_cancel_reports_a_finished_task(monkeypatch):
759
759
  def test_version_flag():
760
760
  result = runner.invoke(app, ["--version"])
761
761
  assert result.exit_code == 0
762
- assert "2.6.1" in result.output
762
+ assert "2.7.0" in result.output
763
763
 
764
764
 
765
765
  def test_output_module_does_not_import_click():
@@ -112,6 +112,24 @@ def test_http_error_mapping(client: DatabarClient, httpx_mock: HTTPXMock, status
112
112
  client.get_user()
113
113
 
114
114
 
115
+ def test_validation_envelope_is_a_validation_error(client: DatabarClient, httpx_mock: HTTPXMock):
116
+ httpx_mock.add_response(
117
+ url=f"{BASE_URL}/enrichments/1/run",
118
+ method="POST",
119
+ status_code=400,
120
+ json={
121
+ "error": "INVALID_PARAMS",
122
+ "detail": "Row 1: domain: This field is required.",
123
+ "rows": [{"position": 1, "fields": {"domain": ["This field is required."]}}],
124
+ },
125
+ )
126
+ with pytest.raises(DatabarValidationError) as exc:
127
+ client.run_enrichment(1, {"domain": ""})
128
+ assert exc.value.status_code == 400
129
+ assert exc.value.message == "Row 1: domain: This field is required."
130
+ assert exc.value.errors[0]["position"] == 1
131
+
132
+
115
133
  def test_retry_on_500(client: DatabarClient, httpx_mock: HTTPXMock):
116
134
  httpx_mock.add_response(url=f"{BASE_URL}/user/me", status_code=500, json={"detail": "oops"})
117
135
  httpx_mock.add_response(url=f"{BASE_URL}/user/me", status_code=500, json={"detail": "oops"})
@@ -209,14 +227,22 @@ def test_list_waterfalls(client: DatabarClient, httpx_mock: HTTPXMock):
209
227
  assert result[0].identifier == "email_getter"
210
228
 
211
229
 
212
- def test_run_waterfall_auto_resolves_providers(client: DatabarClient, httpx_mock: HTTPXMock):
213
- httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter", json=waterfall_payload())
230
+ def test_run_waterfall_without_providers_leaves_the_default_to_the_server(client: DatabarClient, httpx_mock: HTTPXMock):
214
231
  httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter/run", json=task_payload("processing"))
232
+ httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/email_getter/bulk-run", json=task_payload("processing"))
215
233
  task = client.run_waterfall("email_getter", {"linkedin_url": "https://linkedin.com/in/alice"})
234
+ client.run_waterfall_bulk("email_getter", [{"linkedin_url": "https://linkedin.com/in/alice"}])
216
235
  assert task.task_id == "task-123"
217
- req = httpx_mock.get_requests()[-1]
218
- body = json.loads(req.content)
219
- assert body["enrichments"] == [10, 11]
236
+ # One POST each, no GET /waterfalls/{id} to resolve the provider list client-side.
237
+ requests = httpx_mock.get_requests()
238
+ assert [r.method for r in requests] == ["POST", "POST"]
239
+ assert all("enrichments" not in json.loads(r.content) for r in requests)
240
+
241
+
242
+ def test_run_waterfall_passes_explicit_providers(client: DatabarClient, httpx_mock: HTTPXMock):
243
+ httpx_mock.add_response(url=f"{BASE_URL}/waterfalls/person_getter/run", json=task_payload("processing"))
244
+ client.run_waterfall("person_getter", {"email": "a@b.com"}, enrichments=[113])
245
+ assert json.loads(httpx_mock.get_requests()[-1].content)["enrichments"] == [113]
220
246
 
221
247
 
222
248
  # ===========================================================================
@@ -333,6 +333,22 @@ def test_add_waterfall(client: DatabarClient, httpx_mock: HTTPXMock):
333
333
  assert body["email_verifier"] == 10
334
334
 
335
335
 
336
+ def test_add_waterfall_without_providers_leaves_the_default_to_the_server(client: DatabarClient, httpx_mock: HTTPXMock):
337
+ httpx_mock.add_response(
338
+ url=f"{BASE_URL}/table/tbl-1/add-waterfall",
339
+ json={"id": 56, "waterfall_name": "Person Getter"},
340
+ )
341
+ client.add_waterfall("tbl-1", waterfall_identifier="person_getter", mapping={"email": "email"})
342
+ body = json.loads(httpx_mock.get_requests()[0].content)
343
+ assert "enrichments" not in body
344
+ assert body["mapping"] == {"email": "email"}
345
+
346
+
347
+ def test_add_waterfall_requires_mapping(client: DatabarClient):
348
+ with pytest.raises(TypeError, match="mapping"):
349
+ client.add_waterfall("tbl-1", waterfall_identifier="person_getter")
350
+
351
+
336
352
  def test_get_table_waterfalls(client: DatabarClient, httpx_mock: HTTPXMock):
337
353
  httpx_mock.add_response(
338
354
  url=f"{BASE_URL}/table/tbl-1/waterfalls",
File without changes
File without changes
File without changes