gitlabds 2.3.1__tar.gz → 2.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitlabds-2.3.1 → gitlabds-2.4.1}/PKG-INFO +27 -10
- {gitlabds-2.3.1 → gitlabds-2.4.1}/README.md +26 -9
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/feature_reduction.py +185 -89
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/snowflake_connectors.py +90 -24
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds.egg-info/PKG-INFO +27 -10
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds.egg-info/SOURCES.txt +1 -0
- gitlabds-2.4.1/tests/test_feature_reduction.py +232 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/tests/test_snowflake_connectors.py +232 -59
- {gitlabds-2.3.1 → gitlabds-2.4.1}/LICENSE +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/__init__.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/baselines.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/config_generator.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/dummy.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/feature_descriptions.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/insights.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/memory_optimization.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/missing.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/model_evaluator.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/monitoring_metrics.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/outliers.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/record_benchmarking.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/serving_features.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/split_data.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds/trends.py +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds.egg-info/dependency_links.txt +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds.egg-info/requires.txt +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/gitlabds.egg-info/top_level.txt +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/pyproject.toml +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/setup.cfg +0 -0
- {gitlabds-2.3.1 → gitlabds-2.4.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlabds
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.1
|
|
4
4
|
Summary: GitLab Data Science Tools
|
|
5
5
|
Author-email: Kevin Dietz <kdietz@gitlab.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -376,9 +376,9 @@ test_df_transformed = gitlabds.apply_dummy(
|
|
|
376
376
|
<details><summary> Remove Low Variation </summary>
|
|
377
377
|
|
|
378
378
|
#### Description
|
|
379
|
-
Remove columns from a dataset that do not meet the variation threshold. That is, columns will be dropped that contain a high percentage of one value.
|
|
379
|
+
Remove columns from a dataset that do not meet the variation threshold. That is, columns will be dropped that contain a high percentage of one value. Columns that are entirely null are always dropped.
|
|
380
380
|
|
|
381
|
-
`gitlabds.remove_low_variation(df=None, dv=None, columns='all', threshold=.98, verbose=True):`
|
|
381
|
+
`gitlabds.remove_low_variation(df=None, dv=None, columns='all', threshold=.98, verbose=True, dropna=False):`
|
|
382
382
|
|
|
383
383
|
#### Parameters:
|
|
384
384
|
- _**df**_ : your pandas dataframe
|
|
@@ -386,6 +386,7 @@ Remove columns from a dataset that do not meet the variation threshold. That is,
|
|
|
386
386
|
- **_columns_** : Will examine at all columns by default. To limit to just a subset of columns, pass a list of column names.
|
|
387
387
|
- **_threshold_**: The maximum percentage one value in a column can represent. columns that exceed this threshold will be dropped. For example, the default value of `0.98` will drop any column where one value is present in more than 98% of rows.
|
|
388
388
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
389
|
+
- **_dropna_** : Set to `False` (default) to count missing values as their own value. Set to `True` to measure variation over non-null values only, so a column that is one value plus NaN is dropped. Use `True` when missing values are left in place for a model that handles them natively (e.g. XGBoost, LightGBM).
|
|
389
390
|
|
|
390
391
|
#### Returns
|
|
391
392
|
- DataFrame with low variation columns dropped.
|
|
@@ -399,6 +400,10 @@ new_df = gitlabds.remove_low_variation(df=my_df, dv='my_outcome', columns='all',
|
|
|
399
400
|
# Drop any of the selected columns where one value is present in more than 99% of rows.
|
|
400
401
|
new_df = gitlabds.remove_low_variation(df=my_df, dv=None, columns=['colA', 'colB', 'colC'], threshold=.99)
|
|
401
402
|
```
|
|
403
|
+
```python
|
|
404
|
+
# Ignore missing values: drop columns where one value makes up more than 98% of the non-null rows.
|
|
405
|
+
new_df = gitlabds.remove_low_variation(df=my_df, dv='my_outcome', dropna=True)
|
|
406
|
+
```
|
|
402
407
|
</details>
|
|
403
408
|
|
|
404
409
|
<details><summary> Correlation Reduction </summary>
|
|
@@ -406,7 +411,7 @@ new_df = gitlabds.remove_low_variation(df=my_df, dv=None, columns=['colA', 'colB
|
|
|
406
411
|
#### Description
|
|
407
412
|
Reduce the number of columns on a dataframe by dropping columns that are highly correlated with other columns. Note: only one of the two highly correlated columns will be dropped.
|
|
408
413
|
|
|
409
|
-
`gitlabds.correlation_reduction(df=None, dv=None, threshold=0.9, method="pearson", verbose=True):`
|
|
414
|
+
`gitlabds.correlation_reduction(df=None, dv=None, threshold=0.9, method="pearson", verbose=True, dropna=True, min_periods=1):`
|
|
410
415
|
|
|
411
416
|
#### Parameters:
|
|
412
417
|
- _**df**_ : your pandas dataframe
|
|
@@ -414,6 +419,8 @@ Reduce the number of columns on a dataframe by dropping columns that are highly
|
|
|
414
419
|
- **_threshold_**: The threshold above which columns will be dropped. If two variables exceed this threshold, one will be dropped from the dataframe. For example, the default value of `0.90` will identify columns that have correlations greater than 90% to each other and drop one of those columns.
|
|
415
420
|
- **_method_**: The correlation method to use. Options are "pearson" (linear relationships), "spearman" (monotonic relationships), or "mutual_info" (any statistical dependency).
|
|
416
421
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
422
|
+
- **_dropna_** : Set to `True` (default) to compare each pair of columns (and each column with the outcome) using only rows where both are non-null. Pearson and Spearman always work this way; for "mutual_info", `False` raises an error if any missing values are present.
|
|
423
|
+
- **_min_periods_** : Minimum number of rows where both columns of a pair are non-null for the pair to be evaluated. Pairs below it are never treated as correlated. Guards against spurious high correlations between sparsely populated columns. "mutual_info" always requires at least 4 such rows.
|
|
417
424
|
|
|
418
425
|
#### Returns
|
|
419
426
|
- DataFrame with redundant correlated columns dropped.
|
|
@@ -434,7 +441,7 @@ new_df = gitlabds.correlation_reduction(df=my_df, dv=None, threshold=0.90, metho
|
|
|
434
441
|
#### Description
|
|
435
442
|
Remove columns that are highly correlated with the outcome (target) column.
|
|
436
443
|
|
|
437
|
-
`gitlabds.remove_outcome_proxies(df, dv, threshold=.8, method="pearson", verbose=True):`
|
|
444
|
+
`gitlabds.remove_outcome_proxies(df, dv, threshold=.8, method="pearson", verbose=True, dropna=True, min_periods=1):`
|
|
438
445
|
|
|
439
446
|
#### Parameters:
|
|
440
447
|
- _**df**_ : your pandas dataframe
|
|
@@ -442,6 +449,8 @@ Remove columns that are highly correlated with the outcome (target) column.
|
|
|
442
449
|
- _**threshold**_ : The correlation value to the outcome above which columns will be dropped. For example, the default value of `0.80` will identify and drop columns that have correlations greater than 80% to the outcome.
|
|
443
450
|
- **_method_**: The correlation method to use. Options are "pearson" (linear relationships), "spearman" (monotonic relationships), or "mutual_info" (any statistical dependency).
|
|
444
451
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
452
|
+
- **_dropna_** : Set to `True` (default) to compare each column to the outcome using only rows where both are non-null. Pearson and Spearman always work this way; for "mutual_info", `False` raises an error if any missing values are present.
|
|
453
|
+
- **_min_periods_** : Minimum number of rows where both the column and the outcome are non-null for the column to be evaluated. Columns below it are never dropped. Guards against spurious high correlations from sparsely populated columns. "mutual_info" always requires at least 4 such rows.
|
|
445
454
|
|
|
446
455
|
#### Returns
|
|
447
456
|
- DataFrame with outcome proxy columns dropped.
|
|
@@ -455,6 +464,10 @@ new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', threshold=.7
|
|
|
455
464
|
# Drop columns with correlations to the outcome greater than 80% using Spearman correlation
|
|
456
465
|
new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', threshold=.8, method="spearman")
|
|
457
466
|
```
|
|
467
|
+
```python
|
|
468
|
+
# Data with missing values: only evaluate columns with at least 100 non-null rows alongside the outcome
|
|
469
|
+
new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', method="spearman", min_periods=100)
|
|
470
|
+
```
|
|
458
471
|
</details>
|
|
459
472
|
|
|
460
473
|
<details><summary> Drop Categorical </summary>
|
|
@@ -1135,7 +1148,7 @@ feature_drift = results['feature_drift']
|
|
|
1135
1148
|
|
|
1136
1149
|
#### Snowflake Connectors
|
|
1137
1150
|
|
|
1138
|
-
Thin wrappers over the native Snowflake SDKs that resolve GitLab's two credential paths — local (dbt profile + SSO) and GitLab CI (env vars +
|
|
1151
|
+
Thin wrappers over the native Snowflake SDKs that resolve GitLab's two credential paths — local (dbt profile + SSO) and GitLab CI (env vars + key-pair auth) — and then hand off to the native objects. Migrated from `gitlabdata.orchestration_utils`; see the migration notes at the end of this section.
|
|
1139
1152
|
|
|
1140
1153
|
All of these require `pip install gitlabds[snowflake]`.
|
|
1141
1154
|
|
|
@@ -1144,7 +1157,7 @@ All of these require `pip install gitlabds[snowflake]`.
|
|
|
1144
1157
|
#### Description
|
|
1145
1158
|
Open a Snowflake connection, resolving credentials from your dbt profile locally or from GitLab CI environment variables in CI.
|
|
1146
1159
|
|
|
1147
|
-
`gitlabds.snowflake_engine_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="dev", schema="", auth_method="
|
|
1160
|
+
`gitlabds.snowflake_engine_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="dev", schema="", auth_method="keypair", profiles_path=None, **connect_kwargs):`
|
|
1148
1161
|
|
|
1149
1162
|
#### Parameters:
|
|
1150
1163
|
- **_args_** : Environment mapping to read CI credentials from. Defaults to `os.environ`. Ignored on the local path.
|
|
@@ -1152,10 +1165,12 @@ Open a Snowflake connection, resolving credentials from your dbt profile locally
|
|
|
1152
1165
|
- **_run_target_** : `"local"` or `"ci"`. Inferred from the `GITLAB_CI` environment variable when not given.
|
|
1153
1166
|
- **_profile_target_** : dbt profile output name. Only used on the local path.
|
|
1154
1167
|
- **_schema_** : Schema to connect to. Falls back to the dbt profile's schema locally; when it resolves empty the connection is opened with no default schema.
|
|
1155
|
-
- **_auth_method_** : `"
|
|
1168
|
+
- **_auth_method_** : CI authentication method. `"keypair"` is the only supported value and the default, so passing it explicitly is the same as omitting it. Retained so callers that pass `auth_method="keypair"` keep working. `"password"` is accepted but ignored, with a logged warning naming the fix; any other value raises `ValueError`.
|
|
1156
1169
|
- **_profiles_path_** : Override the dbt `profiles.yml` location (defaults to `~/.dbt/profiles.yml`). Only used on the local path.
|
|
1157
1170
|
- **_\*\*connect_kwargs_** : Passed through to `snowflake.connector.connect()`, e.g. `autocommit=False`, `client_session_keep_alive=True`.
|
|
1158
1171
|
|
|
1172
|
+
> **CI authentication** uses key-pair auth exclusively (password-based CI auth was removed ahead of Snowflake's 2026-09-22 service-user password deprecation). In CI, reads `SNOWFLAKE_DATA_SCIENCE_LOAD_PRIVATE_KEY` (raw PEM or base64-encoded PEM — base64 is required for GitLab CI/CD variables since multi-line values cannot be masked) and optionally `SNOWFLAKE_DATA_SCIENCE_LOAD_PRIVATE_KEY_PASSPHRASE` (or the `_PASSWORD` variant) for encrypted keys.
|
|
1173
|
+
|
|
1159
1174
|
#### Returns
|
|
1160
1175
|
- An open `snowflake.connector.SnowflakeConnection`. The caller owns its lifecycle.
|
|
1161
1176
|
|
|
@@ -1300,17 +1315,19 @@ gitlabds.snowflake_stage_load_copy_remove(
|
|
|
1300
1315
|
#### Description
|
|
1301
1316
|
Create a Snowflake Feature Store connection (Snowpark Session + native `FeatureStore`), resolving credentials the same way as `snowflake_engine_factory`.
|
|
1302
1317
|
|
|
1303
|
-
`gitlabds.feature_store_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="feature_store", auth_method="
|
|
1318
|
+
`gitlabds.feature_store_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="feature_store", auth_method="keypair", creation_mode="CreationMode.FAIL_IF_NOT_EXIST", profiles_path=None):`
|
|
1304
1319
|
|
|
1305
1320
|
#### Parameters:
|
|
1306
1321
|
- **_args_** : Environment mapping to read CI credentials from. Defaults to `os.environ`. Ignored on the local path.
|
|
1307
1322
|
- **_role_** : Snowflake role for CI credentials. The feature store's database and schema come from `SNOWFLAKE_FEATURE_STORE_DATABASE` / `SNOWFLAKE_FEATURE_STORE_SCHEMA` on the CI path, not from the role's usual database/schema.
|
|
1308
1323
|
- **_run_target_** : `"local"` or `"ci"`. Inferred from the `GITLAB_CI` environment variable when not given.
|
|
1309
1324
|
- **_profile_target_** : dbt profile output name. Only used on the local path.
|
|
1310
|
-
- **_auth_method_** : `"
|
|
1325
|
+
- **_auth_method_** : CI authentication method. `"keypair"` is the only supported value and the default, so passing it explicitly is the same as omitting it. Retained so callers that pass `auth_method="keypair"` keep working. `"password"` is accepted but ignored, with a logged warning naming the fix; any other value raises `ValueError`.
|
|
1311
1326
|
- **_creation_mode_** : Either a `"CreationMode.X"` string or a `snowflake.ml.feature_store.CreationMode` member.
|
|
1312
1327
|
- **_profiles_path_** : Override the dbt `profiles.yml` location. Only used on the local path.
|
|
1313
1328
|
|
|
1329
|
+
> **CI authentication** uses key-pair auth exclusively — see `snowflake_engine_factory` for the env var names and base64 encoding details.
|
|
1330
|
+
|
|
1314
1331
|
#### Returns
|
|
1315
1332
|
- A `snowflake.ml.feature_store.FeatureStore`. The underlying Snowpark session is reachable as `fs._session` and is not closed by this function.
|
|
1316
1333
|
|
|
@@ -340,9 +340,9 @@ test_df_transformed = gitlabds.apply_dummy(
|
|
|
340
340
|
<details><summary> Remove Low Variation </summary>
|
|
341
341
|
|
|
342
342
|
#### Description
|
|
343
|
-
Remove columns from a dataset that do not meet the variation threshold. That is, columns will be dropped that contain a high percentage of one value.
|
|
343
|
+
Remove columns from a dataset that do not meet the variation threshold. That is, columns will be dropped that contain a high percentage of one value. Columns that are entirely null are always dropped.
|
|
344
344
|
|
|
345
|
-
`gitlabds.remove_low_variation(df=None, dv=None, columns='all', threshold=.98, verbose=True):`
|
|
345
|
+
`gitlabds.remove_low_variation(df=None, dv=None, columns='all', threshold=.98, verbose=True, dropna=False):`
|
|
346
346
|
|
|
347
347
|
#### Parameters:
|
|
348
348
|
- _**df**_ : your pandas dataframe
|
|
@@ -350,6 +350,7 @@ Remove columns from a dataset that do not meet the variation threshold. That is,
|
|
|
350
350
|
- **_columns_** : Will examine at all columns by default. To limit to just a subset of columns, pass a list of column names.
|
|
351
351
|
- **_threshold_**: The maximum percentage one value in a column can represent. columns that exceed this threshold will be dropped. For example, the default value of `0.98` will drop any column where one value is present in more than 98% of rows.
|
|
352
352
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
353
|
+
- **_dropna_** : Set to `False` (default) to count missing values as their own value. Set to `True` to measure variation over non-null values only, so a column that is one value plus NaN is dropped. Use `True` when missing values are left in place for a model that handles them natively (e.g. XGBoost, LightGBM).
|
|
353
354
|
|
|
354
355
|
#### Returns
|
|
355
356
|
- DataFrame with low variation columns dropped.
|
|
@@ -363,6 +364,10 @@ new_df = gitlabds.remove_low_variation(df=my_df, dv='my_outcome', columns='all',
|
|
|
363
364
|
# Drop any of the selected columns where one value is present in more than 99% of rows.
|
|
364
365
|
new_df = gitlabds.remove_low_variation(df=my_df, dv=None, columns=['colA', 'colB', 'colC'], threshold=.99)
|
|
365
366
|
```
|
|
367
|
+
```python
|
|
368
|
+
# Ignore missing values: drop columns where one value makes up more than 98% of the non-null rows.
|
|
369
|
+
new_df = gitlabds.remove_low_variation(df=my_df, dv='my_outcome', dropna=True)
|
|
370
|
+
```
|
|
366
371
|
</details>
|
|
367
372
|
|
|
368
373
|
<details><summary> Correlation Reduction </summary>
|
|
@@ -370,7 +375,7 @@ new_df = gitlabds.remove_low_variation(df=my_df, dv=None, columns=['colA', 'colB
|
|
|
370
375
|
#### Description
|
|
371
376
|
Reduce the number of columns on a dataframe by dropping columns that are highly correlated with other columns. Note: only one of the two highly correlated columns will be dropped.
|
|
372
377
|
|
|
373
|
-
`gitlabds.correlation_reduction(df=None, dv=None, threshold=0.9, method="pearson", verbose=True):`
|
|
378
|
+
`gitlabds.correlation_reduction(df=None, dv=None, threshold=0.9, method="pearson", verbose=True, dropna=True, min_periods=1):`
|
|
374
379
|
|
|
375
380
|
#### Parameters:
|
|
376
381
|
- _**df**_ : your pandas dataframe
|
|
@@ -378,6 +383,8 @@ Reduce the number of columns on a dataframe by dropping columns that are highly
|
|
|
378
383
|
- **_threshold_**: The threshold above which columns will be dropped. If two variables exceed this threshold, one will be dropped from the dataframe. For example, the default value of `0.90` will identify columns that have correlations greater than 90% to each other and drop one of those columns.
|
|
379
384
|
- **_method_**: The correlation method to use. Options are "pearson" (linear relationships), "spearman" (monotonic relationships), or "mutual_info" (any statistical dependency).
|
|
380
385
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
386
|
+
- **_dropna_** : Set to `True` (default) to compare each pair of columns (and each column with the outcome) using only rows where both are non-null. Pearson and Spearman always work this way; for "mutual_info", `False` raises an error if any missing values are present.
|
|
387
|
+
- **_min_periods_** : Minimum number of rows where both columns of a pair are non-null for the pair to be evaluated. Pairs below it are never treated as correlated. Guards against spurious high correlations between sparsely populated columns. "mutual_info" always requires at least 4 such rows.
|
|
381
388
|
|
|
382
389
|
#### Returns
|
|
383
390
|
- DataFrame with redundant correlated columns dropped.
|
|
@@ -398,7 +405,7 @@ new_df = gitlabds.correlation_reduction(df=my_df, dv=None, threshold=0.90, metho
|
|
|
398
405
|
#### Description
|
|
399
406
|
Remove columns that are highly correlated with the outcome (target) column.
|
|
400
407
|
|
|
401
|
-
`gitlabds.remove_outcome_proxies(df, dv, threshold=.8, method="pearson", verbose=True):`
|
|
408
|
+
`gitlabds.remove_outcome_proxies(df, dv, threshold=.8, method="pearson", verbose=True, dropna=True, min_periods=1):`
|
|
402
409
|
|
|
403
410
|
#### Parameters:
|
|
404
411
|
- _**df**_ : your pandas dataframe
|
|
@@ -406,6 +413,8 @@ Remove columns that are highly correlated with the outcome (target) column.
|
|
|
406
413
|
- _**threshold**_ : The correlation value to the outcome above which columns will be dropped. For example, the default value of `0.80` will identify and drop columns that have correlations greater than 80% to the outcome.
|
|
407
414
|
- **_method_**: The correlation method to use. Options are "pearson" (linear relationships), "spearman" (monotonic relationships), or "mutual_info" (any statistical dependency).
|
|
408
415
|
- **_verbose_** : Set to `True` to print outputs of columns being dropped. Set to `False` to suppress.
|
|
416
|
+
- **_dropna_** : Set to `True` (default) to compare each column to the outcome using only rows where both are non-null. Pearson and Spearman always work this way; for "mutual_info", `False` raises an error if any missing values are present.
|
|
417
|
+
- **_min_periods_** : Minimum number of rows where both the column and the outcome are non-null for the column to be evaluated. Columns below it are never dropped. Guards against spurious high correlations from sparsely populated columns. "mutual_info" always requires at least 4 such rows.
|
|
409
418
|
|
|
410
419
|
#### Returns
|
|
411
420
|
- DataFrame with outcome proxy columns dropped.
|
|
@@ -419,6 +428,10 @@ new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', threshold=.7
|
|
|
419
428
|
# Drop columns with correlations to the outcome greater than 80% using Spearman correlation
|
|
420
429
|
new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', threshold=.8, method="spearman")
|
|
421
430
|
```
|
|
431
|
+
```python
|
|
432
|
+
# Data with missing values: only evaluate columns with at least 100 non-null rows alongside the outcome
|
|
433
|
+
new_df = gitlabds.remove_outcome_proxies(df=my_df, dv='my_outcome', method="spearman", min_periods=100)
|
|
434
|
+
```
|
|
422
435
|
</details>
|
|
423
436
|
|
|
424
437
|
<details><summary> Drop Categorical </summary>
|
|
@@ -1099,7 +1112,7 @@ feature_drift = results['feature_drift']
|
|
|
1099
1112
|
|
|
1100
1113
|
#### Snowflake Connectors
|
|
1101
1114
|
|
|
1102
|
-
Thin wrappers over the native Snowflake SDKs that resolve GitLab's two credential paths — local (dbt profile + SSO) and GitLab CI (env vars +
|
|
1115
|
+
Thin wrappers over the native Snowflake SDKs that resolve GitLab's two credential paths — local (dbt profile + SSO) and GitLab CI (env vars + key-pair auth) — and then hand off to the native objects. Migrated from `gitlabdata.orchestration_utils`; see the migration notes at the end of this section.
|
|
1103
1116
|
|
|
1104
1117
|
All of these require `pip install gitlabds[snowflake]`.
|
|
1105
1118
|
|
|
@@ -1108,7 +1121,7 @@ All of these require `pip install gitlabds[snowflake]`.
|
|
|
1108
1121
|
#### Description
|
|
1109
1122
|
Open a Snowflake connection, resolving credentials from your dbt profile locally or from GitLab CI environment variables in CI.
|
|
1110
1123
|
|
|
1111
|
-
`gitlabds.snowflake_engine_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="dev", schema="", auth_method="
|
|
1124
|
+
`gitlabds.snowflake_engine_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="dev", schema="", auth_method="keypair", profiles_path=None, **connect_kwargs):`
|
|
1112
1125
|
|
|
1113
1126
|
#### Parameters:
|
|
1114
1127
|
- **_args_** : Environment mapping to read CI credentials from. Defaults to `os.environ`. Ignored on the local path.
|
|
@@ -1116,10 +1129,12 @@ Open a Snowflake connection, resolving credentials from your dbt profile locally
|
|
|
1116
1129
|
- **_run_target_** : `"local"` or `"ci"`. Inferred from the `GITLAB_CI` environment variable when not given.
|
|
1117
1130
|
- **_profile_target_** : dbt profile output name. Only used on the local path.
|
|
1118
1131
|
- **_schema_** : Schema to connect to. Falls back to the dbt profile's schema locally; when it resolves empty the connection is opened with no default schema.
|
|
1119
|
-
- **_auth_method_** : `"
|
|
1132
|
+
- **_auth_method_** : CI authentication method. `"keypair"` is the only supported value and the default, so passing it explicitly is the same as omitting it. Retained so callers that pass `auth_method="keypair"` keep working. `"password"` is accepted but ignored, with a logged warning naming the fix; any other value raises `ValueError`.
|
|
1120
1133
|
- **_profiles_path_** : Override the dbt `profiles.yml` location (defaults to `~/.dbt/profiles.yml`). Only used on the local path.
|
|
1121
1134
|
- **_\*\*connect_kwargs_** : Passed through to `snowflake.connector.connect()`, e.g. `autocommit=False`, `client_session_keep_alive=True`.
|
|
1122
1135
|
|
|
1136
|
+
> **CI authentication** uses key-pair auth exclusively (password-based CI auth was removed ahead of Snowflake's 2026-09-22 service-user password deprecation). In CI, reads `SNOWFLAKE_DATA_SCIENCE_LOAD_PRIVATE_KEY` (raw PEM or base64-encoded PEM — base64 is required for GitLab CI/CD variables since multi-line values cannot be masked) and optionally `SNOWFLAKE_DATA_SCIENCE_LOAD_PRIVATE_KEY_PASSPHRASE` (or the `_PASSWORD` variant) for encrypted keys.
|
|
1137
|
+
|
|
1123
1138
|
#### Returns
|
|
1124
1139
|
- An open `snowflake.connector.SnowflakeConnection`. The caller owns its lifecycle.
|
|
1125
1140
|
|
|
@@ -1264,17 +1279,19 @@ gitlabds.snowflake_stage_load_copy_remove(
|
|
|
1264
1279
|
#### Description
|
|
1265
1280
|
Create a Snowflake Feature Store connection (Snowpark Session + native `FeatureStore`), resolving credentials the same way as `snowflake_engine_factory`.
|
|
1266
1281
|
|
|
1267
|
-
`gitlabds.feature_store_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="feature_store", auth_method="
|
|
1282
|
+
`gitlabds.feature_store_factory(args=None, role="DATA_SCIENCE_LOADER", run_target=None, profile_target="feature_store", auth_method="keypair", creation_mode="CreationMode.FAIL_IF_NOT_EXIST", profiles_path=None):`
|
|
1268
1283
|
|
|
1269
1284
|
#### Parameters:
|
|
1270
1285
|
- **_args_** : Environment mapping to read CI credentials from. Defaults to `os.environ`. Ignored on the local path.
|
|
1271
1286
|
- **_role_** : Snowflake role for CI credentials. The feature store's database and schema come from `SNOWFLAKE_FEATURE_STORE_DATABASE` / `SNOWFLAKE_FEATURE_STORE_SCHEMA` on the CI path, not from the role's usual database/schema.
|
|
1272
1287
|
- **_run_target_** : `"local"` or `"ci"`. Inferred from the `GITLAB_CI` environment variable when not given.
|
|
1273
1288
|
- **_profile_target_** : dbt profile output name. Only used on the local path.
|
|
1274
|
-
- **_auth_method_** : `"
|
|
1289
|
+
- **_auth_method_** : CI authentication method. `"keypair"` is the only supported value and the default, so passing it explicitly is the same as omitting it. Retained so callers that pass `auth_method="keypair"` keep working. `"password"` is accepted but ignored, with a logged warning naming the fix; any other value raises `ValueError`.
|
|
1275
1290
|
- **_creation_mode_** : Either a `"CreationMode.X"` string or a `snowflake.ml.feature_store.CreationMode` member.
|
|
1276
1291
|
- **_profiles_path_** : Override the dbt `profiles.yml` location. Only used on the local path.
|
|
1277
1292
|
|
|
1293
|
+
> **CI authentication** uses key-pair auth exclusively — see `snowflake_engine_factory` for the env var names and base64 encoding details.
|
|
1294
|
+
|
|
1278
1295
|
#### Returns
|
|
1279
1296
|
- A `snowflake.ml.feature_store.FeatureStore`. The underlying Snowpark session is reachable as `fs._session` and is not closed by this function.
|
|
1280
1297
|
|