Skip to main content

synth_ai.sdk.artifacts.parsing

Artifact ID parsing and resolution utilities. This module provides centralized logic for parsing and validating artifact identifiers, including model IDs (peft:, ft:, rl:) and prompt job IDs (pl_, job_pl_).

Functions

parse_model_id

parse_model_id(model_id: str) -> ParsedModelId
Parse a model identifier into its components. Supports:
  • peft:BASE_MODEL:JOB_ID (canonical fine-tuned model)
  • ft:BASE_MODEL:JOB_ID (legacy fine-tuned model)
  • rl:BASE_MODEL:JOB_ID (RL model)
Args:
  • model_id: Model identifier string
Returns:
  • ParsedModelId with prefix, base_model, job_id, and full_id
Raises:
  • ValueError: If model_id format is invalid

parse_prompt_id

parse_prompt_id(prompt_id: str) -> ParsedPromptId
Parse a prompt job identifier. Supports:
  • pl_JOB_ID (canonical prompt learning job ID)
  • job_pl_JOB_ID (alternative format)
  • JOB_ID (bare job ID, assumed to be prompt learning)
Args:
  • prompt_id: Prompt job identifier string
Returns:
  • ParsedPromptId with job_id and full_id
Raises:
  • ValueError: If prompt_id format is invalid

detect_artifact_type

detect_artifact_type(artifact_id: str) -> ArtifactType
Detect the type of artifact from its ID. Args:
  • artifact_id: Artifact identifier string
Returns:
  • “model”, “prompt”, or “unknown”

is_model_id

is_model_id(artifact_id: str) -> bool
Check if an artifact ID is a model ID.

is_prompt_id

is_prompt_id(artifact_id: str) -> bool
Check if an artifact ID is a prompt job ID.

resolve_wasabi_key_for_model

resolve_wasabi_key_for_model(parsed: ParsedModelId, prefer_merged: bool = True) -> str
Resolve Wasabi storage key for a parsed model ID. This constructs the expected Wasabi key based on naming conventions. Note: This is a fallback - the backend should provide the actual key. Args:
  • parsed: Parsed model ID
  • prefer_merged: For fine-tuned models, prefer merged checkpoint over adapter
Returns:
  • Wasabi storage key path
Raises:
  • ValueError: If model type is unsupported

validate_model_id

validate_model_id(model_id: str) -> bool
Validate that a model ID has the correct format. Args:
  • model_id: Model identifier to validate
Returns:
  • True if valid, False otherwise

validate_prompt_id

validate_prompt_id(prompt_id: str) -> bool
Validate that a prompt ID has a reasonable format. Args:
  • prompt_id: Prompt identifier to validate
Returns:
  • True if valid, False otherwise

Classes

ParsedModelId

Parsed model identifier components. Methods:

is_fine_tuned

is_fine_tuned(self) -> bool
Check if this is a fine-tuned model.

is_rl

is_rl(self) -> bool
Check if this is an RL model.

ParsedPromptId

Parsed prompt job identifier components.