Giter VIP home page Giter VIP logo

Comments (10)

grace-cityblock avatar grace-cityblock commented on May 8, 2024 3

@Aylr you have brought to an end WEEKS of frustration. THANK YOU so much for suggesting this. I hadn't played with github actions enough to realize that I could just grab the library and run it that way. I've modified your suggestion slightly to fix my needs (we just need to run one or two checks against files that are modified in a given branch) and we're off and running!


on:
  pull_request:
    branches: [master]

jobs:
  PreCommitChecks:
    name: Run pre-commit checks
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - uses: actions/setup-python@v3
      - id: file_changes
        uses: trilom/[email protected]
        with:
          output: ' '

      - name: Install pre-commit
        run: pip install pre-commit

      - name: Run pre-commit model checks
        run: pre-commit run --files ${{ steps.file_changes.outputs.files}}

from dbt-checkpoint.

nicholas-eden-pp avatar nicholas-eden-pp commented on May 8, 2024 3

This is a year old, is this going to be fixed?

from dbt-checkpoint.

grace-cityblock avatar grace-cityblock commented on May 8, 2024 1

@KristoferNorwood for viz

from dbt-checkpoint.

grace-cityblock avatar grace-cityblock commented on May 8, 2024 1

Requesting suggestions here on above, since I have tried a multitude of things to handle this, including $ARGS in environment variables, checking out the work and comments in PR 48, and hacking my own fork to get around this, but it seems that the github action is escaping the args line as indicated both in @simon-tarr 's comment and in the original readme. By escaping, I mean that it is passing the entire args line as one command (not as a command + flag + argument). The result is that it doesn't recognize what is passed as a command. As an example, even if I pass nothing, it defaults to the "run --all-files" in the actions yaml, and returns this:

usage: pre-commit [-h] [-V]
                  {autoupdate,clean,hook-impl,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,help}
                  ...
pre-commit: error: argument command: invalid choice: 'run --all-files' (choose from 'autoupdate', 'clean', 'hook-impl', 'gc', 'init-templatedir', 'install', 'install-hooks', 'migrate-config', 'run', 'sample-config', 'try-repo', 'uninstall', 'help')

Notice the line invalid choice: 'run --all-files' - it's not seeing it as run with an added flag. @tomsej have you seen this in your development?

from dbt-checkpoint.

andrejakobsen avatar andrejakobsen commented on May 8, 2024 1

I have encountered the same issue as @grace-cityblock with:

pre-commit: error: argument command: invalid choice: 'run --files <FILE PATHS>'

While the solution by @Aylr circumvents the issue, it is frustrating as a new user that this still isn't fixed or documented as a potential problem.

from dbt-checkpoint.

simon-tarr avatar simon-tarr commented on May 8, 2024

Is there a workaround to this bug while a fix is implemented? Thanks!
EDIT - Turns out there is although I'm not sure this is a good work around for everyone. I changed the version of pre-commit-dbt from @v1.0.0 to the latest (as of 23rd Feb 2022) commit. So my main.yml file now looks like:

- name: Build Docs
  uses: offbi/pre-commit-dbt@cc144b9a1a24112428d9a52a66905815990e4554
  env:
    DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
  with:
    args: run --files ${{ steps.file_changes.outputs.files}}

from dbt-checkpoint.

grace-cityblock avatar grace-cityblock commented on May 8, 2024

Is there a workaround to this bug while a fix is implemented? Thanks! EDIT - Turns out there is although I'm not sure this is a good work around for everyone. I changed the version of pre-commit-dbt from @v1.0.0 to the latest (as of 23rd Feb 2022) commit. So my main.yml file now looks like:

- name: Build Docs
  uses: offbi/pre-commit-dbt@cc144b9a1a24112428d9a52a66905815990e4554
  env:
    DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
  with:
    args: run --files ${{ steps.file_changes.outputs.files}}

Thank you for this @simon-tarr! This got me past the reference format issue. I'm still trying to get around passing arguments but that helped a lot.

from dbt-checkpoint.

Aylr avatar Aylr commented on May 8, 2024

@grace-cityblock I've found a workaround you might find useful. I'm not using the dbt-pre-commit GitHub action at all, which doesn't bother me too much since it appears to be a thin wrapper anyway:

Note I'm using the excellent dbt-action pinned to the latest commit on main that fixes a bug that isn't released yet.

jobs:
  PreCommitChecks:
    name: Run pre-commit checks
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: Install dbt dependencies
        uses: mwhitaker/dbt-action@56f1f21c8026df783c17f65743b17855b5be22d9
        with:
          dbt_command: "dbt deps --profiles-dir . --target=dev"

      - name: Build dbt docs  # the dbt pre-commit checks use assets compiled by dbt docs generate
        uses: mwhitaker/dbt-action@56f1f21c8026df783c17f65743b17855b5be22d9
        with:
          dbt_command: "dbt docs generate --profiles-dir . --target=dev"

      - name: Install pre-commit
        run: pip install pre-commit

      - name: Run pre-commit model checks
        run: pre-commit run --all-files

from dbt-checkpoint.

HarelNavina avatar HarelNavina commented on May 8, 2024

checking out the work and comments in PR 48, and hacking my own fork to get around this, but it seems that the github action is escaping the args line as indicated both in @simon-tarr 's comment and in the original readme. By escaping, I mean that it is passing the entire args line as one command (not as a command + flag + argument). The result is that it doesn't recognize what is passed as a command. As an example, even if I pass nothing, it defaults to the "run --all-files" in the actions yaml, and returns this:

I'm facing the exact same issues, it's weird no one has this issue, I was able to replicate it each and every time.

Is there a fix? @tomsej @Aylr @grace-cityblock

Thank you!

from dbt-checkpoint.

alexfetterman avatar alexfetterman commented on May 8, 2024

@grace-cityblock Did you not even need to pass environment variables or put a profiles.yml file up on your dbt repo with the approach you ultimately went with?

from dbt-checkpoint.

Related Issues (20)

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.