LocalFile
dorsal.file.dorsal_file.LocalFile
LocalFile(
file_path,
client=None,
model_runner_pipeline="default",
use_cache=True,
overwrite_cache=False,
offline=False,
follow_symlinks=True,
_file_record=None,
)
Bases: _DorsalFile
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Absolute or relative path to the local file. |
required |
client
|
DorsalClient | None
|
An optional DorsalClient instance to use for |
None
|
model_runner_pipeline
|
str | list[dict[str, Any]] | None
|
Optional configuration for the ModelRunner instance. |
'default'
|
use_cache
|
bool
|
Whether to use the local cache to speed up processing. Defaults to True. |
True
|
overwrite_cache
|
bool
|
Whether to run the full pipeline and overwrite the cache result. Defaults to False |
False
|
offline
|
bool
|
If True, puts the instance in Offline Mode. Blocks network calls from |
False
|
follow_symlinks
|
bool
|
If True (default), resolves symbolic links to their target content. If False, uses the path as-is (potentially resulting in link metadata). |
True
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file_path does not exist or is not a file. |
IOError
|
If there are issues reading the file. |
DorsalClientError
|
If model runner encounters an issue that it wraps. |
TypeError
|
If file_path is not a string. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 | |
model
instance-attribute
Represents a file on the local filesystem.
Triggers an offline metadata extraction pipeline that generates/infers metadata for this file. Includes methods for updating, managing and indexing (to DorsalHub) the file metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The primary SHA-256 hash of the file content. |
name |
str
|
The base name of the file. |
size |
int
|
The file size in bytes. |
media_type |
str
|
The detected media type of the file. |
tags |
list[FileTag]
|
A list of tags associated with the file. |
annotations |
object
|
A container for detailed metadata records.
Specific annotations like |
Example
from dorsal import LocalFile
# This line processes the file and populates its metadata.
local_file = LocalFile("path/to/my/document.pdf")
# Strict Offline usage (Blocks all network calls e.g. for validation or indexing)
offline_file = LocalFile("path/to/doc.pdf", offline=True)
print(f"Hashed {local_file.name} ({local_file.size} bytes)")
if local_file.pdf:
print(f"It has {local_file.pdf.page_count} pages.")
add_classification
add_classification(
labels,
*,
vocabulary=None,
source=None,
score_explanation=None,
vocabulary_url=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds an 'open/classification' annotation to the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
list[str | ClassificationLabel]
|
can be simple strings (e.g., ["cat"]) or dictionaries. |
required |
vocabulary
|
list[str] | None
|
List of valid labels for this classification task. |
None
|
source
|
str | None
|
Source of the classification. |
None
|
score_explanation
|
str | None
|
Explanation string for the score. |
None
|
vocabulary_url
|
str | None
|
URL to the vocabulary definition. |
None
|
public
|
bool
|
If True, marks annotation as public. |
False
|
overwrite
|
bool
|
If True, overwrites existing classification. |
False
|
api_key
|
str | None
|
API key for validation. |
None
|
ignore_linter_errors
|
bool
|
Skip linter checks. |
False
|
force
|
bool
|
Force add without validation. |
False
|
example
Only labels
lf.add_classification(labels=["EXPIRED", "COMPLETED"])
Labels with vocabulary
lf.add_classification(labels=["eng"], vocabulary=["eng", "fra", "deu"])
Labels, vocabulary, attributes and source
lf.add_classification( labels=[ { "label": "SENSITIVE", "score": 0.95, "attributes": { "page_number": 22, "context": "This document contains sensitive information" } } ], vocabulary=["SENSITIVE", "INTERNAL", "PUBLIC"], source="MySensitiveDocumentScannerV1.0" )
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 | |
add_embedding
add_embedding(
vector,
*,
model=None,
target=None,
source=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds an 'open/embedding' annotation to the file.
This helper provides a convenience wrapper for adding a simple embedding (feature vector) to the file record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
The embedding vector. |
required |
model
|
str
|
Name of the algorithm or model that generated the embedding (e.g., 'CLIP', 'text-embedding-ada-002'). |
None
|
target
|
str
|
Name of target feature/variable |
None
|
source
|
str
|
An optional string describing the source of the annotation (e.g., 'Local CLIP Model v1.2'). This will be passed to the 'detail' field. |
None
|
public
|
bool
|
Whether the annotation should be public. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite an existing annotation. |
False
|
api_key
|
str
|
API key for validation. |
None
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is missing a 'validation_hash'. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
add_label
Adds a private 'label' tag to the local file model.
This method modifies self.model.tags locally.
To synchronize these tags with DorsalHub, call push on the instance.
Note: This is strictly a private tag because "label" is not a whitelisted public tag namespace on DorsalHub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | bool | int | float | datetime
|
Value of the label (str, bool, datetime, int, or float). |
required |
api_key
|
str | None
|
Optional API key to use for validation. |
None
|
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
add_llm_output
add_llm_output(
model,
response_data,
*,
prompt=None,
language=None,
score=None,
score_explanation=None,
generation_params=None,
generation_metadata=None,
source=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds an 'open/llm-output' annotation to the file.
This helper provides a convenience wrapper for storing the output of a Large Language Model (LLM) task related to this file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The ID or name of the generative model used (e.g., 'gpt-4o'). |
required |
response_data
|
str | dict
|
The generative output from the model. Can be a string or a simple key-value dictionary. |
required |
prompt
|
str
|
The text-based task or prompt provided to the model. |
None
|
language
|
str
|
The 3-letter ISO-639-3 language code of the response (e.g., 'eng'). |
None
|
score
|
float
|
An optional confidence or evaluation score for the generated output, from -1 to 1. |
None
|
generation_params
|
dict
|
Optional parameters sent in the API request (e.g., {"temperature": 0.5, "max_tokens": 1000}). |
None
|
generation_metadata
|
dict
|
Optional metadata returned by the API response (e.g., {"usage": {...}, "finish_reason": "stop"}). |
None
|
source
|
str
|
An optional string describing the source of the annotation (e.g., 'OpenAI Summarizer v3'). This will be passed to the 'detail' field. |
None
|
public
|
bool
|
Whether the annotation should be public. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite an existing annotation. |
False
|
api_key
|
str
|
API key for validation. |
None
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is missing a 'validation_hash'. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 | |
add_location
add_location(
longitude,
latitude,
*,
timestamp=None,
camera_make=None,
camera_model=None,
bbox=None,
source=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds an 'open/geolocation' annotation for a simple Point.
This helper provides a convenience wrapper for the common use case of tagging a file with a single GPS coordinate (longitude, latitude) and optional EXIF-like data.
It automatically builds the required GeoJSON Feature object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
longitude
|
float
|
The longitude coordinate (e.g., -0.5895). |
required |
latitude
|
float
|
The latitude coordinate (e.g., 51.3814). |
required |
timestamp
|
str
|
An ISO 8601 timestamp for when the geospatial data was captured (e.g., "2025-09-17T11:45:00Z"). |
None
|
camera_make
|
str
|
The make of the camera or sensor. |
None
|
camera_model
|
str
|
The model of the camera or sensor. |
None
|
source
|
str
|
An optional string describing the source of the annotation (e.g., 'EXIF Data Parser'). This will be passed to the 'detail' field. |
None
|
public
|
bool
|
Whether the annotation should be public. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite an existing annotation. |
False
|
api_key
|
str
|
API key for validation. |
None
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is missing a 'validation_hash'. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 | |
add_private_annotation
add_private_annotation(
*,
schema_id,
annotation_record,
validator=None,
source=None,
api_key=None,
overwrite=False,
ignore_linter_errors=False,
force=False
)
Adds a private annotation to the local file model.
This is a wrapper for the _add_annotation method,
pre-setting public=False.
The annotation is added locally and will be synchronized with DorsalHub upon calling push().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_id
|
str
|
The schema used for validation (e.g., 'open/generic'). |
required |
annotation_record
|
BaseModel | dict[str, Any]
|
The annotation data (a Pydantic model or dict). |
required |
validator
|
Type[BaseModel] | JsonSchemaValidator | None
|
An optional Pydantic model class or |
None
|
source
|
str | None
|
An optional string describing the source of the manual data. |
None
|
api_key
|
str | None
|
An optional API key for fetching the schema. |
None
|
overwrite
|
bool
|
If True, overwrite an existing annotation for the same dataset. |
False
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the |
FileAnnotatorError
|
If the annotation record cannot be processed. |
Example
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 | |
add_private_tag
Adds a private file tag to the local file model.
This method modifies self.model.tags locally.
To synchronize these tags with DorsalHub, call push on the instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the tag (typically 3-64 alphanumeric characters and underscores |
required |
value
|
str | bool | int | float | datetime
|
Value of the tag (str, bool, datetime, int, or float). |
required |
api_key
|
str | None
|
Optional API key to use for validation |
None
|
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
add_public_annotation
add_public_annotation(
*,
schema_id,
annotation_record,
validator=None,
source=None,
api_key=None,
overwrite=False,
ignore_linter_errors=False,
force=False
)
Adds a public annotation to the local file model.
This is a wrapper for the _add_annotation method,
pre-setting public=True.
The annotation is added locally and will be synchronized with DorsalHub upon calling push().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_id
|
str
|
The schema used for validation (e.g., 'open/generic'). |
required |
annotation_record
|
BaseModel | dict[str, Any]
|
The annotation data (a Pydantic model or dict). |
required |
validator
|
Type[BaseModel] | JsonSchemaValidator | None
|
An optional Pydantic model class or |
None
|
source
|
str | None
|
An optional string describing the source of the manual data. |
None
|
api_key
|
str | None
|
An optional API key for fetching the schema. |
None
|
overwrite
|
bool
|
If True, overwrite an existing annotation for the same dataset. |
False
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the |
FileAnnotatorError
|
If the annotation record cannot be processed. |
Example
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 | |
add_public_tag
Adds a public file tag to the local file model.
This method modifies self.model.tags locally.
To synchronize these tags with DorsalHub, call push on the instance.
When auto_validate is True, validates the tag against the API
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the tag (typically 3-64 alphanumeric characters and underscores, subject to server-side validation if dorsal is online). |
required |
value
|
str | bool | int | float | datetime
|
Value of the tag (str, bool, datetime, int, or float). |
required |
api_key
|
str | None
|
Optional API key to use for validation |
None
|
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
add_regression
add_regression(
value,
*,
target=None,
unit=None,
producer=None,
score_explanation=None,
statistic=None,
quantile_level=None,
interval_lower=None,
interval_upper=None,
score=None,
timestamp=None,
attributes=None,
source=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds an 'open/regression' annotation for a single point estimate.
This helper creates a record containing a single data point.
Use for scalar predictions (e.g. a price).
For multi-point data (e.g. time-series, distributions), use add_private_annotation / add_public_annotation and
construct the record manually with a list of points using dorsal.file.helpers.build_regression_point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | None
|
The predicted or sampled value. |
required |
target
|
str
|
The name of the variable being predicted (e.g., 'house_price', 'credit_score'). |
None
|
unit
|
str
|
The unit of measurement (e.g., 'USD', 'kg'). |
None
|
statistic
|
str
|
The statistical nature of this value (e.g., 'mean', 'median', 'max', 'quantile'). |
None
|
quantile_level
|
float
|
If statistic='quantile', this defines the level (e.g., 0.95). |
None
|
interval_lower
|
float
|
The lower bound of the confidence interval. |
None
|
interval_upper
|
float
|
The upper bound of the confidence interval. |
None
|
timestamp
|
str | datetime
|
The specific time this prediction applies to. |
None
|
source
|
str
|
An optional string describing the source of the annotation (e.g., 'PricePredictor v1.0'). |
None
|
public
|
bool
|
Whether the annotation should be public. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite an existing annotation. |
False
|
api_key
|
str
|
API key for validation. |
None
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Examples:
Simple Point Estimate:
Prediction with Confidence Interval:
>>> lf.add_regression(
... target="temperature",
... value=22.5,
... unit="celsius",
... interval_lower=21.0,
... interval_upper=24.0
... )
Quantile Prediction:
>>> lf.add_regression(
... target="latency",
... value=150,
... unit="ms",
... statistic="quantile",
... quantile_level=0.99
... )
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 | |
add_transcription
add_transcription(
text,
language,
*,
track_id=None,
source=None,
public=False,
overwrite=False,
api_key=None,
ignore_linter_errors=False,
force=False
)
Adds a simple 'open/audio-transcription' annotation to the file.
This helper provides a convenience wrapper for the common use case of storing the full, flat text transcription of an audio file.
NOTE: This helper populates the top-level 'text' field. It does NOT handle 'segments'. For timed transcriptions, build the dictionary and use the generic 'add_private_annotation' method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The full, concatenated transcribed text. |
required |
language
|
str
|
The 3-letter ISO-639-3 language code of the transcription (e.g., 'eng'). |
required |
track_id
|
str | int
|
Identifier for the specific audio track or channel in the source file. |
None
|
source
|
str
|
An optional string describing the source of the annotation (e.g., 'Whisper v3 (simple)'). This will be passed to the 'detail' field. |
None
|
public
|
bool
|
Whether the annotation should be public. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite an existing annotation. |
False
|
api_key
|
str
|
API key for validation. |
None
|
Returns:
| Type | Description |
|---|---|
'LocalFile'
|
The LocalFile instance, for method chaining. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is missing a 'validation_hash'. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 | |
from_json
classmethod
Factory method: Instantiates a LocalFile from a JSON File Record.
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
get_annotations
Retrieves a list of annotations from the local model by schema_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_id
|
str
|
The unique identifier of the dataset/schema. |
required |
source_id
|
str | None
|
Optional. Filter custom annotations by their source ID. |
None
|
Returns:
| Type | Description |
|---|---|
Sequence[Annotation | AnnotationXL | PDFValidationModel | MediaInfoValidationModel | EbookValidationModel | OfficeDocumentValidationModel]
|
A list of annotation objects (Core models or generic Annotations). |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 | |
get_latest_annotation
Retrieves the single latest annotation for this file.
This method sorts results by date_modified (descending) and returns the most recent one.
This is useful when multiple versions of an annotation exist locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_id
|
str
|
The unique identifier of the dataset/schema. |
required |
source_id
|
str | None
|
Optional. Filter by source ID before determining the latest. |
None
|
Returns:
| Type | Description |
|---|---|
Annotation | AnnotationXL | PDFValidationModel | MediaInfoValidationModel | EbookValidationModel | OfficeDocumentValidationModel | None
|
The latest matching annotation, or None if no matches found. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
push
Indexes file's metadata (annotations and tags) to DorsalHub.
If no record exists for this hash, a new record is created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
public
|
bool
|
|
False
|
api_key
|
str
|
An API key to use for this specific request, overriding the client's default key. Defaults to None. |
None
|
strict
|
bool
|
|
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FileIndexResponse |
FileIndexResponse
|
A response object from the API detailing the result of the indexing operation. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
DorsalClientError
|
If the push operation fails due to API error, network issue, or authentication failure. |
PartialIndexingError
|
If strict=True and the response contains partial errors. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 | |
remove_annotation
Removes an annotation from the local file model.
For custom schemas, providing source_id removes only that specific entry.
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
save
Exports the File Record to a JSON file on disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The file path to write to. |
required |
indent
|
int | None
|
JSON indentation level. |
2
|
by_alias
|
bool
|
Whether to use field aliases (required for correct schema loading). |
True
|
exclude_none
|
bool
|
Whether to exclude fields with None values. |
True
|
Raises:
| Type | Description |
|---|---|
IOError
|
If the file cannot be written. |
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
to_dict
Overrides the parent method to include local file information.
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
to_json
Export the File Record to a JSON string.
Source code in venv/lib/python3.12/site-packages/dorsal/file/dorsal_file.py
validate_tags
Validates all tags against DorsalHub's API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Optional API key. |
None
|
Returns:
| Type | Description |
|---|---|
ValidateTagsResult | None
|
The validation response object from the client. |
Raises:
| Type | Description |
|---|---|
DorsalError
|
If the instance is in offline mode. |
InvalidTagError
|
If the tags are rejected by the API. |
DorsalClientError
|
If the API call fails. |