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

add secrets format option to dlt deploy #401

Merged
merged 8 commits into from
Jun 15, 2023
Merged

Conversation

sh-rp
Copy link
Collaborator

@sh-rp sh-rp commented Jun 12, 2023

Partly implements: #368

the deploy command for airflow-composer now includes a secrets-format option:
dlt deploy stripe_analytics_pipeline.py airflow-composer --secrets-format toml

which will result in a env output of the following if env or secrets are present:

3. Add the following toml-string to the Airflow UI as the dlt_secrets_toml variable.

[sources.stripe_analytics]
stripe_secret_key = "sk_test_51N0..."

@netlify
Copy link

netlify bot commented Jun 12, 2023

Deploy Preview for dlt-hub-docs ready!

Name Link
🔨 Latest commit cc3155d
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/648acbfb89cc6b0008de2b5d
😎 Deploy Preview https://deploy-preview-401--dlt-hub-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

dlt/cli/_dlt.py Outdated

# deploy airflow composer
deploy_airlow_cmd = deploy_sub_parsers.add_parser(DeploymentMethods.airflow_composer.value, help="Deploys the pipeline to Airflow")
deploy_airlow_cmd.add_argument("--secrets-format", default=SecretFormats.env, choices=[v.value for v in SecretFormats.__members__.values()], required=False, help="Format of the secrets")
Copy link
Contributor

Choose a reason for hiding this comment

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

you can iterate right over SecretFormats
[v.value for v in SecretFormats]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cool thanks :)

self._echo_envs()
elif self.secrets_format == SecretFormats.toml.value:
# build toml
fmt.echo(f"3. Add the following toml-string to the Airflow UI as the {SECRETS_TOML_KEY} variable.")
Copy link
Contributor

Choose a reason for hiding this comment

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

probably "using Google Composer UI", we don't configure Airflow directly. but i'm not sure how exactly

@@ -42,14 +42,7 @@ def list_verified_sources_command_wrapper(repo_location: str, branch: str) -> in


@utils.track_command("deploy", False, "deployment_method")
def deploy_command_wrapper(
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the deployment_method still passed? from my understanding this one and pipeline_script_name must be always present so please declare them explicitly,

Copy link
Collaborator

Choose a reason for hiding this comment

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

also location and branch are always present

dlt/cli/_dlt.py Outdated
@@ -285,7 +281,7 @@ def main() -> int:
else:
return init_command_wrapper(args.source, args.destination, args.generic, args.location, args.branch)
elif args.command == "deploy":
return deploy_command_wrapper(args.pipeline_script_path, args.deployment_method, args.schedule, args.run_on_push, args.run_manually, args.location, args.branch)
return deploy_command_wrapper(**vars(args))
Copy link
Collaborator

Choose a reason for hiding this comment

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

the code is shorter but way harder to understand. IMO. some parameters are expected and should be explicitly passed

run_on_dispatch: bool,
repo_location: str,
branch: Optional[str] = None,
def deploy_command(deployment_method: str, **kwargs: Any
Copy link
Collaborator

Choose a reason for hiding this comment

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

same thing here

# build toml
fmt.echo(f"3. Add the following toml-string to the Airflow UI as the {SECRETS_TOML_KEY} variable.")
fmt.echo()
toml_provider = MemoryTomlProvider("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can absolutely rename it!

@sh-rp sh-rp force-pushed the d#/368-better-deploy-cli branch 2 times, most recently from 1597716 to 113d70c Compare June 14, 2023 09:14
@rudolfix rudolfix mentioned this pull request Jun 15, 2023
@rudolfix rudolfix merged commit 92ae7d7 into devel Jun 15, 2023
27 checks passed
@rudolfix rudolfix deleted the d#/368-better-deploy-cli branch June 15, 2023 08:38
rudolfix added a commit that referenced this pull request Jun 15, 2023
* add secrets format option to dlt deploy

* fix linting

* fix bug with missing args and separate github actions specific args out

* pr fixes

* fix test

* improves deploy tests, fixes toml  problem

* fixes windows timer races due to low resolution: tx file tests

* landing page for deploy a pipeline section

---------

Co-authored-by: Marcin Rudolf <rudolfix@rudolfix.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants