Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/skills-validate-fallback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ on:
- "skills/**"
workflow_dispatch:

permissions:
contents: read

jobs:
skills-validate:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/skills-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
skills-validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.11"

Expand Down
8 changes: 4 additions & 4 deletions skills/bigquery-data-transfer-service/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Discovers and inspects BigQuery Data Transfer Service (DTS) configu
data that may already be managed by a DTS transfer.
license: Apache-2.0
metadata:
version: v2
version: v3
publisher: google
---

Expand All @@ -18,8 +18,8 @@ metadata:
> [!IMPORTANT]
>
> All new BigQuery Data Transfer Service (DTS) configurations **MUST** be
> provisioned through the **gcp pipeline resource provisioning** framework,
> which includes generating a `deployment.yaml`.
> provisioned through the **gcp pipeline provisioning** framework, which
> includes generating a `deployment.yaml`.
>
> - **Do NOT** use imperative CLI commands (e.g., `bq mk` or `gcloud`) to
> create or update configurations.
Expand Down Expand Up @@ -185,7 +185,7 @@ of the tasks.
## Definition of Done

- A BigQuery DTS transfer configuration has been discovered or provisioned
declaratively (via **gcp pipeline resource provisioning** with a generated
declaratively (via **gcp pipeline provisioning** with a generated
`deployment.yaml`).
- Mandatory datasource parameters have been identified and confirmed with the
user.
Expand Down
74 changes: 37 additions & 37 deletions skills/dak-setup/scripts/dak-setup.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions skills/gcp-data-pipelines/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: 'Primary entry point for building, managing, and orchestrating data
'
license: Apache-2.0
metadata:
version: v3
version: v4
publisher: google
---

Expand Down Expand Up @@ -83,7 +83,7 @@ multiple pipelines already in the repo:
Option | Best For | Skill
------------------ | ------------------------------------------------------------------------------------------------------------ | -----
**Cloud Composer** | GCP Data Pipeline Orchestration deploy/schedule existing pipelines(dbt + Spark, etc.). as a unified workflow | `gcp-pipeline-orchestration`
**Provisioning** | Declarative GCP resource creation (Datasets, DTS, Dataproc) | `gcp-pipeline-resource-provisioning`
**Provisioning** | Declarative GCP resource creation (Datasets, DTS, Dataproc) | `gcp-pipeline-provisioning`

> [!TIP]
>
Expand Down Expand Up @@ -136,13 +136,13 @@ two-step process:
Once the user confirms, activate the corresponding skill:

Choice | Skill to Activate
------------- | ------------------------------------
------------- | --------------------------------
BigQuery DTS | `bigquery-data-transfer-service`
dbt | `dbt-bigquery`
Dataflow | `gcp-dataflow`
Dataform | `dataform-bigquery`
Spark | `gcp-spark`
Spark Debug | `gcp-spark-troubleshooting`
Provisioning | `gcp-pipeline-resource-provisioning`
Provisioning | `gcp-pipeline-provisioning`
Orchestration | `gcp-pipeline-orchestration`
Other | — (general GCP assistance)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: gcp-pipeline-resource-provisioning
name: gcp-pipeline-provisioning
description: |
Automates declarative resource creation and provisioning for data pipelines, supporting BigQuery, Dataform, Dataproc, BigQuery Data Transfer Service (DTS), and other resources. It manages environment-specific configurations (dev, staging, prod) through a deployment.yaml file.
Use when:
Expand Down Expand Up @@ -56,8 +56,8 @@ list of supported resource types, run the following command:
gcloud beta orchestration-pipelines resource-types list
```

Refer to: references/gcp-pipeline-resource-provisioning_spec.md to understand
the template for `deployment.yaml`.
Refer to: references/gcp_pipeline_provisioning_spec.md to understand the
template for `deployment.yaml`.

### Step 2: Discover Environment Parameters

Expand Down Expand Up @@ -112,9 +112,9 @@ configurations and resources.
> [!TIP]
>
> **Use the Reference Spec**: The agent can use the
> **`references/gcp_pipeline_resource_provisioning_spec.md`** file as a
> template. It includes sample definitions for select supported resource types.
> Copy and adapt the required resource blocks into the `deployment.yaml`. Use
> **`references/gcp_pipeline_provisioning_spec.md`** file as a template. It
> includes sample definitions for select supported resource types. Copy and
> adapt the required resource blocks into the `deployment.yaml`. Use
> `gcloud beta orchestration-pipelines resource-types list` when needed.

> [!IMPORTANT]
Expand Down
2 changes: 1 addition & 1 deletion skills/gcp-spark/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description: |
- Troubleshooting failed Spark jobs or Dataproc batches (use @skill:gcp-spark-troubleshooting).
license: Apache-2.0
metadata:
version: v35
version: v36
publisher: google
---

Expand Down
55 changes: 54 additions & 1 deletion skills/gcp-spark/references/ml_tasks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ML on Dataproc

**Verified patterns** for ML training:

- **XGBoost**: Use `SparkXGBClassifier`
- **Native Spark ML**: `GBTClassifier`, `RandomForestClassifier`,
`LogisticRegression`
Expand All @@ -12,13 +13,15 @@
> LightGBM wrapper conflicts with Dataproc's internal libraries.

**Alternatives:**

1. **Use XGBoost** — Similar performance, native Spark support.
2. **Use Native Spark ML** — `GBTClassifier` provides similar gradient boosting
3. **Use Vertex AI** — Train LightGBM on Vertex, export model, load in Spark
for inference
4. **Use Dataproc Cluster** (not Serverless) — More control over dependencies

**If you must use LightGBM**, consider:

- Training on a dedicated Dataproc cluster created with LightGBM spark packages
set in the cluster properties:
`spark:spark.jars.packages=com.microsoft.azure:synapseml_2.12:1.1.3`
Expand All @@ -39,12 +42,14 @@
> **`SparkXGBClassifier`** requires `dynamicAllocation=false`

**Prohibited** (causes `ValueError`):

```python
# ❌ DO NOT do this
xgb = SparkXGBClassifier(objective="binary:logistic", ...)
```

**Correct**:

```python
# ✅ Do this - objective is automatically set
xgb = SparkXGBClassifier(
Expand Down Expand Up @@ -85,4 +90,52 @@ fraudulent_df = df_with_array.filter(col("prob_array")[1] >= 0.70)
> [!IMPORTANT] **Null & Unseen Label Protection**: Always set
> `handleInvalid="keep"` or `handleInvalid="skip"` when initializing
> `VectorAssembler` and `StringIndexer` to prevent pipeline crashes when
> processing missing values or unseen categories.
> processing missing values or unseen categories.

--------------------------------------------------------------------------------

## Leakage-Safe Featurization with `pyspark.ml.Pipeline`

> [!IMPORTANT] **Split first, then fit a Pipeline on the training split only.**
> ALL Spark ML feature stages (`VectorAssembler`, `StringIndexer`,
> `OneHotEncoder`, `StandardScaler`, `Imputer`, ...) MUST be stages of a
> `pyspark.ml.Pipeline` together with the estimator. Call `fit()` on the
> training DataFrame only, then call `transform()` on the validation and test
> DataFrames. Do NOT call `assembler.transform()` or `scaler.fit()` on the full
> DataFrame before the split, even for stateless stages such as
> `VectorAssembler`.

For **time-series forecasting**:

1. Build lag and rolling features with `Window` specs that only look backwards
(e.g. `Window.orderBy(time_col).rowsBetween(-N, -1)`; `lag()` over
`Window.orderBy(time_col)`).
2. Split chronologically (filter on the time column), never `randomSplit`.
3. Fit the `Pipeline` on the training split and `transform()` the
validation/test splits. When retraining on train + validation, re-fit the
whole `Pipeline` on the combined split.

```python
from pyspark.ml import Pipeline
from pyspark.ml.feature import StandardScaler, VectorAssembler
from pyspark.ml.regression import LinearRegression
from pyspark.sql.functions import col

# 1. Backward-looking time-series features (no look-ahead).
# 2. Chronological split BEFORE any featurization stage is applied.
train_df = features_df.filter(col("month") < "2023-01-01")
val_df = features_df.filter(
(col("month") >= "2023-01-01") & (col("month") < "2023-07-01")
)

# 3. All feature stages live inside the Pipeline; fit on train only.
pipeline = Pipeline(stages=[
VectorAssembler(
inputCols=feature_cols, outputCol="raw_features", handleInvalid="keep"
),
StandardScaler(inputCol="raw_features", outputCol="features"),
LinearRegression(featuresCol="features", labelCol="target"),
])
model = pipeline.fit(train_df)
val_pred = model.transform(val_df)
```
Loading