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

Trigger hub build conditionally #401

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/docusaurus-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ name: Deploy Docusaurus with GitHub Pages dependencies preinstalled
on:
# Runs on pushes targeting the default branch & contrib subdirectory
push:
branches: ["user_contrib", "main"]
paths:
- 'contrib/**'

Expand All @@ -25,7 +24,7 @@ concurrency:

jobs:
branch-build:
if: GITHUB_REF_NAME != 'main'
if: ${{ github.ref != 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down Expand Up @@ -64,7 +63,7 @@ jobs:
run: yarn build
# 👆 Build steps
deploy:
if: GITHUB_REF_NAME == 'main'
if: ${{ github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions contrib/hamilton/contrib/user/skrawcz/author.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# skrawcz

Hi I'm Stefan Krawczyk. I am on of the co-creators of Hamilton.

# Github
https:/skrawcz
# Linkedin
https://www.linkedin.com/in/skrawczyk
# X (Twitter)
https://www.twitter.com/stefkrawczyk
14 changes: 14 additions & 0 deletions contrib/hamilton/contrib/user/skrawcz/hello_world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Purpose of this module

This module implements a hello world dataflow to show transforming columns from a dataframe.

You can pass in your own values for spend & signups, or use the default.

# Configuration Options
This module can be configured with the following options:
- {"default": "True"} to run it without any inputs.
- {} to have to pass in `spend` and `signups`.

# Limitations

None to really note.
66 changes: 66 additions & 0 deletions contrib/hamilton/contrib/user/skrawcz/hello_world/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import logging

logger = logging.getLogger(__name__)

from hamilton import contrib

with contrib.catch_import_errors(__name__, __file__, logger):
import pandas as pd

from hamilton.function_modifiers import config, extract_columns


@extract_columns("spend", "signups")
@config.when(default="True")
def default_data() -> pd.DataFrame:
return pd.DataFrame(
{
"signups": pd.Series([1, 10, 50, 100, 200, 400]),
"spend": pd.Series([10, 10, 20, 40, 40, 50]),
}
)


def avg_3wk_spend(spend: pd.Series) -> pd.Series:
"""Rolling 3 week average spend."""
return spend.rolling(3).mean()


def spend_per_signup(spend: pd.Series, signups: pd.Series) -> pd.Series:
"""The cost per signup in relation to spend."""
return spend / signups


def spend_mean(spend: pd.Series) -> float:
"""Shows function creating a scalar. In this case it computes the mean of the entire column."""
return spend.mean()


def spend_zero_mean(spend: pd.Series, spend_mean: float) -> pd.Series:
"""Shows function that takes a scalar. In this case to zero mean spend."""
return spend - spend_mean


def spend_std_dev(spend: pd.Series) -> float:
"""Function that computes the standard deviation of the spend column."""
return spend.std()


def spend_zero_mean_unit_variance(spend_zero_mean: pd.Series, spend_std_dev: float) -> pd.Series:
"""Function showing one way to make spend have zero mean and unit variance."""
return spend_zero_mean / spend_std_dev


if __name__ == "__main__":
# run as a script to test Hamilton's execution
import __init__ as hello_world

from hamilton import base, driver

dr = driver.Driver(
{"default": "True"},
hello_world,
adapter=base.DefaultAdapter(),
)
# create the DAG image
dr.display_all_functions("dag", {"format": "png", "view": False})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pandas
7 changes: 7 additions & 0 deletions contrib/hamilton/contrib/user/skrawcz/hello_world/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"schema": "1.0",
"use_case_tags": ["example", "transformation"],
"secondary_tags": {
"dataframe-library": "pandas"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"description": "Default way to run the dataflow.", "name": "default", "config": {"default": "True"}}
{"description": "Bring your own spend & signup values.", "name": "bring-your-own", "config": {}}