Skip to content

Commit

Permalink
add main clause
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Oct 2, 2023
1 parent ceb3fa1 commit c6a503c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
17 changes: 9 additions & 8 deletions docs/examples/transformers/pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ def species(pokemon: TDataItem):
def source():
return [pokemon_list | pokemon, pokemon_list | pokemon | species]

# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)

# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
if __name__ == "__main__":
# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)

# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ def get_pages(


# @@@DLT_SNIPPET_START markdown_pipeline
# create dlt pipeline
pipeline = dlt.pipeline(
pipeline_name="zendesk", destination="duckdb", dataset_name="zendesk_data"
)

load_info = pipeline.run(zendesk_support())
print(load_info)
__name__ = "__main__" # @@@DLT_REMOVE
if __name__ == "__main__":
# create dlt pipeline
pipeline = dlt.pipeline(
pipeline_name="zendesk", destination="duckdb", dataset_name="zendesk_data"
)

load_info = pipeline.run(zendesk_support())
print(load_info)
# @@@DLT_SNIPPET_END markdown_pipeline
# @@@DLT_SNIPPET_END example

Expand Down
16 changes: 9 additions & 7 deletions docs/website/docs/examples/transformers/code/pokemon-snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ def species(pokemon: TDataItem):
def source():
return [pokemon_list | pokemon, pokemon_list | pokemon | species]

# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)
__name__ = "__main__" # @@@DLT_REMOVE
if __name__ == "__main__":
# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)

# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
# @@@DLT_SNIPPET_END example

# test assertions
Expand Down
17 changes: 9 additions & 8 deletions docs/website/docs/examples/transformers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ def species(pokemon: TDataItem):
def source():
return [pokemon_list | pokemon, pokemon_list | pokemon | species]

# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)

# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
if __name__ == "__main__":
# build duck db pipeline
pipeline = dlt.pipeline(
pipeline_name="pokemon", destination="duckdb", dataset_name="pokemon_data"
)

# the pokemon_list resource does not need to be loaded
load_info = pipeline.run(source())
print(load_info)
```
<!--@@@DLT_SNIPPET_END ./code/pokemon-snippets.py::example-->

Expand Down

0 comments on commit c6a503c

Please sign in to comment.