|
| 1 | +```{eval-rst} |
| 2 | +:tocdepth: 2 |
| 3 | +``` |
| 4 | + |
| 5 | +```{currentModule} mdio.core.config |
| 6 | +
|
| 7 | +``` |
| 8 | + |
| 9 | +# Configuration |
| 10 | + |
| 11 | +MDIO can be configured using environment variables to customize behavior for import, export, |
| 12 | +and validation operations. These variables provide runtime control without requiring code changes. |
| 13 | +You can find a summary of the available variables and their defaults below. |
| 14 | + |
| 15 | +| **Variable** | **Type** | **Default** | |
| 16 | +| ------------------------------------- | -------- | -------------------------------- | |
| 17 | +| `MDIO__IMPORT__CPU_COUNT` | `int` | Number of logical CPUs available | |
| 18 | +| `MDIO__EXPORT__CPU_COUNT` | `int` | Number of logical CPUs available | |
| 19 | +| `MDIO__GRID__SPARSITY_RATIO_WARN` | `float` | `2.0` | |
| 20 | +| `MDIO__GRID__SPARSITY_RATIO_LIMIT` | `float` | `10.0` | |
| 21 | +| `MDIO__IMPORT__SAVE_SEGY_FILE_HEADER` | `bool` | `False` | |
| 22 | +| `MDIO__IMPORT__CLOUD_NATIVE` | `bool` | `False` | |
| 23 | +| `MDIO__IMPORT__RAW_HEADERS` | `bool` | `False` | |
| 24 | +| `MDIO_IGNORE_CHECKS` | `bool` | `False` | |
| 25 | + |
| 26 | +## CPU and Performance |
| 27 | + |
| 28 | +### `MDIO__EXPORT__CPU_COUNT` |
| 29 | + |
| 30 | +Controls the number of CPUs used during SEG-Y export operations. Adjust this to balance |
| 31 | +performance with system resource availability. |
| 32 | + |
| 33 | +```shell |
| 34 | +$ export MDIO__EXPORT__CPU_COUNT=8 |
| 35 | +$ mdio segy export input.mdio output.segy |
| 36 | +``` |
| 37 | + |
| 38 | +### `MDIO__IMPORT__CPU_COUNT` |
| 39 | + |
| 40 | +Controls the number of CPUs used during SEG-Y import operations. Higher values can |
| 41 | +significantly speed up ingestion of large datasets. |
| 42 | + |
| 43 | +```shell |
| 44 | +$ export MDIO__IMPORT__CPU_COUNT=16 |
| 45 | +$ mdio segy import input.segy output.mdio --header-locations 189,193 |
| 46 | +``` |
| 47 | + |
| 48 | +## Grid Validation |
| 49 | + |
| 50 | +### `MDIO__GRID__SPARSITY_RATIO_WARN` |
| 51 | + |
| 52 | +Sparsity ratio threshold that triggers warnings during grid validation. The sparsity ratio |
| 53 | +measures how sparse the trace grid is compared to a dense grid. Values above this threshold |
| 54 | +will log warnings but won't prevent operations. |
| 55 | + |
| 56 | +```shell |
| 57 | +$ export MDIO__GRID__SPARSITY_RATIO_WARN=3.0 |
| 58 | +``` |
| 59 | + |
| 60 | +### `MDIO__GRID__SPARSITY_RATIO_LIMIT` |
| 61 | + |
| 62 | +Sparsity ratio threshold that triggers errors and prevents operations. Use this to enforce |
| 63 | +quality standards and prevent ingestion of excessively sparse datasets that may indicate |
| 64 | +data quality issues. |
| 65 | + |
| 66 | +```shell |
| 67 | +$ export MDIO__GRID__SPARSITY_RATIO_LIMIT=15.0 |
| 68 | +``` |
| 69 | + |
| 70 | +## SEG-Y Processing |
| 71 | + |
| 72 | +### `MDIO__IMPORT__SAVE_SEGY_FILE_HEADER` |
| 73 | + |
| 74 | +**Accepted values:** `true`, `false`, `1`, `0`, `yes`, `no`, `on`, `off` |
| 75 | + |
| 76 | +When enabled, preserves the original SEG-Y textual file header during import. |
| 77 | +This is useful for maintaining full SEG-Y standard compliance and preserving survey metadata. |
| 78 | + |
| 79 | +```shell |
| 80 | +$ export MDIO__IMPORT__SAVE_SEGY_FILE_HEADER=true |
| 81 | +$ mdio segy import input.segy output.mdio --header-locations 189,193 |
| 82 | +``` |
| 83 | + |
| 84 | +### `MDIO__IMPORT__CLOUD_NATIVE` |
| 85 | + |
| 86 | +**Accepted values:** `true`, `false`, `1`, `0`, `yes`, `no`, `on`, `off` |
| 87 | + |
| 88 | +Enables buffered reads during SEG-Y header scans to optimize performance when reading from or |
| 89 | +writing to cloud object storage (S3, GCS, Azure). This mode balances bandwidth usage with read |
| 90 | +latency by processing the file twice: first to determine optimal buffering, then to perform the |
| 91 | +actual ingestion. |
| 92 | + |
| 93 | +```{note} |
| 94 | +This variable is designed for cloud storage I/O, regardless of where the compute is running. |
| 95 | +``` |
| 96 | + |
| 97 | +**When to use:** |
| 98 | + |
| 99 | +- Reading from cloud storage (e.g., `s3://bucket/input.segy`) |
| 100 | +- Writing to cloud storage (e.g., `gs://bucket/output.mdio`) |
| 101 | + |
| 102 | +**When to skip:** |
| 103 | + |
| 104 | +- Local file paths on fast storage |
| 105 | +- Very slow network connections where bandwidth is the primary bottleneck |
| 106 | + |
| 107 | +```shell |
| 108 | +$ export MDIO__IMPORT__CLOUD_NATIVE=true |
| 109 | +$ mdio segy import s3://bucket/input.segy output.mdio --header-locations 189,193 |
| 110 | +``` |
| 111 | + |
| 112 | +## Development and Testing |
| 113 | + |
| 114 | +### `MDIO_IGNORE_CHECKS` |
| 115 | + |
| 116 | +**Accepted values:** `true`, `false`, `1`, `0`, `yes`, `no`, `on`, `off` |
| 117 | + |
| 118 | +Bypasses validation checks during MDIO operations. This is primarily intended for development, |
| 119 | +testing, or debugging scenarios where you need to work with non-standard data. |
| 120 | + |
| 121 | +```{warning} |
| 122 | +Disabling checks can lead to corrupted output or unexpected behavior. Only use this |
| 123 | +when you understand the implications and are working in a controlled environment. |
| 124 | +``` |
| 125 | + |
| 126 | +```shell |
| 127 | +$ export MDIO_IGNORE_CHECKS=true |
| 128 | +$ mdio segy import input.segy output.mdio --header-locations 189,193 |
| 129 | +``` |
| 130 | + |
| 131 | +## Deprecated Features |
| 132 | + |
| 133 | +### `MDIO__IMPORT__RAW_HEADERS` |
| 134 | + |
| 135 | +**Accepted values:** `true`, `false`, `1`, `0`, `yes`, `no`, `on`, `off` |
| 136 | + |
| 137 | +```{warning} |
| 138 | +This is a deprecated feature and is expected to be removed without warning in a future release. |
| 139 | +``` |
| 140 | + |
| 141 | +## Configuration Best Practices |
| 142 | + |
| 143 | +### Setting Multiple Variables |
| 144 | + |
| 145 | +You can configure multiple environment variables at once: |
| 146 | + |
| 147 | +```shell |
| 148 | +# Set for current session |
| 149 | +export MDIO__IMPORT__CPU_COUNT=16 |
| 150 | +export MDIO__GRID__SPARSITY_RATIO_LIMIT=15.0 |
| 151 | +export MDIO__IMPORT__CLOUD_NATIVE=true |
| 152 | + |
| 153 | +# Run MDIO commands |
| 154 | +mdio segy import input.segy output.mdio --header-locations 189,193 |
| 155 | +``` |
| 156 | + |
| 157 | +### Persistent Configuration |
| 158 | + |
| 159 | +To make environment variables permanent, add them to your shell profile: |
| 160 | + |
| 161 | +**Bash/Zsh:** |
| 162 | + |
| 163 | +```shell |
| 164 | +# Add to ~/.bashrc or ~/.zshrc |
| 165 | +export MDIO__IMPORT__CPU_COUNT=16 |
| 166 | +export MDIO__IMPORT__CLOUD_NATIVE=true |
| 167 | +``` |
| 168 | + |
| 169 | +**Windows:** |
| 170 | + |
| 171 | +```console |
| 172 | +# Set permanently in PowerShell (run as Administrator) |
| 173 | +[System.Environment]::SetEnvironmentVariable('MDIO__IMPORT__CPU_COUNT', '16', 'User') |
| 174 | +``` |
| 175 | + |
| 176 | +### Project-Specific Configuration |
| 177 | + |
| 178 | +For project-specific settings, use a `.env` file with tools like `python-dotenv`: |
| 179 | + |
| 180 | +```python |
| 181 | +# example_import.py |
| 182 | +from dotenv import load_dotenv |
| 183 | +import mdio |
| 184 | + |
| 185 | +load_dotenv() # Load environment variables from .env file |
| 186 | +# Your MDIO operations here |
| 187 | +``` |
| 188 | + |
| 189 | +```shell |
| 190 | +# .env file |
| 191 | +MDIO__IMPORT__CPU_COUNT=16 |
| 192 | +MDIO__GRID__SPARSITY_RATIO_LIMIT=15.0 |
| 193 | +MDIO__IMPORT__CLOUD_NATIVE=true |
| 194 | +``` |
| 195 | + |
| 196 | +## Reference |
| 197 | + |
| 198 | +```{eval-rst} |
| 199 | +.. autopydantic_model:: MDIOSettings |
| 200 | + :inherited-members: BaseSettings |
| 201 | +``` |
0 commit comments