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

get_models seems broken in 1.8 #172

Closed
1 of 5 tasks
sdebruyn opened this issue Apr 5, 2024 · 4 comments
Closed
1 of 5 tasks

get_models seems broken in 1.8 #172

sdebruyn opened this issue Apr 5, 2024 · 4 comments
Labels
bug Something isn't working triage

Comments

@sdebruyn
Copy link

sdebruyn commented Apr 5, 2024

Steps to reproduce

  1. Install dbt-core 1.8.0b2 with a compatible adapter
  2. Create a new analysis and paste {{ log('repro: ' ~ codegen.get_models(directory='somedir')) }}
  3. Run dbt run -s your_analysis

Expected results

A log with your models

Actual results

Compilation error 'dict object' has no attribute 'nodes'

System information

packages:
  - package: dbt-labs/codegen
    version: 0.12.1

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Core:
  - installed: 1.8.0-b2
  - latest:    1.7.11   - Ahead of latest version!

Plugins:
  - postgres:    1.8.0b1 - Ahead of latest version!
  - timescaledb: 1.8.0b2 - Up to date!

The operating system you're using: macOS

The output of python --version: Python 3.11.8

@sdebruyn sdebruyn added bug Something isn't working triage labels Apr 5, 2024
@gwenwindflower
Copy link
Contributor

thanks @sdebruyn -- we're getting ready to cut a new release next week so we'll dig into this and make sure it gets fixed before we do that! thanks for the heads up!

@gwenwindflower
Copy link
Contributor

hey @sdebruyn were you wrapping that in an if execute tag? wondering if it's just this -- there aren't nodes in the graph in the parsing stage that would typically apply to an analysis file.

@gwenwindflower gwenwindflower closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
@mrhorvath
Copy link

Could the example in the readme (https://github.com/dbt-labs/dbt-codegen?tab=readme-ov-file#generate_model_yaml-source) that uses codegen.get_models be updated to include 'if execute'? As the documentation is written now, it results in the error described in this issue.

@SuaveCharlie
Copy link

SuaveCharlie commented Nov 5, 2024

Could the example in the readme (https://github.com/dbt-labs/dbt-codegen?tab=readme-ov-file#generate_model_yaml-source) that uses codegen.get_models be updated to include 'if execute'? As the documentation is written now, it results in the error described in this issue.

Echoing this, I've got it running in an analysis file by wrapping it in an if execute block, but it then complained that I needed to add -- depends on x which voids the point of using get_models(directory='some_dir')

# analyses/codegen/app_installs.sql

-- depends_on: {{ ref('mobile_app_installs') }}

{% if execute %}
    {% set models_to_generate = codegen.get_models(directory='app_installs') %}
    {{ codegen.generate_model_yaml(
        model_names = models_to_generate,
        upstream_descriptions = true,
        include_data_types = true
    ) }}
{% endif %}

Scratch that, the above doesn't work; it adds duplicate entries to my various yaml files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

4 participants