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

feat: create new rest dlt factory #2663

Merged
merged 10 commits into from
Dec 21, 2024
Merged

feat: create new rest dlt factory #2663

merged 10 commits into from
Dec 21, 2024

Conversation

Jabolol
Copy link
Contributor

@Jabolol Jabolol commented Dec 18, 2024

This PR closes #2396, closes #619, closes #2665, closes #2666 by creating a new factory: create_rest_factory_asset. It uses dlt's REST API source under the hood, abstracting all our infrastructure-specific details, so that new contributors can add new sources effortlessly. Usage is as follows:

Tip

For the full reference, check dlt docs.

config: RESTAPIConfig = {
    "client": {
        "base_url": "https://api.llama.fi/",
    },
    "resources": list(
        map(
            lambda protocol: {
                "name": f"{protocol.replace('-', '_')}",
                "endpoint": {
                    "path": f"protocol/{protocol}",
                    "data_selector": "$",
                },
            },
            DEFI_LLAMA_PROTOCOLS,
        )
    ),
}

dlt_assets = create_rest_factory_asset(
    config=config,
)

defillama_tvl_assets = dlt_assets(
    key_prefix=["defillama", "tvl"],
)

This will create new assets, such as defillama/tvl/aave-v3, which will fetch the endpoint and automatically upload the new source data to BigQuery. Since it uses dlt_factory under the hood, all the concurrency, tags, etc. implementations are available out of the box.

Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kariba-network ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:47pm
oso-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2024 9:47pm

Copy link

@oso-prs oso-prs bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved! please merge responsibly 😄

@oso-prs
Copy link

oso-prs bot commented Dec 18, 2024

Test deployment unnecessary, no dbt files have been changed.

@Jabolol Jabolol deployed to external-prs-app December 21, 2024 21:43 — with GitHub Actions Active
@Jabolol Jabolol added this pull request to the merge queue Dec 21, 2024
Merged via the queue into main with commit dc09f83 Dec 21, 2024
9 checks passed
@Jabolol Jabolol deleted the jabolol/defillama-tvl branch December 21, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants