imednet package¶
iMednet SDK - A Python client for the iMednet EDC REST API.
- class imednet.AsyncImednetSDK[source]¶
Bases:
_BaseSDK,AsyncSDKConvenienceMixinAsync variant of
ImednetSDKusing the async HTTP client.Always use this class with
async withor callawait sdk.aclose()explicitly when done. Using the synchronous context manager (with) or synchronousclose()on this class will raise aTypeError.- __init__(api_key=None, security_key=None, base_url=None, timeout=None, strict_mode=None, retry_config=None, async_client=None, retries=None, backoff_factor=None, retry_policy=None)[source]¶
Initialize the asynchronous SDK.
- Parameters:
api_key (
Optional[str]) – iMednet API key.security_key (
Optional[str]) – iMednet security key.base_url (
Optional[str]) – Base URL for the iMednet API.timeout (
Optional[float]) – Default request timeout in seconds.strict_mode (
Optional[bool]) – Toggle strict mode for data validation.retry_config (
Optional[RetryConfig]) – Centralized configuration for retry behaviors.async_client (
Optional[AsyncClient]) – Pre-configured async client instance.retries (
Optional[int]) – Number of retries for failed requests.backoff_factor (
Optional[float]) – Backoff factor for retry delays.retry_policy (
Optional[RetryPolicy]) – Custom retry policy.
- Return type:
None
- async aclose()[source]¶
Close the underlying asynchronous client and free resources.
- Return type:
None
- property auth: Any¶
Return the authentication provider used by the async client.
- property retry_policy: RetryPolicy¶
Return the current retry policy of the async client.
- class imednet.BaseClient[source]¶
Bases:
objectCommon initialization logic for HTTP clients.
- __init__(api_key=None, security_key=None, base_url=None, timeout=30.0, tracer=None, retry_config=None, auth=None)[source]¶
Initialize common client settings.
- Parameters:
api_key (
Optional[str]) – iMednet API key.security_key (
Optional[str]) – iMednet security key.base_url (
Optional[str]) – Base URL for the iMednet API.timeout (
float|Timeout) – Default request timeout in seconds or httpx.Timeout.tracer (
Optional[Tracer]) – Optional OpenTelemetry tracer instance.retry_config (
Optional[RetryConfig]) – Centralized configuration for retry behaviors.auth (
Optional[AuthStrategy]) – Optional pre-configured AuthStrategy.
- Return type:
None
- class imednet.Config[source]¶
Bases:
objectConfiguration object for the SDK client.
- api_key¶
The API key for authentication.
- security_key¶
The security key for authentication.
- base_url¶
The base URL for the iMednet API.
- oidc_token¶
Optional OIDC token for authentication.
- timeout¶
The default timeout for network requests.
- strict_mode¶
Toggle strict mode for data validation.
- __init__(api_key=None, security_key=None, base_url=None, oidc_token=None, timeout=30.0, strict_mode=False, vpat_path='/app/docs/VPAT.md', a11y_report_path=None)¶
- Parameters:
api_key (str | None) –
security_key (str | None) –
base_url (str | None) –
oidc_token (str | None) –
timeout (float) –
strict_mode (bool) –
vpat_path (str) –
a11y_report_path (str | None) –
- Return type:
None
- class imednet.DefaultRetryPolicy[source]¶
Bases:
objectRetry policy with idempotency-aware retry logic.
Network errors (
httpx.RequestError) and server errors (HTTP 500-599) are only retried for idempotent HTTP methods:GET,PUT,DELETE,HEAD, andOPTIONS.Rate-limit responses (HTTP 429) are retried for all methods because the server rejected the request before processing the payload, so there is no risk of duplicate side-effects.
Requests with an unknown or missing method are treated as non-idempotent (fail-safe default): they are not retried on network errors or 5xx responses.
Overriding this behaviour
If you need retries on a
POSTendpoint that is internally deduplicated (e.g. the server uses an idempotency key), subclassRetryPolicyand pass an instance to the client:from imednet.core.retry import RetryPolicy, RetryState, IDEMPOTENT_METHODS import httpx class IdempotentPostPolicy(RetryPolicy): def should_retry(self, state: RetryState) -> bool: method = (state.method or "").upper() if state.exception: return isinstance(state.exception, httpx.RequestError) response = state.result if isinstance(response, httpx.Response): return ( response.status_code == 429 or 500 <= response.status_code < 600 ) return False sdk = ImednetSDK(..., retry_config=RetryConfig(retry_policy=IdempotentPostPolicy()))
- should_retry(state)[source]¶
Return True if the request should be retried based on the state.
- Return type:
bool- Parameters:
state (RetryState) –
- exception imednet.FilterConflictError[source]¶
Bases:
OrchestratorErrorRaised when both whitelist and blacklist are non-empty simultaneously.
The whitelist and blacklist filters are mutually exclusive operations. Providing both simultaneously creates ambiguous behavior and is rejected at validation time before any study resolution occurs.
Example:
# This raises FilterConflictError — a study key cannot be in both: orchestrator.execute_pipeline( my_func, whitelist={"STUDY-A", "STUDY-B"}, blacklist={"STUDY-C"}, )
- imednet.ImednetClient¶
alias of
ImednetSDK
- class imednet.ImednetSDK[source]¶
Bases:
_BaseSDK,SyncSDKConvenienceMixinPublic entry-point for library users.
Provides access to all iMednet API endpoints and maintains configuration.
- __init__(api_key=None, security_key=None, base_url=None, timeout=None, strict_mode=None, retry_config=None, client=None, retries=None, backoff_factor=None, retry_policy=None)[source]¶
Initialize the SDK with credentials and configuration.
- Parameters:
api_key (str | None) –
security_key (str | None) –
base_url (str | None) –
timeout (float | None) –
strict_mode (bool | None) –
retry_config (RetryConfig | None) –
client (Client | None) –
retries (int | None) –
backoff_factor (float | None) –
retry_policy (RetryPolicy | None) –
- Return type:
None
- async aclose()[source]¶
Asynchronous close is not supported on the synchronous SDK.
- Return type:
None
- property auth: Any¶
Return the authentication provider used by the client.
- property retry_policy: RetryPolicy¶
Return the current retry policy.
- imednet.JsonDict¶
alias of
dict[str,Any]
- class imednet.MultiStudyOrchestrator[source]¶
Bases:
objectOrchestrates pipeline execution across multiple active clinical trial boundaries.
The SDK instance passed at construction is treated as an immutable read-only resource — no worker thread may mutate its transport, authentication state, or connection pool during parallel execution.
- Parameters:
sdk (
Any) – A fully initializedImednetSDKinstance. The orchestrator stores a reference (not a copy) and treats it as immutable.max_workers (
int) – Maximum number of concurrent worker threads. Defaults to 4. Set to 1 to force sequential execution (useful for debugging).
Example:
with ImednetSDK(api_key=..., security_key=...) as sdk: orchestrator = MultiStudyOrchestrator(sdk, max_workers=8) results = orchestrator.execute_pipeline(my_pipeline_func)
- __init__(sdk, max_workers=4)[source]¶
Initialize the multi-study orchestrator.
- Parameters:
sdk (
Any) – An initialized iMednet SDK instance.max_workers (
int) – Maximum number of concurrent worker threads.
- Return type:
None
- execute_pipeline(pipeline_func, whitelist=None, blacklist=None, *args, **kwargs)[source]¶
Execute a pipeline function concurrently across resolved study contexts.
- Return type:
dict[str,OrchestratorResult]- Parameters:
pipeline_func (StudyWorkerCallable[Any]) –
whitelist (set[str] | None) –
blacklist (set[str] | None) –
args (Any) –
kwargs (Any) –
- property max_workers: int¶
Maximum number of concurrent worker threads.
- resolve_active_studies(whitelist=None, blacklist=None)[source]¶
Query the iMednet registry and apply filtering rules.
Calls
self._sdk.studies.list()to fetch the live study inventory, then applies the whitelist OR blacklist (mutually exclusive).- Parameters:
whitelist (
Optional[set[str]]) – If provided, only studies whosestudyKeyis in this set are included. Mutually exclusive withblacklist.blacklist (
Optional[set[str]]) – If provided, studies whosestudyKeyis in this set are excluded. Mutually exclusive withwhitelist.
- Return type:
list[str]- Returns:
Ordered list of study key strings targeting this execution run.
- Raises:
FilterConflictError – When both
whitelistandblacklistare non-empty simultaneously.
- property sdk: Any¶
The shared read-only SDK instance.
- exception imednet.OrchestratorError[source]¶
Bases:
ImednetErrorBase exception for all orchestration-layer failures.
Raised when the
MultiStudyOrchestratorencounters a structural or configuration error that prevents pipeline execution from starting.Individual per-study runtime failures are NOT raised as exceptions — they are captured in the
OrchestratorResultresult matrix withstatus="FAILED".
- class imednet.OrchestratorResult[source]¶
Bases:
TypedDictNormalized result entry returned per study by
execute_pipeline.
- exception imednet.PluginLoadError[source]¶
Bases:
ImednetErrorRaised when a plugin fails to load or does not satisfy the
PluginProtocol.
- class imednet.PluginProtocol[source]¶
Bases:
ProtocolProtocol that every iMednet plugin factory must satisfy.
A conforming factory is a callable that accepts an SDK instance and returns an object implementing
WorkflowsNamespaceProtocol.Example:
from imednet.plugins import PluginProtocol from imednet.sdk import ImednetSDK class MyWorkflows: def __init__(self, sdk: ImednetSDK) -> None: self.data_extraction = ... self.query_management = ... self.record_mapper = ... self.record_update = ... self.subject_data = ... def create_workflows(sdk: ImednetSDK) -> MyWorkflows: return MyWorkflows(sdk) # Verify conformance at import time (optional, for development use): assert isinstance(create_workflows, PluginProtocol)
- __init__(*args, **kwargs)¶
- class imednet.RetryPolicy[source]¶
Bases:
ProtocolInterface to determine whether a request should be retried.
- __init__(*args, **kwargs)¶
- should_retry(state)[source]¶
Return
Trueto retry the request for the given state.- Return type:
bool- Parameters:
state (RetryState) –
- class imednet.RetryState[source]¶
Bases:
objectState information passed to
RetryPolicy.- __init__(attempt_number, exception=None, result=None, method=None)¶
- Parameters:
attempt_number (int) –
exception (BaseException | None) –
result (Any | None) –
method (str | None) –
- Return type:
None
- class imednet.StudyWorkerCallable[source]¶
Bases:
Protocol[T_Output]Defines the explicit signature required for injected pipeline tasks.
Pipeline callables injected into
MultiStudyOrchestrator.execute_pipelinemust conform to this protocol.- __init__(*args, **kwargs)¶
- class imednet.WorkflowsNamespaceProtocol[source]¶
Bases:
ProtocolMinimal interface that a workflows namespace object must expose.
Each attribute should be a workflow class instance wired to the SDK.
- __init__(*args, **kwargs)¶
- imednet.load_config(api_key=None, security_key=None, base_url=None, oidc_token=None, timeout=None, strict_mode=None, vpat_path=None, a11y_report_path=None)[source]¶
Return configuration using arguments or environment variables.
- Parameters:
api_key (
Optional[str]) – The API key for authentication. Defaults to IMEDNET_API_KEY environment variable.security_key (
Optional[str]) – The security key for authentication. Defaults to IMEDNET_SECURITY_KEY environment variable.base_url (
Optional[str]) – The base URL for the iMednet API. Defaults to IMEDNET_BASE_URL environment variable.oidc_token (
Optional[str]) – Optional OIDC token. Defaults to IMEDNET_OIDC_TOKEN environment variable.timeout (
Optional[float]) – HTTP request timeout in seconds. Defaults to IMEDNET_TIMEOUT environment variable or 30.0.strict_mode (
Optional[bool]) – Toggle strict mode for data validation. Defaults to IMEDNET_STRICT_MODE environment variable or False.vpat_path (
Optional[str]) – Path to the VPAT file. Defaults to IMEDNET_VPAT_PATH environment variable.a11y_report_path (
Optional[str]) – Path to the a11y report. Defaults to IMEDNET_A11Y_REPORT_PATH environment variable.
- Return type:
- Returns:
The loaded SDK configuration.
- Raises:
ValueError – If required authentication parameters are missing.
Subpackages¶
- imednet.auth package
- imednet.cli package
SinkConfigapp()export_to_csv()export_to_duckdb()export_to_excel()export_to_json()export_to_long_sql()export_to_parquet()export_to_sql()export_to_sql_by_form()get_parser()get_sdk()parse_filter_args()with_sdk()- Subpackages
- imednet.cli.export package
- imednet.cli.intervals package
- imednet.cli.jobs package
- imednet.cli.queries package
- imednet.cli.record_revisions package
- imednet.cli.records package
- imednet.cli.sites package
- imednet.cli.studies package
- imednet.cli.subjects package
- imednet.cli.utils package
- imednet.cli.variables package
- Submodules
- imednet.cli.decorators module
- imednet.endpoints package
AsyncCodingsEndpointAsyncFormsEndpointAsyncIntervalsEndpointAsyncJobsEndpointAsyncQueriesEndpointAsyncRecordRevisionsEndpointAsyncRecordsEndpointAsyncSitesEndpointAsyncStudiesEndpointAsyncSubjectsEndpointAsyncUsersEndpointAsyncVariablesEndpointAsyncVisitsEndpointCodingsEndpointFormsEndpointIntervalsEndpointJobsEndpointQueriesEndpointRecordRevisionsEndpointRecordsEndpointSitesEndpointStudiesEndpointSubjectsEndpointUsersEndpointVariablesEndpointVisitsEndpoint- Submodules
- imednet.endpoints.codings module
- imednet.endpoints.forms module
- imednet.endpoints.intervals module
- imednet.endpoints.jobs module
- imednet.endpoints.queries module
- imednet.endpoints.record_revisions module
- imednet.endpoints.records module
- imednet.endpoints.registry module
- imednet.endpoints.sites module
- imednet.endpoints.studies module
- imednet.endpoints.subjects module
- imednet.endpoints.users module
- imednet.endpoints.variables module
- imednet.endpoints.visits module
- imednet.errors package
ApiErrorAuthenticationErrorAuthorizationErrorBadRequestErrorClientErrorConfigurationErrorConflictErrorExportBatchErrorExportConfigurationErrorExportErrorFilterConflictErrorForbiddenErrorImednetErrorNotFoundErrorOrchestratorErrorPaginationErrorPathTraversalValidationErrorPluginLoadErrorRateLimitErrorRequestErrorServerErrorUnauthorizedErrorUnknownVariableTypeErrorValidationErrorget_error_class()- Submodules
- imednet.errors.api module
- imednet.errors.base module
- imednet.errors.client module
- imednet.errors.export module
- imednet.errors.network module
- imednet.errors.orchestration module
- imednet.errors.plugin module
- imednet.errors.registry module
- imednet.errors.validation module
- imednet.form_designer package
FormBuilderFormDesignerClientLayout- Submodules
- imednet.form_designer.builder module
- imednet.form_designer.client module
- imednet.form_designer.models module
- imednet.form_designer.presets module
- imednet.integrations package
ExportSinkPartitionedStorageEnginePyArrowDatasetPartitionedStorageEngineSinkConfigexport_to_csv()export_to_duckdb()export_to_duckdb_by_form()export_to_excel()export_to_hive_parquet()export_to_json()export_to_long_sql()export_to_parquet()export_to_sql()export_to_sql_by_form()hive_parquet_query()- Submodules
- imednet.integrations.dispatcher module
- imednet.integrations.enrichment module
- imednet.integrations.export module
- imednet.integrations.parquet module
- imednet.integrations.parquet_engine module
- imednet.integrations.sink_base module
- imednet.models package
AdverseEventAnalysisAdverseEventAnalysisLabResultApiResponseBaseRecordRequestCodingCreateNewRecordRequestDeviceDeficiencyDeviceSafetyProfileDrugSafetyProfileErrorFormFormStructureFormSummaryGeneralClinicalProfileImednetBaseModelIntervalIntervalStructureJobJobStatusKeywordMappingRuleMetadataPaginationProtocolDeviationQueryQueryCommentRecordRecordDataRecordJobResponseRecordRevisionRegisterSubjectRequestResourceRegistryRoleSiteSortFieldStandardsProfileStandardsProfileRegistryStudyStudyConfigurationStudyStructureSubjectSubjectKeywordSubjectLevelAnalysisTriageAnnotationTriageHistoryEntryTriageItemTriageStatusUpdateScheduledRecordRequestUserValidationViolationVariableVisitWidgetConfigparse_bool()parse_datetime()parse_dict_or_default()parse_int_or_default()parse_list_or_default()parse_str_or_default()- Submodules
- imednet.models.base module
- imednet.models.codings module
- imednet.models.contract module
- imednet.models.engine module
- imednet.models.forms module
- imednet.models.intervals module
- imednet.models.jobs module
- imednet.models.queries module
- imednet.models.record_revisions module
- imednet.models.records module
- imednet.models.reporting module
- imednet.models.sites module
- imednet.models.standards module
- imednet.models.studies module
- imednet.models.study_config module
- imednet.models.study_structure module
- imednet.models.subjects module
- imednet.models.triage module
- imednet.models.users module
- imednet.models.variables module
- imednet.models.visits module
- imednet.orchestration package
- imednet.pagination package
- imednet.spi package
- Submodules
- imednet.spi.cli module
- imednet.spi.constants module
- imednet.spi.endpoints module
- imednet.spi.errors module
- imednet.spi.facade module
AsyncImednetFacadeAsyncImednetFacade.__init__()AsyncImednetFacade.async_create_record()AsyncImednetFacade.async_get_codings()AsyncImednetFacade.async_get_forms()AsyncImednetFacade.async_get_intervals()AsyncImednetFacade.async_get_job()AsyncImednetFacade.async_get_queries()AsyncImednetFacade.async_get_record_revisions()AsyncImednetFacade.async_get_records()AsyncImednetFacade.async_get_sites()AsyncImednetFacade.async_get_studies()AsyncImednetFacade.async_get_subjects()AsyncImednetFacade.async_get_users()AsyncImednetFacade.async_get_variables()AsyncImednetFacade.async_get_visits()AsyncImednetFacade.async_poll_job()
ImednetFacadeImednetFacade.__init__()ImednetFacade.authImednetFacade.create_record()ImednetFacade.get_codings()ImednetFacade.get_forms()ImednetFacade.get_intervals()ImednetFacade.get_job()ImednetFacade.get_queries()ImednetFacade.get_record_revisions()ImednetFacade.get_records()ImednetFacade.get_sites()ImednetFacade.get_studies()ImednetFacade.get_subjects()ImednetFacade.get_users()ImednetFacade.get_variables()ImednetFacade.get_visits()ImednetFacade.poll_job()
- imednet.spi.models module
- imednet.spi.utils module
AsyncJobPollerJobFailedErrorJobPollSummaryJobPollerJobProgressCallbackJobStatusEventJobTimeoutErrorbuild_filter_string()evaluate_job_state()flatten()format_iso_datetime()get_base_url_context()get_sqlite_connection()get_study_context()is_boolean_token()is_missing_value()mask_clinical_phi()parse_bool()parse_iso_datetime()redact_sensitive_payload()redact_sensitive_text()reset_base_url_context()sanitize_csv_formula()set_base_url_context()sqlite_connection()
- imednet.spi.validation module
- imednet.testing package
- Submodules
- imednet.testing.data_generator module
RandomDataGeneratorRandomDataGenerator.__init__()RandomDataGenerator.boolean()RandomDataGenerator.bothify()RandomDataGenerator.company()RandomDataGenerator.date_time()RandomDataGenerator.email()RandomDataGenerator.first_name()RandomDataGenerator.last_name()RandomDataGenerator.lexify()RandomDataGenerator.paragraph()RandomDataGenerator.pyfloat()RandomDataGenerator.random_element()RandomDataGenerator.random_int()RandomDataGenerator.sentence()RandomDataGenerator.user_name()RandomDataGenerator.uuid4()RandomDataGenerator.word()
- imednet.testing.fake_data module
- imednet.testing.typed_values module
- imednet.utils package
JsonDictbuild_filter_string()configure_json_logging()format_iso_datetime()parse_iso_datetime()sanitize_base_url()sanitize_csv_formula()validate_partition_key()- Submodules
- imednet.utils.arrow module
- imednet.utils.dates module
- imednet.utils.db module
- imednet.utils.filters module
- imednet.utils.job_poller module
- imednet.utils.json_logging module
- imednet.utils.pandas module
- imednet.utils.secrets module
- imednet.utils.security module
- imednet.utils.serialization module
- imednet.utils.typing module
- imednet.utils.url module
- imednet.utils.validators module
- imednet.validation package
AsyncSchemaCacheAsyncSchemaValidatorBaseSchemaCacheBaseSchemaValidatorDataDictionaryDataDictionaryLoaderSchemaCacheSchemaValidatorvalidate_record_data()- Submodules
- imednet.validation.cache module
- imednet.validation.data_dictionary module
Submodules¶
imednet.config module¶
Global SDK configuration state.
This module provides the core configuration object for the iMednet SDK.
- class imednet.config.Config[source]¶
Bases:
objectConfiguration object for the SDK client.
- api_key¶
The API key for authentication.
- security_key¶
The security key for authentication.
- base_url¶
The base URL for the iMednet API.
- oidc_token¶
Optional OIDC token for authentication.
- timeout¶
The default timeout for network requests.
- strict_mode¶
Toggle strict mode for data validation.
- __init__(api_key=None, security_key=None, base_url=None, oidc_token=None, timeout=30.0, strict_mode=False, vpat_path='/app/docs/VPAT.md', a11y_report_path=None)¶
- Parameters:
api_key (str | None) –
security_key (str | None) –
base_url (str | None) –
oidc_token (str | None) –
timeout (float) –
strict_mode (bool) –
vpat_path (str) –
a11y_report_path (str | None) –
- Return type:
None
- imednet.config.load_config(api_key=None, security_key=None, base_url=None, oidc_token=None, timeout=None, strict_mode=None, vpat_path=None, a11y_report_path=None)[source]¶
Return configuration using arguments or environment variables.
- Parameters:
api_key (
Optional[str]) – The API key for authentication. Defaults to IMEDNET_API_KEY environment variable.security_key (
Optional[str]) – The security key for authentication. Defaults to IMEDNET_SECURITY_KEY environment variable.base_url (
Optional[str]) – The base URL for the iMednet API. Defaults to IMEDNET_BASE_URL environment variable.oidc_token (
Optional[str]) – Optional OIDC token. Defaults to IMEDNET_OIDC_TOKEN environment variable.timeout (
Optional[float]) – HTTP request timeout in seconds. Defaults to IMEDNET_TIMEOUT environment variable or 30.0.strict_mode (
Optional[bool]) – Toggle strict mode for data validation. Defaults to IMEDNET_STRICT_MODE environment variable or False.vpat_path (
Optional[str]) – Path to the VPAT file. Defaults to IMEDNET_VPAT_PATH environment variable.a11y_report_path (
Optional[str]) – Path to the a11y report. Defaults to IMEDNET_A11Y_REPORT_PATH environment variable.
- Return type:
- Returns:
The loaded SDK configuration.
- Raises:
ValueError – If required authentication parameters are missing.
imednet.constants module¶
Common constants used throughout the iMednet SDK.
This module centralizes configuration constants to avoid magic numbers and improve maintainability.
- imednet.constants.CONTENT_TYPE_JSON = 'application/json'¶
JSON content type value.
- imednet.constants.DEFAULT_BACKOFF_FACTOR = 1.0¶
Default backoff factor for exponential retry delays.
- imednet.constants.DEFAULT_BASE_URL = 'https://edc.prod.imednetapi.com'¶
Default base URL for the iMednet API.
- imednet.constants.DEFAULT_PAGE_SIZE = 100¶
Default number of items to fetch per page.
- imednet.constants.DEFAULT_RETRIES = 3¶
Default number of retry attempts for failed requests.
- imednet.constants.DEFAULT_TIMEOUT = 30.0¶
Default timeout in seconds for HTTP requests.
- imednet.constants.HEADER_ACCEPT = 'Accept'¶
HTTP Accept header name.
- imednet.constants.HEADER_API_KEY = 'x-api-key'¶
iMednet API key header name.
- imednet.constants.HEADER_CONTENT_TYPE = 'Content-Type'¶
HTTP Content-Type header name.
- imednet.constants.HEADER_EMAIL_NOTIFY = 'x-email-notify'¶
iMednet email notification header name.
- imednet.constants.HEADER_SECURITY_KEY = 'x-imn-security-key'¶
iMednet security key header name.
- imednet.constants.LARGE_PAGE_SIZE = 500¶
Page size for endpoints with large metadata (forms, intervals, variables).
- imednet.constants.MAX_SQLITE_COLUMNS = 2000¶
Maximum number of columns allowed in a SQLite table.
When exporting data to SQLite, tables exceeding this limit must be split into multiple tables.
- imednet.constants.TERMINAL_JOB_STATES = frozenset({'', 'CANCELLED', 'COMPLETED', 'FAILED', 'SUCCESS'})¶
Job states that indicate the job has finished processing.
These states are used by the job poller to determine when to stop polling. Jobs in these states will not transition to another state.
imednet.discovery module¶
Runtime discovery utilities for live tests and scripts.
- exception imednet.discovery.NoLiveDataError[source]¶
Bases:
RuntimeErrorRaised when required live data cannot be found.
- imednet.discovery.discover_form_key(sdk, study_key)[source]¶
Return the first subject record form key for
study_key.- Return type:
str- Parameters:
sdk (ImednetSDK) –
study_key (str) –
- imednet.discovery.discover_interval_name(sdk, study_key)[source]¶
Return the first non-disabled interval name for
study_key.- Return type:
str- Parameters:
sdk (ImednetSDK) –
study_key (str) –
- imednet.discovery.discover_site_name(sdk, study_key)[source]¶
Return the first eligible site name for
study_key.A site is eligible when its
site_enrollment_statusis one ofELIGIBLE_SITE_STATUSES. When no eligible site is found the encountered statuses are logged so callers can distinguish missing data from unsupported status vocabulary.- Return type:
str- Parameters:
sdk (ImednetSDK) –
study_key (str) –
- imednet.discovery.discover_study_key(sdk)[source]¶
Return the first study key available for the provided SDK.
- Return type:
str- Parameters:
sdk (ImednetSDK) –
- imednet.discovery.discover_subject_key(sdk, study_key)[source]¶
Return the first eligible subject key for
study_key.A subject is eligible when its
subject_statusis one ofELIGIBLE_SUBJECT_STATUSES. When no eligible subject is found the encountered statuses are logged so callers can distinguish missing data from unsupported status vocabulary.- Return type:
str- Parameters:
sdk (ImednetSDK) –
study_key (str) –
imednet.plugins module¶
Plugin contracts for the iMednet SDK.
This module defines the PluginProtocol that any third-party plugin
factory must satisfy in order to be discoverable via the imednet.plugins
entry-point group, together with the WorkflowsNamespaceProtocol that
the factory’s return value must implement.
Minimal plugin skeleton¶
A plugin package must:
Expose a factory callable under the
imednet.pluginsentry-point group with the name"workflows"(or another agreed name).The callable must accept a single argument — the
ImednetSDK(orAsyncImednetSDK) instance — and return an object that satisfiesWorkflowsNamespaceProtocol.
Example pyproject.toml snippet:
[project.entry-points."imednet.plugins"]
workflows = "myplugin.namespace:create_workflows"
Example factory:
# myplugin/namespace.py
from imednet.sdk import ImednetSDK
class MyWorkflows:
def __init__(self, sdk: ImednetSDK) -> None:
self.data_extraction = ...
self.query_management = ...
self.record_mapper = ...
self.record_update = ...
self.subject_data = ...
def create_workflows(sdk: ImednetSDK) -> MyWorkflows:
return MyWorkflows(sdk)
- class imednet.plugins.PluginProtocol[source]¶
Bases:
ProtocolProtocol that every iMednet plugin factory must satisfy.
A conforming factory is a callable that accepts an SDK instance and returns an object implementing
WorkflowsNamespaceProtocol.Example:
from imednet.plugins import PluginProtocol from imednet.sdk import ImednetSDK class MyWorkflows: def __init__(self, sdk: ImednetSDK) -> None: self.data_extraction = ... self.query_management = ... self.record_mapper = ... self.record_update = ... self.subject_data = ... def create_workflows(sdk: ImednetSDK) -> MyWorkflows: return MyWorkflows(sdk) # Verify conformance at import time (optional, for development use): assert isinstance(create_workflows, PluginProtocol)
- __init__(*args, **kwargs)¶
- class imednet.plugins.SinksNamespaceProtocol[source]¶
Bases:
ProtocolMinimal interface that a sinks namespace object must expose.
- __init__(*args, **kwargs)¶
imednet.sdk module¶
Public entry-point for the iMednet SDK.
This module provides the ImednetSDK class which: - Manages configuration and authentication - Exposes all endpoint functionality through a unified interface - Provides context management for proper resource cleanup
- class imednet.sdk.AsyncImednetSDK[source]¶
Bases:
_BaseSDK,AsyncSDKConvenienceMixinAsync variant of
ImednetSDKusing the async HTTP client.Always use this class with
async withor callawait sdk.aclose()explicitly when done. Using the synchronous context manager (with) or synchronousclose()on this class will raise aTypeError.- __init__(api_key=None, security_key=None, base_url=None, timeout=None, strict_mode=None, retry_config=None, async_client=None, retries=None, backoff_factor=None, retry_policy=None)[source]¶
Initialize the asynchronous SDK.
- Parameters:
api_key (
Optional[str]) – iMednet API key.security_key (
Optional[str]) – iMednet security key.base_url (
Optional[str]) – Base URL for the iMednet API.timeout (
Optional[float]) – Default request timeout in seconds.strict_mode (
Optional[bool]) – Toggle strict mode for data validation.retry_config (
Optional[RetryConfig]) – Centralized configuration for retry behaviors.async_client (
Optional[AsyncClient]) – Pre-configured async client instance.retries (
Optional[int]) – Number of retries for failed requests.backoff_factor (
Optional[float]) – Backoff factor for retry delays.retry_policy (
Optional[RetryPolicy]) – Custom retry policy.
- Return type:
None
- async aclose()[source]¶
Close the underlying asynchronous client and free resources.
- Return type:
None
- property auth: Any¶
Return the authentication provider used by the async client.
- property retry_policy: RetryPolicy¶
Return the current retry policy of the async client.
- class imednet.sdk.ImednetSDK[source]¶
Bases:
_BaseSDK,SyncSDKConvenienceMixinPublic entry-point for library users.
Provides access to all iMednet API endpoints and maintains configuration.
- __init__(api_key=None, security_key=None, base_url=None, timeout=None, strict_mode=None, retry_config=None, client=None, retries=None, backoff_factor=None, retry_policy=None)[source]¶
Initialize the SDK with credentials and configuration.
- Parameters:
api_key (str | None) –
security_key (str | None) –
base_url (str | None) –
timeout (float | None) –
strict_mode (bool | None) –
retry_config (RetryConfig | None) –
client (Client | None) –
retries (int | None) –
backoff_factor (float | None) –
retry_policy (RetryPolicy | None) –
- Return type:
None
- async aclose()[source]¶
Asynchronous close is not supported on the synchronous SDK.
- Return type:
None
- property auth: Any¶
Return the authentication provider used by the client.
- property retry_policy: RetryPolicy¶
Return the current retry policy.
imednet.sdk_convenience module¶
Convenience mixins for the iMedNet SDK.
These mixins contain high-level helper methods that delegate to specific endpoints. They are architecturally linked to the core execution engine.
- class imednet.sdk_convenience.AsyncSDKConvenienceMixin[source]¶
Bases:
objectAsynchronous SDK convenience methods.
- async async_create_record(study_key, records_data, email_notify=None, *, schema=None)[source]¶
Asynchronously create records in the specified study.
- Return type:
- Parameters:
study_key (str) –
records_data (list[dict[str, Any]]) –
email_notify (bool | str | None) –
schema (Any) –
- imednet.sdk_convenience.SDKConvenienceMixin¶
alias of
SyncSDKConvenienceMixin
- class imednet.sdk_convenience.SyncSDKConvenienceMixin[source]¶
Bases:
objectSynchronous SDK convenience methods.
- create_record(study_key, records_data, email_notify=None, *, schema=None)[source]¶
Create records in the specified study.
- Return type:
- Parameters:
study_key (str) –
records_data (list[dict[str, Any]]) –
email_notify (bool | str | None) –
schema (Any) –