foundry_dev_tools.helpers.fast_snowflake_ingestion.utils module#

Helpers to resolve Foundry job information inside a lightweight transform runtime.

foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.filter_kwargs_for_function(func, kwargs_dict)[source]#

Filter kwargs to only include parameters that the function accepts.

Parameters:
  • func (Callable[..., Any]) – the function whose signature is used for filtering

  • kwargs_dict (dict[str, Any]) – the keyword arguments to filter

Return type:

dict[str, Any]

class foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.TransactionPath[source]#

Bases: object

Path to a dataset transaction, usable without importing Foundry internal classes.

__init__(dataset_rid, transaction_rid, logical_path=None)[source]#
Parameters:
  • dataset_rid (str)

  • transaction_rid (str)

  • logical_path (str | None)

property dataset_rid: str#

The dataset rid.

property transaction_rid: str#

The transaction rid.

property end_ref: str#

The end ref, which is the transaction rid.

class foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.ViewPath[source]#

Bases: object

Path to a dataset view, usable without importing Foundry internal classes.

__init__(dataset_rid, end_ref, start_transaction=None, logical_path=None)[source]#
Parameters:
  • dataset_rid (str)

  • end_ref (str)

  • start_transaction (str | None)

  • logical_path (str | None)

property dataset_rid: str#

The dataset rid.

property end_ref: str#

The end ref of the view.

class foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.FoundryPathWithBranchId[source]#

Bases: object

A FoundryPath together with a branch id.

__init__(foundry_path, branch_id)[source]#
Parameters:
property foundry_path: TransactionPath | ViewPath#

The foundry path.

property branch_id: str | None#

The branch id.

foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.load_job_config()[source]#

Load job configuration from the Foundry transforms runtime.

Only available inside a Foundry lightweight transform.

Raises:

ModuleNotFoundError – if the Foundry transforms runtime is not available

Return type:

Any

foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.resolve_output_alias_flattened(alias)[source]#

Resolve output alias and return the core components directly.

Parameters:

alias (str) – The output alias to resolve.

Returns:

A tuple containing:
  • dataset_rid: The dataset RID

  • transaction_rid: The transaction RID

  • branch_id: The branch ID (can be None)

  • foundry_path_str: String representation of the foundry path

Return type:

tuple

foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.get_output_foundry_path_components(output)[source]#

Extract core components from an Output object.

Parameters:

output (Output) – The Output object to extract components from.

Returns:

A tuple containing:
  • dataset_rid: The dataset RID

  • transaction_rid: The transaction RID

  • branch_id: The branch ID (can be None)

  • foundry_path_str: String representation of the foundry path

Return type:

tuple

foundry_dev_tools.helpers.fast_snowflake_ingestion.utils.prepare_job_info(out, **kwargs)[source]#

Build a job information dictionary from the current job config and an Output.

Parameters:
  • out (Output) – The primary Output object for which to collect job information.

  • **kwargs – Additional key-value pairs to merge into the result. Keys that already exist from the job configuration are not overwritten; a warning is logged and the original values are kept.

Returns:

A dictionary containing:
  • output_dataset_rid: RID of the output dataset

  • output_transaction_rid: RID of the output transaction

  • branch: name of the branch the code originates from

  • job_rid: RID of the Foundry job

  • sourceProvenance_details_code: Raw sourceProvenance.details.code block

  • inputs: Mapping of input names to dataset RIDs

  • outputs: Mapping of output names to dataset RIDs

  • any additional non-conflicting kwargs

Return type:

dict

Example

>>> result = {
...     "output_dataset_rid": "ri.foundry.main.dataset.00000-00005",
...     "output_transaction_rid": "ri.foundry.main.transaction.00000-00123",
...     "branch": "master",
...     "job_rid": "ri.foundry.main.job.00000-00010",
...     "sourceProvenance_details_code": {
...         "repositoryRid": "ri.stemma.main.repository.00000-00000",
...         "versionId": "84e49aff909709b121250a682193328020f37435",
...         "file": "transforms-python/src/myproject/hello_world.py",
...         "lineNumber": 2137,
...     },
...     "inputs": {
...         "input_1": "ri.foundry.main.dataset.00000-00001",
...         "virtual_table_1": "ri.tables.main.table.00000-00002",
...         "input_2": "ri.foundry.main.dataset.00000-00004",
...     },
...     "outputs": {
...         "out": "ri.foundry.main.dataset.00000-00005",
...     },
...     **kwargs
... }