Metadata-Version: 2.4
Name: revefi-ingestion
Version: 0.1.0b2
Summary: Revefi customer-side metadata ingestion CLI and library, built on OpenMetadata's ingestion framework
Author: Revefi
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Project-URL: Homepage, https://www.revefi.com/
Project-URL: Source, https://github.com/revefi/revefi-ingestion-cli
Keywords: revefi,openmetadata,metadata,ingestion,looker,lineage
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openmetadata-ingestion[looker]==1.13.0.0
Requires-Dist: requests
Requires-Dist: pydantic>=2
Requires-Dist: PyYAML
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: cryptography; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# revefi-ingestion

Revefi's customer-side metadata ingestion library and CLI. It runs an
[OpenMetadata](https://open-metadata.org) connector **inside your network**, under your own BI-tool
admin credentials, and streams discovered metadata to Revefi's ingestion API over HTTPS.
**Your credentials never leave your environment** — Revefi never sees your Looker password, client
secret, or GitHub token.

It is built **on top of** the published `openmetadata-ingestion` framework (pulled in as a
dependency, not forked), so this repository contains only Revefi's own code.

The first supported source is **Looker** (dashboards, looks, explores, and warehouse-table lineage).

## Install

The package pulls in the OpenMetadata ingestion framework, so install it into an **isolated
environment** — not your project/shared venv. Recommended: [`pipx`](https://pipx.pypa.io):

```bash
pipx install "revefi-ingestion[looker]==0.1.0b2"
```

Or a dedicated venv:

```bash
python -m venv ~/.revefi-ingestion
~/.revefi-ingestion/bin/pip install "revefi-ingestion[looker]==0.1.0b2"
```

Requires Python 3.10–3.11. This is a beta — pin the exact `0.1.0bN` version (or pass `--pre`).

## Use as a library (recommended)

Import the module and run ingestion from your own Python script. `run()` returns a `RunResult` on
success and raises `RevefiIngestionError` on failure (after a best-effort abort is delivered):

```python
from revefi_ingestion import (
    LineageOptions,
    LookerCredentials,
    LookerIngestion,
    RevefiIngestionError,
    RevefiTarget,
)

ingestion = LookerIngestion(
    target=RevefiTarget(
        api_url="https://ingest.revefi.com",
        token="<token-from-revefi>",
        # Optional: also write every payload sent to a JSONL file (see "Inspecting what's sent").
        # dump_file="./looker-run.jsonl",
    ),
    looker=LookerCredentials(
        host="https://yourco.cloud.looker.com",
        client_id="<looker-api3-client-id>",
        client_secret="<looker-api3-client-secret>",
    ),
    # Optional: resolve warehouse-table lineage from your LookML (omit for metadata-only).
    lineage=LineageOptions(
        github_repo="yourorg/your-lookml-repo",
        github_token="<github-read-token>",
        db_service_prefixes=["bq_prod"],
        warehouse_type="BigQuery",
    ),
)

try:
    result = ingestion.run()
    print(f"{result.run_id}: {result.status}")
    print(f"  entities: {result.entity_count} in {result.entity_batch_count} batch(es)")
    print(f"  edges:    {result.edge_count} in {result.lineage_batch_count} batch(es)")
    print(f"  failed:   {result.records_failed}")
    for step in result.steps:
        print(f"  {step.name}: {step.processed} processed, {step.failed} failed")
except RevefiIngestionError as exc:
    # Message is already redacted of secrets; the failure was logged and aborted server-side.
    raise SystemExit(f"ingestion failed: {exc}")
```

`dump_file` and `lineage` are both optional. See [What a run reports](#what-a-run-reports) for the
full `RunResult` and [Inspecting what's sent](#inspecting-whats-sent) for the dump file. A complete,
environment-driven version of this script lives in
[`examples/run_ingestion.py`](examples/run_ingestion.py).

A metadata-only run is just the `target` + `looker` arguments:

```python
LookerIngestion(
    target=RevefiTarget(api_url="https://ingest.revefi.com", token="<token-from-revefi>"),
    looker=LookerCredentials(host="...", client_id="...", client_secret="..."),
).run()
```

## Use as a CLI

A `revefi-ingestion` console script wraps the same library.

Metadata-only (no lineage):

```bash
revefi-ingestion looker \
  --api-url   https://ingest.revefi.com \
  --token     <token-from-revefi> \
  --looker-host   https://yourco.cloud.looker.com \
  --client-id     <looker-api3-client-id> \
  --client-secret <looker-api3-client-secret>
```

With warehouse-table lineage (BigQuery example):

```bash
revefi-ingestion looker \
  --api-url   https://ingest.revefi.com \
  --token     <token-from-revefi> \
  --looker-host   https://yourco.cloud.looker.com \
  --client-id     <looker-api3-client-id> \
  --client-secret <looker-api3-client-secret> \
  --github-repo   yourorg/your-lookml-repo \
  --github-token  <github-read-token> \
  --db-service-prefix bq_prod \
  --warehouse-type BigQuery
```

- The `--github-*` and `--db-service-prefix` flags are required to resolve **warehouse-table
  lineage** from your LookML; omit them for metadata-only ingestion.
- `--warehouse-type` (default `BigQuery`; one of `BigQuery`, `Snowflake`, `Redshift`, `Databricks`)
  sets the SQL dialect used to parse your LookML `sql_table_name` references. **Set it to match the
  warehouse your Looker models read from** — a wrong dialect silently produces incorrect lineage.

### Secrets via environment variables

The three secret flags can be supplied as environment variables instead of on the command line, so
they don't end up in your shell history or process list:

| Flag | Environment variable |
|------|----------------------|
| `--token` | `REVEFI_INGEST_TOKEN` |
| `--client-secret` | `LOOKER_CLIENT_SECRET` |
| `--github-token` | `GITHUB_TOKEN` |

If both a flag and its environment variable are set, the flag wins. Run
`revefi-ingestion looker --help` for the full flag list.

### Optional tuning & diagnostics

```bash
revefi-ingestion looker \
  --api-url https://ingest.revefi.com --token <token-from-revefi> \
  --looker-host https://yourco.cloud.looker.com \
  --client-id <id> --client-secret <secret> \
  --dump-file ./looker-run.jsonl \
  --log-level DEBUG \
  --connect-timeout 30 --read-timeout 60 \
  --retry-total 5 --retry-backoff 2.0 \
  --max-batch-entities 100 --max-batch-bytes 204800
```

- `--dump-file PATH` — also write every sent payload to a JSONL file (see below).
- `--log-level` — `DEBUG | INFO | WARNING | ERROR` (default `INFO`).
- `--connect-timeout` / `--read-timeout` — HTTP timeouts, in seconds.
- `--retry-total` / `--retry-backoff` — retry budget for transient failures.
- `--max-batch-entities` / `--max-batch-bytes` — caps per streamed request.

All are optional and default sensibly.

## Inspecting what's sent

Pass `--dump-file PATH` (CLI) or `dump_file="PATH"` on `RevefiTarget` (library) to also write every
payload to a JSONL file. It is optional and **additive** — the run still streams to the API; omit it
and nothing is written.

The first line is a header (the target URL the payloads are POSTed to, plus run metadata); each
following line is one request, serialized **identically to the POST body** (camelCase, unset fields
omitted) — including the message that fails, if one does:

```jsonl
{"type":"run_header","target_url":"https://ingest.revefi.com/api/v1/discovery/ingest","run_id":"3f…","cli_version":"0.1.0b2","written_at":"2026-…"}
{"runId":"3f…","messageSequenceNo":0,"messageType":"BEGIN_RUN","beginRun":{"startTime":"2026-…"}}
{"runId":"3f…","messageSequenceNo":1,"messageType":"ENTITY_BATCH","entityBatch":{"entities":[{"entityType":"CHART","entityJson":"{…}"}]}}
{"runId":"3f…","messageSequenceNo":2,"messageType":"END_ENTITY_RUN","endEntityRun":{"clientEmittedEntityCount":412,"clientEmittedEntityBatchCount":5}}
```

`entityJson` is the OpenMetadata `Create*Request` / `AddLineageRequest` as a nested JSON **string**,
so decode it too when inspecting an entity:

```bash
# message types, in send order:
jq -r 'if .type=="run_header" then "→ "+.target_url else "\(.messageSequenceNo)\t\(.messageType)" end' looker-run.jsonl

# the OM entities inside the first entity batch:
jq -r 'select(.messageType=="ENTITY_BATCH") | .entityBatch.entities[].entityJson' looker-run.jsonl | head -1 | jq .
```

## What a run reports

A run logs progress as it goes (each batch as it's sent, with running totals) and ends with a
summary; the library's `RunResult` carries the same numbers:

```
INFO  Sent entity batch 5: 100 entities (412 entities total)
INFO  Sent lineage batch 3: 20 edges (120 edges total)
INFO  Ingestion run 3f… finished: SUCCESS
INFO    entities published: 412 in 5 batch(es)
INFO    lineage edges published: 120 in 3 batch(es)
INFO    LookerSource: 410 processed, 2 failed, 8 filtered, 0 warning(s)
```

`RunResult` fields:

| Field | Meaning |
|-------|---------|
| `run_id` | Unique id for this run |
| `status` | `SUCCESS`, or `PARTIAL_SUCCESS` if some records failed |
| `entity_count` / `entity_batch_count` | Entities published, and in how many batches |
| `edge_count` / `lineage_batch_count` | Lineage edges published, and in how many batches |
| `records_failed` | Records the workflow could not process (each logged at WARNING) |
| `steps` | Per-step tally: `name`, `processed`, `failed`, `filtered`, `warnings` |

Individual record failures are **not fatal**: they're logged (redacted) and reported via
`records_failed` / `steps`, and the run still publishes what succeeded. A failure that aborts the
whole run (auth, connectivity, or a run that produced nothing) raises `RevefiIngestionError` after a
best-effort abort is delivered to the server.

## How your Looker instance is identified

You don't choose an OpenMetadata "service name" — every run records its Looker metadata under a
fixed internal name, `revefi_looker`. This is deliberate: Looker exposes no instance, account, or
"service" name to read back (unlike Tableau's *site* or Snowflake's *account*), so there is nothing
to name it after. A Looker deployment is identified by its **host URL**.

Your runs are still told apart — by two things, neither of which is that service name:

- **Your ingest token** (`--token`) — Revefi resolves your tenant and integration from the token,
  server-side. The CLI never sends, and never even knows, a tenant or integration id.
- **Your Looker host** (`--looker-host`) — recorded on every message, identifying which Looker
  instance the run came from.

So `revefi_looker` is only an internal namespace label; the identity that actually scopes your data
(who you are, and which Looker instance this is) travels on the token and the host — not on the
service name.

## How it works

`revefi-ingestion` drives OpenMetadata's Looker connector with no OpenMetadata server: a set of
monkey-patches replaces the server-bound calls (entity lookups, owner resolution, usage percentiles)
with synthetic entities, and a custom sink (`revefi-http`) batches the connector's
`Create*Request` / `AddLineageRequest` records and POSTs them to Revefi's ingestion API. The
`revefi-http` sink type is resolved to the bundled sink by patching OpenMetadata's sink importer,
since OpenMetadata is an installed dependency and owns the `metadata.ingestion.sink` namespace.

## Development

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e '.[looker,dev]'
pytest tests/unit -q
```

## License

Apache License 2.0. See [LICENSE](LICENSE). OpenMetadata is used as a dependency under its own
license.
