Giter Club home page Giter Club logo

dbt-cloud-cli's People

Contributors

b-per avatar datamie-simo avatar ernestoongaro avatar jeremyyeo avatar lefthanded78 avatar runar-alvseike avatar stumelius avatar tonayya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dbt-cloud-cli's Issues

issue installing latest version No module named 'dbt_cloud.command'

See below - installed 0.3, worked fine, then 0.5, not fine!

0.30 - works fine:

(env) ernesto@Ernesto-Ongaro dbt_cloud_api % python3 -m pip install dbt-cloud-cli==0.3.0
Collecting dbt-cloud-cli==0.3.0
Using cached dbt_cloud_cli-0.3.0-py3-none-any.whl (15 kB)
Requirement already satisfied: requests in ./env/lib/python3.9/site-packages (from dbt-cloud-cli==0.3.0) (2.27.1)
Requirement already satisfied: click in ./env/lib/python3.9/site-packages (from dbt-cloud-cli==0.3.0) (8.0.3)
Requirement already satisfied: mergedeep in ./env/lib/python3.9/site-packages (from dbt-cloud-cli==0.3.0) (1.3.4)
Requirement already satisfied: pydantic in ./env/lib/python3.9/site-packages (from dbt-cloud-cli==0.3.0) (1.9.0)
Requirement already satisfied: typing-extensions>=3.7.4.3 in ./env/lib/python3.9/site-packages (from pydantic->dbt-cloud-cli==0.3.0) (4.0.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli==0.3.0) (1.26.8)
Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli==0.3.0) (2021.10.8)
Requirement already satisfied: idna<4,>=2.5 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli==0.3.0) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli==0.3.0) (2.0.10)
Installing collected packages: dbt-cloud-cli
Attempting uninstall: dbt-cloud-cli
Found existing installation: dbt-cloud-cli 0.4.0
Uninstalling dbt-cloud-cli-0.4.0:
Successfully uninstalled dbt-cloud-cli-0.4.0
Successfully installed dbt-cloud-cli-0.3.0
(env) ernesto@Ernesto-Ongaro dbt_cloud_api % dbt-cloud
Usage: dbt-cloud [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.

Commands:
job
run

Then 0.5.0:
(env) ernesto@Ernesto-Ongaro dbt_cloud_api % python3 -m pip install dbt-cloud-cli --upgrade
Requirement already satisfied: dbt-cloud-cli in ./env/lib/python3.9/site-packages (0.3.0)
Collecting dbt-cloud-cli
Using cached dbt_cloud_cli-0.5.0-py3-none-any.whl (13 kB)
Requirement already satisfied: mergedeep in ./env/lib/python3.9/site-packages (from dbt-cloud-cli) (1.3.4)
Requirement already satisfied: requests in ./env/lib/python3.9/site-packages (from dbt-cloud-cli) (2.27.1)
Requirement already satisfied: click in ./env/lib/python3.9/site-packages (from dbt-cloud-cli) (8.0.3)
Requirement already satisfied: pydantic in ./env/lib/python3.9/site-packages (from dbt-cloud-cli) (1.9.0)
Requirement already satisfied: typing-extensions>=3.7.4.3 in ./env/lib/python3.9/site-packages (from pydantic->dbt-cloud-cli) (4.0.1)
Requirement already satisfied: idna<4,>=2.5 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli) (2021.10.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli) (1.26.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./env/lib/python3.9/site-packages (from requests->dbt-cloud-cli) (2.0.10)
Installing collected packages: dbt-cloud-cli
Attempting uninstall: dbt-cloud-cli
Found existing installation: dbt-cloud-cli 0.3.0
Uninstalling dbt-cloud-cli-0.3.0:
Successfully uninstalled dbt-cloud-cli-0.3.0
Successfully installed dbt-cloud-cli-0.5.0
(env) ernesto@Ernesto-Ongaro dbt_cloud_api % dbt-cloud
Traceback (most recent call last):
File "/Users/ernesto/Dev/dbt_cloud_api/env/bin/dbt-cloud", line 5, in
from dbt_cloud.cli import dbt_cloud
File "/Users/ernesto/Dev/dbt_cloud_api/env/lib/python3.9/site-packages/dbt_cloud/init.py", line 1, in
from .command import DbtCloudRunStatus
ModuleNotFoundError: No module named 'dbt_cloud.command'
(env) ernesto@Ernesto-Ongaro dbt_cloud_api %

Support Export and Import jobs as files

Will this allow to export jobs to file and import them again? Getting users moving from single-tenant to multi-tenant dbt cloud (and vice versa) this would be ๐Ÿคค

Unable to create a job using dbt-cloud job create command in command-line

I am trying to create a job. But it is throwing an error with the execute steps parameter.
The following is my command -
dbt-cloud job create --project-id 241666 --environment-id 188496 --name "NewJob" --execute-steps ["dbt run"]

Following is the error that it is throwing:
Error: Invalid value for '--execute-steps': [dbt run]

I was initially trying to create a job using the dbt API by sending a post request which was also not working. The response shows that various parameter values in the request body are not valid. It would be great if someone could help me with the API problem as well. We are trying to automatically create jobs on the go based on a few parameters but manually doing that using API itself is not working.

Newly released Pydantic version has a breaking change in dbt-cloud-cli

Following the new version of Pydantic provides an breaking change in dbt-cloud-cli.

Running dbt-cloud job <arguments> provides the following traceback:
pydantic.errors.PydanticUserError: The fieldandconfigparameters are not available in Pydantic V2, please use theinfo parameter instead.

Specifying dbt-cloud-host in cli not working while using Env works properly

When specifying the dbt-cloud-host (e.g. emea.dbt.com) in the cli-arguments when starting a job, the job is started with the correct url.
BUT the loop for checking the run-state does not use the overridden host, but the default host cloud.getdbt.com, causing the check to fail with:

Traceback (most recent call last):
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/bin/dbt-cloud", line 8, in <module>
    sys.exit(dbt_cloud())
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/dbt_cloud/cli.py", line 117, in run
    status = DbtCloudRunStatus(response.json()["data"]["status"])
TypeError: 'NoneType' object is not subscriptable

By drilling through the code, I found out, that the root problem was a <Response [401]>, while getting the run-state, because the API of cloud.getdbt.com is accessed where the used token is not valid.

Changing the cli.py (lines 109 - 114) from:

            run_get_command = DbtCloudRunGetCommand(
                api_token=command.api_token,
                account_id=command.account_id,
                run_id=run_id
            )

to

            run_get_command = DbtCloudRunGetCommand(
                api_token=command.api_token,
                account_id=command.account_id,
                dbt_cloud_host=command.dbt_cloud_host,
                run_id=run_id
            )

solves the problem. I'm double hefthanded and a python-novice and therefore not quite sure if it is the right place to fix this issue.

Allow `dbt-cloud metadata query` to accept the query as stdin/inline string

First of all, thanks a lot for the work here, this is amazing.

I have been looking at dbt-cloud metadata query and was expecting to be able to run a query like:

dbt-cloud metadata query '{
  model(jobId: xxxxx, uniqueId:"xxxx") {
    name
    uniqueId
    type
    jobId
  }
}'

