dbt-core icon indicating copy to clipboard operation
dbt-core copied to clipboard

[CT-3560] Remove usage of flags and tracking in WritableManifest

Open MichelleArk opened this issue 1 year ago • 0 comments

Housekeeping

  • [X] I am a maintainer of dbt-core

Short description

Remove usage of dbt.tracking and dbt.flags from dbt/artifacts/schemas/manifest.py. If they were to be left in, these would represent a dependency on dbt internals from an upstream component, and it could not be packaged separately.

Current usage: https://github.com/dbt-labs/dbt-core/pull/9377/files#diff-a0f1c7a8ab56c28a02547801a741a8139854ac72e0e2e8b556f9ebb7d5b9f7ffR15-R16

Acceptance criteria

dbt/artifacts does not contain imports or usage of dbt.tracking or dbt.flags.

Impact to Other Teams

N/A - should be a refactor.

Will backports be required?

nope

Context

  • The usage of flags here is quite minimal. get_flags().SEND_ANONYMOUS_USAGE_STATS is used as a reference to a global. It could instead be obtained by:

    • having the core caller set send_anonymous_usage_stats based on the global value instead of relying on the post_init
    • https://github.com/dbt-labs/dbt-core/pull/9377/files#diff-a0f1c7a8ab56c28a02547801a741a8139854ac72e0e2e8b556f9ebb7d5b9f7ffR78
  • tracking usage is similar: tracking.active_user.id is referenced as a global when it could be set when the caller provides user_id

    • https://github.com/dbt-labs/dbt-core/pull/9377/files#diff-a0f1c7a8ab56c28a02547801a741a8139854ac72e0e2e8b556f9ebb7d5b9f7ffR75
  • only one callsite for WritableManifest instantiation: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/contracts/graph/manifest.py#L1031

  • Testing: ensure tests exist for setting of user_id and anonymous_usage_stats on manifest.json artifact

MichelleArk avatar Jan 16 '24 17:01 MichelleArk