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

Feature: Add Activity YML Codegen #42

Merged
merged 10 commits into from
Dec 19, 2023

Conversation

awoehrl
Copy link
Contributor

@awoehrl awoehrl commented Dec 15, 2023

Hi @bcodell,

I've tried my luck on a codegen macro for automating the generation of docs and tests for activities (#35). The macro takes a list of activities as input and outputs a model docs yaml file containing the docs and tests for all listed activities and their respective columns. It documents the available keys in the json object as well.

Things to watch out for:

  • I'm using the node graph to get the config for a specific activity. This is used for parsing the data_types object as well as getting the stream name. Maybe there is an easier way to do this, but I couldn't find it in the existing code.
  • I've tried to adhere to your docs format, but it should be checked for clarity as I'm not a native speaker

Example output:

version: 2
models:
  - name: customer__viewed_page
    columns:
      - name: activity_id
        description: "Unique identifier for the activity."
        data_type: STRING
        tests:
          - unique
          - not_null
      - name: customer_id
        description: "Identifier for the customer."
        data_type: STRING
      - name: anonymous_customer_id
        description: "Anonymous identifier for the customer."
        data_type: STRING
        tests:
          - not_null
      - name: activity
        description: "Type of activity performed by the customer."
        data_type: STRING
        tests:
          - not_null
      - name: ts
        description: "Timestamp of when the activity occurred."
        data_type: TIMESTAMP
        tests:
          - not_null
      - name: revenue_impact
        description: "Revenue impact of the activity, if applicable."
        data_type: INT64
      - name: link
        description: "Link associated with the activity, if applicable."
        data_type: STRING
      - name: feature_json
        description: > 
          JSON containing additional feature data related to the activity. Contains the following items:
            - article_id: STRING
      - name: activity_occurrence
        description: "Number of times the activity occurred."
        data_type: INT64
      - name: activity_repeated_at
        description: "Timestamp of when the activity was repeated, if applicable."
        data_type: TIMESTAMP
  - name: customer__bought_subscription
    columns:
      - name: activity_id
        description: "Unique identifier for the activity."
        data_type: STRING
        tests:
          - unique
          - not_null
      - name: customer_id
        description: "Identifier for the customer."
        data_type: STRING
      - name: anonymous_customer_id
        description: "Anonymous identifier for the customer."
        data_type: STRING
        tests:
          - not_null
      - name: activity
        description: "Type of activity performed by the customer."
        data_type: STRING
        tests:
          - not_null
      - name: ts
        description: "Timestamp of when the activity occurred."
        data_type: TIMESTAMP
        tests:
          - not_null
      - name: revenue_impact
        description: "Revenue impact of the activity, if applicable."
        data_type: INT64
      - name: link
        description: "Link associated with the activity, if applicable."
        data_type: STRING
      - name: feature_json
        description: > 
          JSON containing additional feature data related to the activity. Contains the following items:
            - product_id: STRING
            - product_category: STRING
            - product_name: STRING
            - product_price: FLOAT64
      - name: activity_occurrence
        description: "Number of times the activity occurred."
        data_type: INT64
      - name: activity_repeated_at

Let me know what you think!

Resolves #35

Copy link
Owner

@bcodell bcodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @awoehrl thanks for publishing this and nice work! I left some feedback - take a look at the comments. Some changes are necessary, but others suggested by my comments are certainly up for debate. Let me know what thoughts/feedback you have, and I'll take another look at any changes you make once you push them!

macros/activity_schema/activity/generate_activity_yml.sql Outdated Show resolved Hide resolved
macros/activity_schema/activity/generate_activity_yml.sql Outdated Show resolved Hide resolved
macros/activity_schema/activity/generate_activity_yml.sql Outdated Show resolved Hide resolved
macros/activity_schema/activity/generate_activity_yml.sql Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@awoehrl awoehrl changed the title feature: add activity yml codegen Feature: Add Activity YML Codegen Dec 19, 2023
@awoehrl awoehrl requested a review from bcodell December 19, 2023 14:18
Copy link
Owner

@bcodell bcodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 🙌 🎉 🚀

@bcodell
Copy link
Owner

bcodell commented Dec 19, 2023

CI failed because the contributor's forked repo doesn't have access to secrets needed for specific CI steps. I'm merging as there are no code conflicts and the changes should not affect existing functionality.

@bcodell bcodell merged commit 0fbff48 into bcodell:main Dec 19, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature - generate automatic tests for activities
2 participants