graflo.hq.bulk.run¶
Run a bulk load: open the staging directory, fold, write, verify.
Casting into the staging directory is the caster's (it hands each batch to a
:class:~graflo.hq.bulk.stage.Stager); this module does the rest. Every phase
is recorded in the run ledger, so a run stopped at any point resumes from the
last thing that completed: staging is redone, a fold is kept, written chunks
are skipped and the one in doubt is replayed.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
BulkVerifyError
¶
Functions:¶
dense_ids_for(conn_conf)
¶
Whether the target's bulk writer takes dense integer ids.
Raises:
| Type | Description |
|---|---|
ValueError
|
The target has no bulk writer. |
Source code in graflo/hq/bulk/run.py
edge_buckets_for(conn_conf, cfg)
¶
Buckets per endpoint to split edge runs into, when the writer asks for it.
Raises:
| Type | Description |
|---|---|
ValueError
|
The target has no bulk writer. |
Source code in graflo/hq/bulk/run.py
fold_staged(staging_dir, ledger, cfg, *, dense_ids, edge_buckets=None)
¶
Fold the staged runs once; a resumed run reuses the fold.
Source code in graflo/hq/bulk/run.py
open_staging(staging_dir, mode='bulk')
¶
The ledger of a new or resumable mode run (bulk or sync) in staging_dir.
A run stopped while staging is staged again from the start; one stopped later resumes.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The |
ValueError
|
staging_dir holds files but no run, or a run of the other mode. |
Source code in graflo/hq/bulk/run.py
verify(expected, actual)
¶
Refuse a load whose per-type counts differ from the fold's.
Raises:
| Type | Description |
|---|---|
BulkVerifyError
|
Listing every type that differs. |
Source code in graflo/hq/bulk/run.py
write_folded(schema, conn_conf, staging_dir, ledger, cfg, *, recreate=False)
¶
Write the folded runs to the target and check its counts against the fold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
Schema
|
The schema, logical names, initialized for the target flavor. |
required |
conn_conf
|
DBConfig
|
The target; it must declare |
required |
staging_dir
|
Path
|
A folded staging directory. |
required |
ledger
|
RunLedger
|
Its ledger. |
required |
cfg
|
BulkConfig
|
Chunk size and parallelism. |
required |
recreate
|
bool
|
Drop the target's schema first instead of refusing an existing one. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The target has no bulk writer, or (from the writer's first-write guard) already holds a schema. |
BulkVerifyError
|
The target's counts differ from the fold's. |
Source code in graflo/hq/bulk/run.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |