# Configuration reference

The defaults are tuned for a long list of image URLs on an ordinary computer and connection. Most people change nothing.

Set an option in any of these ways; they all end up in the same [`DownloadConfig`](<https://divyanshusingh96.github.io/machyon/reference/python-api/index.md#machyon.DownloadConfig> "<code class=\"doc-symbol doc-symbol-heading doc-symbol-class\"></code>            <span class=\"doc doc-object-name doc-class-name\">DownloadConfig</span>     <span class=\"doc doc-labels\">       <small class=\"doc doc-label doc-label-dataclass\"><code>dataclass</code></small>   </span>"):

```python
machyon.download("urls.csv", "images/", max_retries=8, referer="https://example.com/")
```

```python
cfg = machyon.DownloadConfig(max_retries=8, referer="https://example.com/")
machyon.download("urls.csv", "images/", config=cfg)
```

```bash
machyon urls.csv -o images/ --retries 8 --referer https://example.com/
```

machyon.ini

```ini
[SETTINGS]
max_retries = 8
referer = https://example.com/
```

`DownloadConfig.from_ini("machyon.ini")`, or `machyon --config machyon.ini`. Keys are field names, in any case. Dictionary options (`headers`) can't be set from INI files; pass them in code or with `--header`.

## All options

A flag shown as `--no-adaptive` turns a `True` default off. Options without a flag are available from Python and INI files only.

### Concurrency

`concurrency`default `32`CLI `--concurrency`

Starting number of in-flight requests. With `adaptive=True` this is only a starting point.

`max_concurrency`default `256`CLI `--max-concurrency`

Hard ceiling for in-flight requests and the size of the connection pool.

`adaptive`default `True`CLI `--no-adaptive`

Tune concurrency live: grow while throughput improves, back off on 429s and errors.

`hedge`default `True`CLI `--no-hedge`

Near the end of a batch, race a duplicate request against stragglers; first one wins.

`warm_start`default `True`

Remember the best concurrency per host and start there next time.

`profile_path`default `~/.machyon/profiles.json`

Where warm-start profiles live. Default: `~/.machyon/profiles.json`.

### Retries and timeouts

`max_retries`default `5`CLI `--retries`

Retries per URL after the first attempt (timeouts, resets, 408/425/429/5xx), in each round: the pass and, with `retry_failures`, the final sweep.

`backoff`default `0.5`

Base seconds for exponential backoff with jitter.

`timeout`default `15.0`CLI `--timeout`

Connect timeout and maximum silence between received bytes, in seconds.

`max_request_time`default `120.0`

Hard cap for one attempt; extended automatically in proportion to large bodies.

`max_retry_after`default `120.0`

Upper bound on how long a server's `Retry-After` may pause a host.

### HTTP

`headers`default `{}`CLI `--header`

Extra request headers (auth tokens, cookies, ...).

`referer`default `None`CLI `--referer`

Value of the `Referer` header sent with every request (hotlink-protected sites).

`user_agent`default browser identity

The `User-Agent` header. Default: one current, stable desktop browser identity.

`verify_ssl`default `True`CLI `--insecure`

Verify TLS certificates. Turn off only for hosts you trust (`--insecure`).

`tls_trust`default `'native'`CLI `--tls-trust`

Where trusted CAs come from: "native" (OS store via truststore, like your browser), "certifi" (Mozilla bundle, like requests) or "python" (Python's defaults).

`use_compression`default `True`

`False` sends `Accept-Encoding: identity`.

### Files

`validate`default `True`CLI `--no-validate`

Reject bodies that aren't images (HTML "soft 404" pages, JSON errors, ...).

`verify_existing`default `False`CLI `--verify-existing`

Before skipping a file that already exists, check it really is an image.

`fsync`default `False`

Flush every file to physical disk before renaming it into place (slower, power-loss safe).

`stream_threshold`default `4 MiB`

Bodies larger than this (or of unknown size) stream to disk and can resume with Range.

`write_threads`default min(32, 4 × CPUs)

Threads for file I/O. Default: min(32, 4 x CPUs).

`shard_size`default `200_000`

Rows planned at a time; keeps memory flat for inputs of any size.

### Reporting

`progress`default `True`CLI `--no-progress`

Show the progress bar.

`log_dir`default `None`CLI `--log`

Write a rotating `machyon.log` here. `None` = no log file.

`metrics_dir`default `None`CLI `--metrics`

Append a JSON entry per run to `metrics_json_info.json` here. `None` = off.

## Where things are written

| Path | Written when | Contents |
| --- | --- | --- |
| `<save_dir>/failed_downloads.jsonl` | Something failed | [The failure ledger](<https://divyanshusingh96.github.io/machyon/reliability/failure-ledger/index.md>) |
| `<save_dir>/failed_downloads.txt` | Something failed | The failed URLs, one per line |
| `<save_dir>/.<name>.machpart` | During a streamed download | A partial body, kept for resuming; removed when finished or abandoned |
| `~/.machyon/profiles.json` | After a run that downloaded something, with `adaptive` and `warm_start` on | The concurrency learned per host |
| `<metrics_dir>/metrics_json_info.json` | `metrics_dir` is set | One summary entry per run |
| `<log_dir>/machyon.log` | `log_dir` is set | A rotating log |
