Skip to content

Commit

Permalink
chore: Add __main__.py entry point to samples and cookiecutters (#2156
Browse files Browse the repository at this point in the history
)

* chore: Add `__main__.py` entry point to samples and cookiecutters

* Add missing key to replay files
  • Loading branch information
edgarrmondragon authored Jan 18, 2024
1 parent e9f2c17 commit 02f6288
Show file tree
Hide file tree
Showing 31 changed files with 100 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cookiecutter/mapper-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"variant": "None (Skip)",
"include_ci_files": ["GitHub", "None (Skip)"],
"license": ["Apache-2.0"],
"ide": ["VSCode", "None"],
"__prompts__": {
"name": "The name of the mapper, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
"admin_email": "Provide your [bold yellow]email[/]",
"mapper_id": "The ID of the tap, in kebab-case",
"library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
17 changes: 17 additions & 0 deletions cookiecutter/mapper-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python
from pathlib import Path
import shutil


BASE_PATH = Path("{{cookiecutter.library_name}}")


if __name__ == "__main__":
if "{{ cookiecutter.license }}" != "Apache-2.0":
Path("LICENSE").unlink()

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(Path(".github"))

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.mapper import {{ cookiecutter.name }}Mapper

{{ cookiecutter.name }}Mapper.cli()
4 changes: 3 additions & 1 deletion cookiecutter/tap-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"include_ci_files": ["GitHub", "None"],
"license": ["Apache-2.0", "None"],
"ide": ["VSCode", "None"],
"__prompts__": {
"source_name": "The name of the source, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
Expand All @@ -25,6 +26,7 @@
"stream_type": "The type of stream the source provides",
"auth_method": "The [bold red]authentication[/] method used by the source, for REST and GraphQL sources",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
3 changes: 3 additions & 0 deletions cookiecutter/tap-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(".github")

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.source_name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.tap import Tap{{ cookiecutter.source_name }}

Tap{{ cookiecutter.source_name }}.cli()
4 changes: 3 additions & 1 deletion cookiecutter/target-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"serialization_method": ["Per record", "Per batch", "SQL"],
"include_ci_files": ["GitHub", "None (Skip)"],
"license": ["Apache-2.0"],
"ide": ["VSCode", "None"],
"__prompts__": {
"name": "The name of the mapper, in CamelCase",
"admin_name": "Provide your [bold yellow]full name[/]",
Expand All @@ -16,6 +17,7 @@
"library_name": "The name of the library, in snake_case. This is how the library will be imported in Python.",
"serialization_method": "The serialization method to use for loading data",
"include_ci_files": "Whether to include CI files for a common CI services",
"license": "The license for the project"
"license": "The license for the project",
"ide": "Add configuration files for your preferred IDE"
}
}
3 changes: 3 additions & 0 deletions cookiecutter/target-template/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

if "{{ cookiecutter.include_ci_files }}" != "GitHub":
shutil.rmtree(Path(".github"))

if "{{ cookiecutter.ide }}" != "VSCode":
shutil.rmtree(".vscode")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""{{ cookiecutter.destination_name }} entry point."""

from __future__ import annotations

from {{ cookiecutter.library_name }}.target import Target{{ cookiecutter.destination_name }}

Target{{ cookiecutter.destination_name }}.cli()
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/mapper-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"variant": "None (Skip)",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../mapper-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-graphql-jwt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "JWT",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-other-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "Custom or N/A",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-api_key-github.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "API Key",
"include_ci_files": "GitHub",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-basic_auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "Basic Auth",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-bearer_token.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "Bearer Token",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "Custom or N/A",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-jwt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "JWT",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-rest-oauth2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "OAuth2",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/tap-sql-custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"auth_method": "Custom or N/A",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "../tap-template/",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/target-per_record.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"serialization_method": "Per record",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "./sdk/cookiecutter/target-template",
"_output_dir": "."
}
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/cookiecutters/target-sql.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"serialization_method": "SQL",
"include_ci_files": "None (Skip)",
"license": "Apache-2.0",
"ide": "VSCode",
"_template": "./sdk/cookiecutter/target-template",
"_output_dir": "."
}
Expand Down
5 changes: 5 additions & 0 deletions samples/sample_mapper/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_mapper.mapper import StreamTransform

StreamTransform.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_bigquery/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_bigquery import TapBigQuery

TapBigQuery.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_gitlab/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from sample_tap_gitlab.gitlab_tap import SampleTapGitlab

SampleTapGitlab.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_google_analytics/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_google_analytics.ga_tap import SampleTapGoogleAnalytics

SampleTapGoogleAnalytics.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_hostile/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_hostile import SampleTapHostile

SampleTapHostile.cli()
5 changes: 5 additions & 0 deletions samples/sample_tap_sqlite/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from samples.sample_tap_sqlite import SQLiteTap

SQLiteTap.cli()
5 changes: 5 additions & 0 deletions samples/sample_target_parquet/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from sample_target_parquet.parquet_target import SampleTargetParquet

SampleTargetParquet.cli()

0 comments on commit 02f6288

Please sign in to comment.