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

Add featureset spec for test #2960

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- sdk/python/dev-requirements.txt
- infra/bootstrapping/**
- sdk/python/setup.sh
- sdk/python/featurestore_sample
- sdk/python/featurestore_sample/**
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- sdk/python/dev-requirements.txt
- infra/bootstrapping/**
- sdk/python/setup.sh
- sdk/python/featurestore_sample
- sdk/python/featurestore_sample/**
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- sdk/python/dev-requirements.txt
- infra/bootstrapping/**
- sdk/python/setup.sh
- sdk/python/featurestore_sample
- sdk/python/featurestore_sample/**
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -32,7 +32,7 @@ jobs:
- name: setup python
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"
- name: pip install notebook reqs
run: pip install -r sdk/python/dev-requirements.txt
- name: azure login
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
feature_transformation:
transformation_code:
path: ./transformation_code
transformer_class: transaction_transform.TransactionFeatureTransformer
features:
- name: transaction_3d_count
type: long
- name: transaction_amount_3d_sum
type: double
- name: transaction_amount_3d_avg
type: double
- name: transaction_7d_count
type: long
- name: transaction_amount_7d_sum
type: double
- name: transaction_amount_7d_avg
type: double
index_columns:
- name: accountID
type: string
source:
path: wasbs://[email protected]/feature-store-prp/datasources/transactions-source/*.parquet
source_delay:
days: 0
hours: 0
minutes: 20
timestamp_column:
name: timestamp
type: parquet
source_lookback:
days: 7
hours: 0
minutes: 0
temporal_join_lookback:
days: 1
hours: 0
minutes: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from pyspark.sql import functions as F
fredms marked this conversation as resolved.
Show resolved Hide resolved
from pyspark.sql.window import Window
from pyspark.ml import Transformer
from pyspark.sql.dataframe import DataFrame


class TransactionFeatureTransformer(Transformer):
def _transform(self, df: DataFrame) -> DataFrame:
days = lambda i: i * 86400
w_3d = (
Window.partitionBy("accountID")
.orderBy(F.col("timestamp").cast("long"))
.rangeBetween(-days(3), 0)
)
w_7d = (
Window.partitionBy("accountID")
.orderBy(F.col("timestamp").cast("long"))
.rangeBetween(-days(7), 0)
)
res = (
df.withColumn("transaction_7d_count", F.count("transactionID").over(w_7d))
.withColumn(
"transaction_amount_7d_sum", F.sum("transactionAmount").over(w_7d)
)
.withColumn(
"transaction_amount_7d_avg", F.avg("transactionAmount").over(w_7d)
)
.withColumn("transaction_3d_count", F.count("transactionID").over(w_3d))
.withColumn(
"transaction_amount_3d_sum", F.sum("transactionAmount").over(w_3d)
)
.withColumn(
"transaction_amount_3d_avg", F.avg("transactionAmount").over(w_3d)
)
.select(
"accountID",
"timestamp",
"transaction_3d_count",
"transaction_amount_3d_sum",
"transaction_amount_3d_avg",
"transaction_7d_count",
"transaction_amount_7d_sum",
"transaction_amount_7d_avg",
)
)
return res
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
"if not os.path.exists(transactions_featureset_spec_folder):\n",
" os.makedirs(transactions_featureset_spec_folder)\n",
"\n",
"transactions_featureset_spec.dump(transactions_featureset_spec_folder)"
"transactions_featureset_spec.dump(transactions_featureset_spec_folder, overwrite=True)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@
"if not os.path.exists(transactions_featureset_spec_folder):\n",
" os.makedirs(transactions_featureset_spec_folder)\n",
"\n",
"transactions_featureset_spec.dump(transactions_featureset_spec_folder)"
"transactions_featureset_spec.dump(transactions_featureset_spec_folder, overwrite=True)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
"if not os.path.exists(transactions_featureset_spec_folder):\n",
" os.makedirs(transactions_featureset_spec_folder)\n",
"\n",
"transactions_featureset_spec.dump(transactions_featureset_spec_folder, overwrite=False)"
"transactions_featureset_spec.dump(transactions_featureset_spec_folder, overwrite=True)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def write_notebook_workflow(
- infra/bootstrapping/**
- sdk/python/setup.sh\n"""
if is_featurestore_sample:
workflow_yaml += f""" - sdk/python/featurestore_sample"""
workflow_yaml += f""" - sdk/python/featurestore_sample/**"""
workflow_yaml += f"""
concurrency:
group: {GITHUB_CONCURRENCY_GROUP}
Expand Down
Loading