Skip to content
Bits & Flames Fyron Documentation GitHub
DocsDocument parameters

Document downloader: complete parameter reference

Back to the workflow guide

Use this page when you know the operation and need every argument, its actual Python default and its interactions. Signatures and parameter coverage are generated from the current source; descriptions explain operational choices.

Version scope: Fyron 0.3.20b8 (Beta 8). The reporting, deadline, naming and validation options below require Beta 5 or newer; they are not available in previously published Beta 4 packages.

Reading the tables

  • Required means the Python signature has no default. A default of None can still require environment configuration or a value from the resource.
  • Keyword only arguments must be passed by name. Boolean options accept Python True / False; None is a separate inherit/unset choice where documented.
  • Use the workflow guide for setup, authentication, return schemas and safe restarts. FHIR params and SQL schemas are site-specific; this page lists Fyron arguments, not every parameter a remote service might support.
  • These clients support with ... as client: and close(); they close owned resources and keep borrowed HTTP sessions open.

Function index

Constructor

DocumentDownloader

Signature reference (use the workflow guide for runnable calls):

python
def DocumentDownloader(
    auth=None,
    base_url=None,
    output_dir='documents_out',
    timeout=30,
    skip_existing=True,
    log_downloads=False,
    max_workers=4,
    retries=None,
    save_mode='auto',
    force_extension=None,
    basic_auth=None,
    *,
    require_pdf=False,
    allow_redirects=True,
    write_completion_record=True,
    flat_output=False,
    expected_content_types=None,
    max_download_bytes=None,
):
    ...
ParameterTypePython defaultPurpose and accepted options
authOptional[Union[Auth, requests.Session]]NoneAn existing Fyron Auth or requests.Session. Borrowed sessions stay open and retain their configuration. Use a service-approved authentication method.
base_urlOptional[str]NoneService base URL. None falls back to FHIR_BASE_URL. Documents use it only to resolve relative URLs; absolute URLs work without it.
output_dirUnion[str, pathlib.Path]'documents_out'Destination directory. DICOM creates study/series folders beneath it; documents use flat or per-document layout according to flat_output.
timeoutint30Positive finite network connect/read timeout in seconds. Python defaults to 30; document CLI defaults to 90. Not a whole-batch deadline.
skip_existingboolTrueTrue skips only outputs verified by matching completion records. False explicitly permits replacement. Disabling JSON does not make existing files automatically trusted.
log_downloadsboolFalseEnable controlled download timing, outcomes and counts. Configure console colors or JSON logging once in the application.
max_workersint4Thread count for list/DataFrame downloads. The scheduler submits at most twice the worker count at a time; results remain in input order.
retriesOptional[Retry]NoneAn optional urllib3.util.retry.Retry GET policy. None selects Fyron’s bounded default, including 429/502/503/504 and Retry-After. Existing retry-capable caller adapters retain their own policy. No automatic SQL or write retries.
save_modestr'auto'Naming choices: "auto" uses response MIME extension when available; "txt" or "pdf" appends that extension. Other values retain the URL-derived name. This changes naming, not conversion or validation.
force_extensionOptional[str]NoneOptional extension, with or without a leading dot, appended to the automatic base name. Takes precedence over save_mode. It does not convert the content.
basic_authOptional[Tuple[str, str]]NoneOptional (username, password) tuple. Do not combine with shared auth or conflicting explicit credentials.
require_pdf (keyword only)boolFalseRequire HTTP 200, PDF media type and a streamed %PDF- prefix. Does not validate full PDF syntax or clinical correctness.
allow_redirects (keyword only)boolTrueTrue follows guarded same-origin redirects; False rejects redirects. Never authorizes sending tokens to arbitrary attachment hosts.
write_completion_record (keyword only)boolTrueWrite new hidden JSON completion records for verified restarts. False omits new records; it neither deletes existing JSON nor disables token caching.
flat_output (keyword only)boolFalseTrue writes custom-ID/hash-named files directly in output_dir with absolute result paths. False uses a document subfolder. Explicit output_path overrides both.
expected_content_types (keyword only)Optional[Sequence[str]]NoneOptional nonempty sequence of exact MIME types, e.g. ["text/plain", "application/pdf"]. Comparison ignores response charset/case. No wildcards. A PDF requirement must remain compatible.
max_download_bytes (keyword only)Optional[int]NoneBeta 6: optional positive limit on decoded response bytes per document. The default permits any size.

close

close

Signature reference (use the workflow guide for runnable calls):

python
def close(
):
    ...

No arguments. Closes owned resources; call once work has finished.

download id

download_id

Signature reference (use the workflow guide for runnable calls):

python
def download_id(
    url,
):
    ...
