plexus.dashboard.api.models.score module

Score Model - Python representation of the GraphQL Score type.

Represents a scoring method within a scorecard section, tracking: - Configuration and metadata - AI model details - Performance metrics - Version history

class plexus.dashboard.api.models.score.Score(id: str, name: str, key: str, externalId: str, type: str, order: int, sectionId: str, accuracy: float | None = None, version: str | None = None, aiProvider: str | None = None, aiModel: str | None = None, client: ForwardRef('_BaseAPIClient') | None = None)

Bases: BaseModel

__init__(id: str, name: str, key: str, externalId: str, type: str, order: int, sectionId: str, accuracy: float | None = None, version: str | None = None, aiProvider: str | None = None, aiModel: str | None = None, client: _BaseAPIClient | None = None)
accuracy: float | None = None
aiModel: str | None = None
aiProvider: str | None = None
create_version_from_code(code_content: str, note: str | None = None, guidelines: str | None = None) Dict[str, Any]

Create a new score version from code and guidelines content.

This is the foundational method that only creates a new version if the content has changed from the current champion version.

Args:

code_content: The YAML code content as a string note: Optional version note. Defaults to “Updated via Score.create_version_from_code()” guidelines: Optional guidelines content as a string

Returns:
Dict containing:
  • success: bool

  • version_id: str (new version ID if created, existing if no changes)

  • champion_updated: bool (whether champion version was updated)

  • message: str (success/error message)

  • skipped: bool (true if no changes detected)

create_version_from_yaml(yaml_content: str, note: str | None = None) Dict[str, Any]

Create a new score version from YAML content string.

Args:

yaml_content: The YAML configuration content as a string note: Optional version note.

Returns:
Dict containing:
  • success: bool

  • version_id: str (new version ID if created, existing if no changes)

  • champion_updated: bool (whether champion version was updated)

  • skipped: bool (true if no changes detected)

  • error: str (error message if failed)

externalId: str
classmethod fields() str

Return the GraphQL fields to query for this model

classmethod from_dict(data: Dict[str, Any], client: _BaseAPIClient) Score

Create an instance from a dictionary of data

classmethod get_by_external_id(external_id: str, scorecard_id: str, client: _BaseAPIClient) Score | None

Get a score by its external ID

classmethod get_by_id(id: str, client: _BaseAPIClient) Score
classmethod get_by_key(key: str, scorecard_id: str, client: _BaseAPIClient) Score | None

Get a score by its key

classmethod get_by_name(name: str, scorecard_id: str, client: _BaseAPIClient) Score | None

Get a score by its name

classmethod get_by_scorecard_and_external_id(scorecard_id: str, external_id: str, client: _BaseAPIClient) Dict[str, Any] | None

Get a score by scorecard ID and external ID using the GSI.

This uses the byScorecardIdAndExternalId GSI for efficient lookup.

Args:

scorecard_id: The scorecard ID to filter by external_id: The score external ID to look up client: The API client instance

Returns:

Dict with ‘id’ and ‘name’ keys if found, None otherwise

get_champion_code_yaml() str | None

Get the raw YAML code string from the champion version.

Returns:

Optional[str]: The raw YAML code string, or None if not found

get_champion_configuration_yaml() str | None

Get the raw YAML configuration string from the champion version.

Returns:

Optional[str]: The raw YAML configuration string, or None if not found

get_code() Dict[str, Any] | None

Get the score’s code from its champion version.

Returns:

Optional[Dict[str, Any]]: The parsed YAML code, or None if not found

get_local_code_path(scorecard_name: str | None = None) Path

Get the local YAML file path for this score’s code.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API.

Returns:

Path: Path to the local YAML code file

get_local_configuration_path(scorecard_name: str | None = None) Path

Get the local YAML file path for this score’s configuration.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API.

Returns:

Path: Path to the local YAML configuration file

get_local_guidelines_path(scorecard_name: str | None = None) Path

Get the local file path for this score’s guidelines.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API.

Returns:

Path: Path to the local guidelines file

get_valid_classes() List[Dict[str, Any]]

Get the list of valid classes from the score’s code.

Looks for a ‘classes’ key in the score’s YAML configuration, where each class has at least a ‘name’ field and may have additional metadata like ‘positive’.

Example YAML format: ```yaml classes:

  • name: Yes positive: true

  • name: No

```

Returns:
List[Dict[str, Any]]: List of valid class dictionaries, each containing at least a ‘name’ key

and any additional metadata from the configuration. Returns empty list if not found or on error.

get_valid_classes_count() int

Get the number of valid classes from the score’s configuration.

This method looks at: 1. The explicit valid_classes list in the configuration 2. Any output values specified in conditions that might add additional classes

Returns:

int: Number of valid classes, defaulting to 2 (binary classification) if not found.

key: str
classmethod list_by_section_id(section_id: str, client: _BaseAPIClient, next_token: str | None = None, limit: int = 100) Dict[str, Any]

Get all scores for a section with pagination support

Returns:
Dict containing:
  • items: List of Score objects

  • nextToken: Token for next page if more results exist

name: str
order: int
pull_code_and_guidelines(scorecard_name: str | None = None) Dict[str, Any]

Pull the champion version code and guidelines to local files.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API.

Returns:
Dict containing:
  • success: bool

  • code_file_path: str (path where code was saved)

  • guidelines_file_path: str (path where guidelines were saved)

  • version_id: str (the champion version ID that was pulled)

  • message: str (success/error message)

pull_configuration(scorecard_name: str | None = None) Dict[str, Any]

Pull the champion version configuration to local file.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API.

Returns:
Dict containing:
  • success: bool

  • file_path: str (path where configuration was saved)

  • version_id: str (the champion version ID that was pulled)

  • error: str (error message if failed)

push_code_and_guidelines(scorecard_name: str | None = None, note: str | None = None) Dict[str, Any]

Push local code and guidelines files as a new score version.

Automatically detects which files have changed by comparing with the current champion version. Only creates a new version if either code or guidelines have changed.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API. note: Optional version note. Defaults to “Updated via Score.push_code_and_guidelines()”

Returns:
Dict containing:
  • success: bool

  • version_id: str (new version ID if created, existing if no changes)

  • champion_updated: bool (whether champion version was updated)

  • message: str (success/error message)

  • skipped: bool (true if no changes detected)

  • changes_detected: dict with ‘code’ and ‘guidelines’ booleans indicating what changed

push_configuration(scorecard_name: str | None = None, note: str | None = None) Dict[str, Any]

Push local configuration file as a new score version.

Args:

scorecard_name: Optional scorecard name. If not provided, will lookup via API. note: Optional version note.

Returns:
Dict containing:
  • success: bool

  • version_id: str (new version ID if created, existing if no changes)

  • champion_updated: bool (whether champion version was updated)

  • skipped: bool (true if no changes detected)

  • error: str (error message if failed)

sectionId: str
type: str
version: str | None = None