amrox / asdf-pyapp

A generic Python Application plugin the asdf version manager.
MIT License
58 stars 5 forks source link

dbt support #11

Open jtzero opened 2 years ago

jtzero commented 2 years ago

Is your feature request related to a problem? Please describe.

The linking doesn't seem to work with DBT, and as dbt isn't in the list of Compatible Python Applications I'm assuming it's not "officially" supported, and thus a feature and not a bug.

Describe the solution you'd like

the dbt command available as a shim

asdf plugin add dbt-snowflake https://github.com/amrox/asdf-pyapp.git ls ~/.asdf/installs/dbt-snowflake/1.0.0rc1/venv/bin lists dbt as a binary there ls ~/.asdf/installs/dbt-snowflake/1.0.0rc1/bin but is not linked here, thus no shim

perhaps because the egg/wheel is named dbt-snowflake and not just dbt ? (not sure haven't verified in the code as of yet, and not sure if this is something you would want to officially support)

Describe alternatives you've considered

I could set up another asdf plugin exclusively for dbt.

Additional context

amrox commented 2 years ago

Hi @jtzero - thanks for the feature request.

I'm not too familiar with dbt / dbt-snowflake. What is the "normal" way to install it? Does it work with pipx?

This plugin uses pipx under the hood, so if it works with pipx, but not with this plugin, I'd consider it a bug.

I'm interested in supporting it if we can though!

amrox commented 2 years ago

dug into this a little.

Installing dbt via pipx yields this:

❯ pipx install dbt
Note: Dependent package 'dbt-core' contains 1 apps
  - dbt
Note: Dependent package 'sqlparse' contains 1 apps
  - sqlformat
Note: Dependent package 'chardet' contains 1 apps
  - chardetect
Note: Dependent package 'babel' contains 1 apps
  - pybabel
Note: Dependent package 'python-slugify' contains 1 apps
  - slugify
Note: Dependent package 'jsonschema' contains 1 apps
  - jsonschema
Note: Dependent package 'jmespath' contains 1 apps
  - jp.py
Note: Dependent package 'docutils' contains 12 apps
  - rst2html.py
  - rst2html4.py
  - rst2html5.py
  - rst2latex.py
  - rst2man.py
  - rst2odt.py
  - rst2odt_prepstyles.py
  - rst2pseudoxml.py
  - rst2s5.py
  - rst2xetex.py
  - rst2xml.py
  - rstpep2html.py
Note: Dependent package 'snowflake-connector-python' contains 4 apps
  - snowflake-dump-certs
  - snowflake-dump-ocsp-response
  - snowflake-dump-ocsp-response-cache
  - snowflake-export-certs
Note: Dependent package 'pyjwt' contains 1 apps
  - pyjwt
Note: Dependent package 'keyring' contains 1 apps
  - keyring
Note: Dependent package 'rsa' contains 6 apps
  - pyrsa-decrypt
  - pyrsa-encrypt
  - pyrsa-keygen
  - pyrsa-priv2pub
  - pyrsa-sign
  - pyrsa-verify

No apps associated with package dbt. Try again with '--include-deps' to
include apps of dependent packages, which are listed above. If you are
attempting to install a library, pipx should not be used. Consider using pip
or a similar tool instead."

Next I tried installing dbt-core:

❯ pipx install dbt-core
  installed package dbt-core 1.0.0, Python 3.10.0
  These apps are now globally available
    - dbt
⚠️  Note: '/Users/amrox/.local/bin' is not on your PATH environment variable. These apps will
    not be globally accessible until your PATH is updated. Run `pipx ensurepath` to
    automatically add it, or manually modify your PATH in your shell's config file (i.e.
    ~/.bashrc).
done! ✨ 🌟 ✨

And it worked!

Finally:

❯ asdf plugin add dbt-core https://github.com/amrox/asdf-pyapp.git
❯ asdf install dbt-core 1.0.0
❯ ls ~/.asdf/installs/dbt-core/1.0.0/bin
dbt

So there are a couple ways forward:

  1. Add support for --include-deps in asdf-pyapp (probably should be optional somehow).

  2. Install dbt-core - but I'm not sure this has all the dependencies you need.

jtzero commented 2 years ago

interesting...