imednet.cli package

iMednet Command Line Interface.

class imednet.cli.SinkConfig[source]

Bases: object

Shared configuration for all export sinks.

Parameters

study_key:

Mandatory study key for the export.

batch_size:

Number of records per ExportSink.write_batch() call.

max_retries:

Maximum number of retry attempts on transient errors.

retry_backoff:

Base delay in seconds between retry attempts. The actual delay grows exponentially: retry_backoff * 2 ** attempt.

idempotent:

When True, sinks use upsert / replace semantics so that replaying a batch with the same batch_id produces no duplicate data.

__init__(study_key, batch_size=500, max_retries=3, retry_backoff=1.0, idempotent=True, extra=<factory>, quality_gate_enabled=False, min_schema_readiness_score=100.0, tracer=None)
Parameters:
  • study_key (str) –

  • batch_size (int) –

  • max_retries (int) –

  • retry_backoff (float) –

  • idempotent (bool) –

  • extra (dict[str, Any]) –

  • quality_gate_enabled (bool) –

  • min_schema_readiness_score (float) –

  • tracer (Any | None) –

Return type:

None

imednet.cli.app(args=None)[source]

Main entrypoint for the CLI.

Return type:

None

Parameters:

args (list[str] | None) –

imednet.cli.export_to_csv(sdk, study_key, path, *, use_labels_as_columns=False, **kwargs)[source]

Export study records to a CSV file.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • path (str) –

  • use_labels_as_columns (bool) –

  • kwargs (Any) –

Parameters

use_labels_as_columns:

When True, variable labels are used for column names instead of variable names.

imednet.cli.export_to_duckdb(sdk, study_key, db_path, table_name, *, use_labels_as_columns=False, variable_whitelist=None, form_whitelist=None)[source]

Export study records to a DuckDB table using native DataFrame registration.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • db_path (str) –

  • table_name (str) –

  • use_labels_as_columns (bool) –

  • variable_whitelist (list[str] | None) –

  • form_whitelist (list[int] | None) –

Parameters

sdk:

Authenticated SDK instance used to fetch study records.

study_key:

Study identifier to export.

db_path:

Path to the target .duckdb database file.

table_name:

Name of the destination DuckDB table.

use_labels_as_columns:

When True, variable labels are used for DataFrame column names.

variable_whitelist:

Optional list of variable names to include.

form_whitelist:

Optional list of form IDs to include.

Raises:

ImportError

If the optional duckdb dependency is not installed.

imednet.cli.export_to_excel(sdk, study_key, path, *, use_labels_as_columns=False, **kwargs)[source]

Export study records to an Excel workbook.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • path (str) –

  • use_labels_as_columns (bool) –

  • kwargs (Any) –

Parameters

use_labels_as_columns:

When True, variable labels are used for column names instead of variable names.

imednet.cli.export_to_json(sdk, study_key, path, *, use_labels_as_columns=False, hierarchical=False, **kwargs)[source]

Export study records to a JSON file.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • path (str) –

  • use_labels_as_columns (bool) –

  • hierarchical (bool) –

  • kwargs (Any) –

Parameters

use_labels_as_columns:

When True, variable labels are used for column names instead of variable names.

hierarchical:

When True, generates a nested tree (Subject > Visit > Form) suitable for Veeva Vault integrations instead of a flat tabular layout.

imednet.cli.export_to_long_sql(sdk, study_key, table_name, conn_str, *, chunk_size=1000)[source]

Export records to a normalized long-format SQL table.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • table_name (str) –

  • conn_str (str) –

  • chunk_size (int) –

imednet.cli.export_to_parquet(sdk, study_key, path, *, use_labels_as_columns=False, **kwargs)[source]

Export study records to a Parquet file.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • path (str) –

  • use_labels_as_columns (bool) –

  • kwargs (Any) –

Parameters

use_labels_as_columns:

When True, variable labels are used for column names instead of variable names.

imednet.cli.export_to_sql(sdk, study_key, table, conn_str, if_exists='replace', *, use_labels_as_columns=False, variable_whitelist=None, form_whitelist=None, **kwargs)[source]

Export study records to a SQL table.

All exports now inherit StudyConfiguration rules by default.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • table (str) –

  • conn_str (str) –

  • if_exists (Literal['fail', 'replace', 'append', 'delete_rows']) –

  • use_labels_as_columns (bool) –

  • variable_whitelist (list[str] | None) –

  • form_whitelist (list[int] | None) –

  • kwargs (Any) –

Parameters

use_labels_as_columns:

When True, variable labels are used for column names instead of variable names.

imednet.cli.export_to_sql_by_form(sdk, study_key, conn_str, if_exists='replace', *, use_labels_as_columns=False, variable_whitelist=None, form_whitelist=None, **kwargs)[source]

Export records to separate SQL tables for each form.

Return type:

None

Parameters:
  • sdk (ImednetSDK) –

  • study_key (str) –

  • conn_str (str) –

  • if_exists (Literal['fail', 'replace', 'append', 'delete_rows']) –

  • use_labels_as_columns (bool) –

  • variable_whitelist (list[str] | None) –

  • form_whitelist (list[int] | None) –

  • kwargs (Any) –

imednet.cli.get_parser()[source]

Return the main argparse.ArgumentParser for the CLI.

Return type:

ArgumentParser

imednet.cli.get_sdk()[source]

Initialize and return the SDK instance using load_config().

Return type:

ImednetSDK

imednet.cli.parse_filter_args(filter_args)[source]

Parse a list of key=value strings into a dictionary.

Return type:

Optional[dict[str, Any]]

Parameters:

filter_args (list[str] | None) –

imednet.cli.with_sdk(func)[source]

Initialize the SDK and pass it to the wrapped command function.

Return type:

Callable[[ParamSpec(P)], TypeVar(R)]

Parameters:

func (Callable[[Concatenate[ImednetSDK, ~P]], R]) –

Subpackages

Submodules

imednet.cli.decorators module

Decorators for CLI command functions.

imednet.cli.decorators.with_sdk(func)[source]

Initialize the SDK and pass it to the wrapped command function.

Return type:

Callable[[ParamSpec(P)], TypeVar(R)]

Parameters:

func (Callable[[Concatenate[ImednetSDK, ~P]], R]) –