but it returned Error: Got unexpected extra argument ({ ........})

I was able to run the query by saving it in a file and using -f file_name though.

Is there a way to run a metadata query inline or is the only way with -f ? My use case was to get all the jobs with dbt-cloud job list and pipe this list with xargs to run a metadata query for each job.

If this is not possible today, would you be OK with a contribution to make it possible?

How to set up and use

It's unclear from the README and other artifacts in the repo (or from a google search) how to actually set up and use this package. In my case I'm working in MacOS Ventura.

I have used the command python3 -m pip install dbt-cloud-cli to install the package via terminal (running zsh) as suggested in [the blog post](https://docs.getdbt.com/blog/making-dbt-cloud-api-calls-using-dbt-cloud-cli. However, I am not able to invoke dbt-cloud from the CLI as the blog post seems to suggest.

dbt-cloud job create --settings-threads is not working

Passing --settings-threads 4 to dbt-cloud job create results in a job with 1 thread (default). Nested pydantic args are not properly translated from click options and therefore the thread value does not get passed to the pydantic model. This affects all nested arguments in dbt-cloud job create.

>> dbt-cloud job create --project-id 26597 --environment-id 49819 --name "Test nested args" --settings-threads 4 --execute-steps "dbt seed"
{
  "status": {
    "code": 201,
    "is_success": true,
    "user_message": "Success!",
    "developer_message": ""
  },
  "data": {
    "execution": {
      "timeout_seconds": 0
    },
    "generate_docs": false,
    "run_generate_sources": false,
    "id": 48534,
    "account_id": REDACTED,
    "project_id": 26597,
    "environment_id": 49819,
    "name": "Test nested args",
    "dbt_version": null,
    "created_at": "2021-12-27T08:15:22.470119+00:00",
    "updated_at": "2021-12-27T08:15:22.470140+00:00",
    "execute_steps": [
      "dbt seed"
    ],
    "state": 1,
    "deferring_job_definition_id": null,
    "lifecycle_webhooks": false,
    "lifecycle_webhooks_url": null,
    "triggers": {
      "github_webhook": false,
      "git_provider_webhook": null,
      "custom_branch_only": false,
      "schedule": false
    },
    "settings": {
      "threads": 1,
      "target_name": "default"
    },
    "schedule": {
      "cron": "0 * * * *",
      "date": {
        "type": "every_day"
      },
      "time": {
        "type": "every_hour",
        "interval": 1
      }
    },
    "is_deferrable": false,
    "generate_sources": false,
    "cron_humanized": "Every hour",
    "next_run": null,
    "next_run_humanized": null
  }
}

support single tenant dbt cloud deployments

dbt Cloud can be deployed either multi-tenant (i.e url is cloud.getdbt.com) or single-tenant, where a customer chooses their own url (like cloud.customer.getdbt.com) a bit more about it here

Descriptive error messages when environment variables are not defined

>> docker run datamie/dbt-cloud-cli:latest account list
Traceback (most recent call last):
  File "/usr/local/bin/dbt-cloud", line 8, in <module>
    sys.exit(dbt_cloud())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/dbt_cloud/cli.py", line 346, in list
    command = DbtCloudAccountListCommand.from_click_options(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/dbt_cloud/command/command.py", line 87, in from_click_options
    return cls(**kwargs_translated)
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1038, in pydantic.main.validate_model
  File "pydantic/fields.py", line 840, in pydantic.fields.ModelField.validate
  File "pydantic/fields.py", line 1121, in pydantic.fields.ModelField._apply_validators
  File "pydantic/class_validators.py", line 284, in pydantic.class_validators._generic_validator_cls.lambda5
  File "/usr/local/lib/python3.9/site-packages/dbt_cloud/command/command.py", line 80, in field_not_none
    return field.default_factory()
  File "/usr/local/lib/python3.9/site-packages/dbt_cloud/field.py", line 21, in <lambda>
    default_factory=lambda: os.environ["DBT_CLOUD_API_TOKEN"],
  File "/usr/local/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'DBT_CLOUD_API_TOKE`N

Unable to send multiple dbt commands for dbt-cloud job run command

I am trying to invoke a dbt job with multiple dbt commands but I am unable to do it. I am facing the below error:

["dbt deps", "dbt compile"]
Traceback (most recent call last):
File "C:\Users\ArunT\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\ArunT\Anaconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\ArunT\Anaconda3\Scripts\dbt-cloud.exe_main
.py", line 7, in
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 829, in call
return self.main(*args, **kwargs)
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\ArunT\Anaconda3\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\ArunT\Anaconda3\lib\site-packages\dbt_cloud\cli.py", line 106, in run
run_id = response.json()["data"]["id"]
KeyError: 'id'

I am trying to use Bash Terminal in windows and Python Version 3.8.8.

I have checked the python code and it is expecting python list of string, so i tried all the possible ways to send the array in bash to that list but unable to get that working.

Is this supported ? If yes what is the appropriate way to send multiple dbt commands from Bash to dbt job run command?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.