Utils
seed_data.utils
Shared utilities for the orchestrator.
bundled_schemas_dir()
Path to the schemas/ directory shipped inside the installed package.
Source code in seed_data/utils.py
21 22 23 | |
clone_schema_library(dest)
Copy the bundled schema library out to a local, editable directory.
Users install seed-data from PyPI, so the built-in schemas live inside
site-packages where they cannot be edited comfortably. This copies the whole
library to dest so users can tweak schemas and point --schema-dir at them.
Returns the path the schemas were copied to. Raises if dest already exists.
Source code in seed_data/utils.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
load_schema_dir(schema_dir)
Load schema.json, *.md steering docs, and sample PDFs from a directory.
Returns:
| Type | Description |
|---|---|
tuple[dict, str, list[str]]
|
(schema_dict, steering_text, sample_pdf_paths) |
Source code in seed_data/utils.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
make_model(model_key, thinking_budget=0, role='', session=None, temperature=None)
Create a BedrockModel from a MODELS key or raw model ID.
model_key may be a key in MODELS or a raw Bedrock model ID (for region
portability, e.g. an EU/GovCloud inference profile). session is an optional
boto3 Session for in-process use (containers, Lambda, AgentCore); if omitted,
one is resolved from the environment via get_boto_session.
temperature is optional so the structured/ingest agents — which each run at
their own sampling temperature — can come through this factory rather than
constructing BedrockModel themselves. This is the only place boto_session
is wired, so a call site that bypasses it silently ignores the caller's session.
Source code in seed_data/utils.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
safe_path_segment(name, fallback)
Reduce a model-supplied name to a single safe path segment.
Any name that reaches the filesystem having come from a model is untrusted:
../../../../tmp/pwned joined onto an output directory escapes it, and
os.makedirs will happily create the result. Keeps only the basename, maps
anything outside [alnum]-_ to -, strips leading/trailing dots and
dashes, and substitutes fallback when nothing usable is left (an empty
segment would write into the parent instead of a subdirectory).
Shared by packet_infer (for schema_dir_name, at inference time) and
packet (for document_class, at generation time). Both are needed:
sanitizing only at inference leaves a hand-written or previously-generated
packet.json unguarded, so the check belongs at every point a name becomes
a path.
Source code in seed_data/utils.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |