-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Simpler Examples, generate examples pages from actual examples …
…code (#1134) * start migrating examples * restore chess dbt example * bring examples into desired shape * generate example pages from existing examples using docstrings * fix one md link * post merge file delete * add some notes for test vars * move chess example back into examples folder * skip examples without proper header * separate examples testing into own make command * prepare tests for examples and run them * fix examples test setup * add postgres dependency to snippets tests * ignore some folders * add argparse plus clear flag to example test preparation make examples raise in case of failed loads * simplify example folder skipping * add a template for a new example * fix bug in deployment * update contributing
- Loading branch information
Showing
80 changed files
with
699 additions
and
1,723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
--- | ||
title: Example Template | ||
description: Add desciption here | ||
keywords: [example] | ||
--- | ||
This is a template for a new example. This text will show up in the docs. | ||
With this example you will learn to: | ||
* One | ||
* two | ||
* Three | ||
""" | ||
|
||
import dlt | ||
|
||
if __name__ == "__main__": | ||
# run a pipeline | ||
pipeline = dlt.pipeline( | ||
pipeline_name="example_pipeline", destination="duckdb", dataset_name="example_data" | ||
) | ||
# Extract, normalize, and load the data | ||
load_info = pipeline.run([1, 2, 3], table_name="player") | ||
print(load_info) | ||
|
||
# make sure nothing failed | ||
load_info.raise_on_failed_jobs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chess_url="https://api.chess.com/pub/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import pytest | ||
from unittest.mock import patch | ||
|
||
from dlt.common.configuration.container import Container | ||
from dlt.common.configuration.providers import ( | ||
ConfigTomlProvider, | ||
EnvironProvider, | ||
SecretsTomlProvider, | ||
StringTomlProvider, | ||
) | ||
from dlt.common.configuration.specs.config_providers_context import ( | ||
ConfigProvidersContext, | ||
) | ||
from dlt.common.utils import set_working_dir | ||
|
||
from tests.utils import ( | ||
patch_home_dir, | ||
autouse_test_storage, | ||
preserve_environ, | ||
duckdb_pipeline_location, | ||
wipe_pipeline, | ||
) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def setup_secret_providers(request): | ||
"""Creates set of config providers where tomls are loaded from tests/.dlt""" | ||
secret_dir = "./.dlt" | ||
dname = os.path.dirname(request.module.__file__) | ||
config_dir = dname + "/.dlt" | ||
|
||
# inject provider context so the original providers are restored at the end | ||
def _initial_providers(): | ||
return [ | ||
EnvironProvider(), | ||
SecretsTomlProvider(project_dir=secret_dir, add_global_config=False), | ||
ConfigTomlProvider(project_dir=config_dir, add_global_config=False), | ||
] | ||
|
||
glob_ctx = ConfigProvidersContext() | ||
glob_ctx.providers = _initial_providers() | ||
|
||
with set_working_dir(dname), Container().injectable_context(glob_ctx), patch( | ||
"dlt.common.configuration.specs.config_providers_context.ConfigProvidersContext.initial_providers", | ||
_initial_providers, | ||
): | ||
# extras work when container updated | ||
glob_ctx.add_extras() | ||
yield | ||
|
||
|
||
def pytest_configure(config): | ||
# push sentry to ci | ||
os.environ["RUNTIME__SENTRY_DSN"] = ( | ||
"https://[email protected]/4504819859914752" | ||
) |
Oops, something went wrong.