ParameterTypePython defaultPurpose and accepted options
urlstrRequiredApproved HTTP(S) document URL, or a relative URL with a configured base URL. Embedded credentials and whitespace are rejected.

download url

download_url

Signature reference (use the workflow guide for runnable calls):

python
def download_url(
    url,
    *,
    output_path=None,
    document_id=None,
):
    ...
ParameterTypePython defaultPurpose and accepted options
urlstrRequiredApproved HTTP(S) document URL, or a relative URL with a configured base URL. Embedded credentials and whitespace are rejected.
output_path (keyword only)Optional[Union[str, pathlib.Path]]NoneOptional exact destination file for one document. Overrides automatic directory/name choices. Existing-file protection still applies.
document_id (keyword only)Optional[Union[str, int]]NoneOptional custom string/integer ID for one document. Replaces the default hash in automatic names; explicit output_path still takes precedence.

download urls

download_urls

Signature reference (use the workflow guide for runnable calls):

python
def download_urls(
    urls,
    results_csv=None,
    *,
    return_report=False,
    show_progress=False,
):
    ...
ParameterTypePython defaultPurpose and accepted options
urlsIterable[str]RequiredIterable of approved document URLs. Use a DataFrame method when you also need per-document custom IDs.
results_csvOptional[Union[str, pathlib.Path]]NoneOptional sensitive CSV of outcome rows and actual paths. Written atomically; keep it separate from downloaded files and client metadata.
return_report (keyword only)boolFalseFalse keeps the normal data return. True returns {"data": ..., "report": ...}. Read the return-format section below for the client-specific report tables.
show_progress (keyword only)boolFalseDisplay a progress bar. Units depend on the operation: pages, partitions, input queries or download tasks. Disable for noninteractive jobs; CLI quiet/no-progress/JSON settings disable bars.

download from dataframe

download_from_dataframe

Signature reference (use the workflow guide for runnable calls):

python
def download_from_dataframe(
    df,
    url_col='document_url',
    results_csv=None,
    *,
    id_col=None,
    return_report=False,
    show_progress=False,
):
    ...
ParameterTypePython defaultPurpose and accepted options
dfpd.DataFrameRequiredInput pandas DataFrame. Column labels must be unique; mapped identifiers must meet the method’s missing-value rules. Preserve identifier strings and leading zeros.
url_colstr'document_url'Input column containing document URLs.
results_csvOptional[Union[str, pathlib.Path]]NoneOptional sensitive CSV of outcome rows and actual paths. Written atomically; keep it separate from downloaded files and client metadata.
id_col (keyword only)Optional[str]NoneOptional column of unique filename-safe document IDs. Strings preserve leading zeros; integers are accepted, but floats, booleans, missing values and case-insensitive duplicates are rejected.
return_report (keyword only)boolFalseFalse keeps the normal data return. True returns {"data": ..., "report": ...}. Read the return-format section below for the client-specific report tables.
show_progress (keyword only)boolFalseDisplay a progress bar. Units depend on the operation: pages, partitions, input queries or download tasks. Disable for noninteractive jobs; CLI quiet/no-progress/JSON settings disable bars.

download from df

download_from_df

Signature reference (use the workflow guide for runnable calls):

python
def download_from_df(
    df,
    url_col='document_url',
    results_csv=None,
    *,
    id_col=None,
    return_report=False,
    show_progress=False,
):
    ...
ParameterTypePython defaultPurpose and accepted options
dfpd.DataFrameRequiredInput pandas DataFrame. Column labels must be unique; mapped identifiers must meet the method’s missing-value rules. Preserve identifier strings and leading zeros.
url_colstr'document_url'Input column containing document URLs.
results_csvOptional[Union[str, pathlib.Path]]NoneOptional sensitive CSV of outcome rows and actual paths. Written atomically; keep it separate from downloaded files and client metadata.
id_col (keyword only)Optional[str]NoneOptional column of unique filename-safe document IDs. Strings preserve leading zeros; integers are accepted, but floats, booleans, missing values and case-insensitive duplicates are rejected.
return_report (keyword only)boolFalseFalse keeps the normal data return. True returns {"data": ..., "report": ...}. Read the return-format section below for the client-specific report tables.
show_progress (keyword only)boolFalseDisplay a progress bar. Units depend on the operation: pages, partitions, input queries or download tasks. Disable for noninteractive jobs; CLI quiet/no-progress/JSON settings disable bars.

Return formats and limits

download_url returns DocumentResult; batch methods return a DataFrame, or data with report.rows / report.summary when requested. Batch results retain input order. The internal download_id remains the source URL hash even with custom filenames. PDF/MIME checks do not establish clinical validity.

Sensitive outputs: result paths, identifiers, URLs and detailed reports belong in approved research storage. Progress logs use controlled labels and counts.

Return to the workflow guide for worked examples.