Skip to content

Luna Model

An extended version of the luna_model.Model with additional methods (upload and download functionality) for integration with LunaSolve and the Luna Platform.

Bases: Model

metadata: ModelMetadata | None property writable

Return metadata for the current model instance.

If metadata is cached and corresponds to the current hash, returns the cached metadata. Otherwise, retrieves metadata via a client and updates the cache.

Returns:

  • Optional[ModelMetadata]

    Metadata for the current model instance, or None if an error occurs or metadata cannot be retrieved.

load_luna(model_id: str, client: ILunaSolve | str | None = None) -> Model staticmethod

Load a model using a specific model ID.

This function retrieves a model from a client. The client can either be provided directly or created dynamically if not specified.

Parameters:

  • model_id (str) –

    The identifier of the model that needs to be loaded.

  • client (Optional[Union[ILunaSolve, str]], default: None ) –

    The client to use for loading the model. If not provided, a client will be created automatically.

Returns:

  • Model

    The model that was successfully loaded.

save_luna(client: ILunaSolve | str | None = None) -> None

Save the model and update its metadata and hash.

This function saves the current state of the model using the provided client or default client obtained from ClientFactory. It also updates the local metadata attributes of the model after saving.

Parameters:

  • client (Optional[Union[ILunaSolve, str]], default: None ) –

    The client to facilitate saving the model. Can be an instance of ILunaSolve, a string representing the client, or left as None to use the default client.

delete_luna(client: ILunaSolve | str | None = None) -> None

Delete the Luna instance of the Model.

Ensure the model instance is removed properly using the provided client or the default client.

Parameters:

  • client (Optional[Union[ILunaSolve, str]], default: None ) –

    The client used to connect to the service. If not provided, the default client is used.

load_solutions(client: ILunaSolve | str | None = None) -> list[Solution]

Load solutions for a model.

Fetch and return the list of all solutions for the model using the provided client or the default client.

Parameters:

  • client (Optional[Union[ILunaSolve, str]], default: None ) –

    The client used to interact and retrieve model solutions. If not provided, a default client will be created using the ClientFactory.

Returns:

  • list[Solution]

    A list of Solution instances containing the solutions.

load_solve_jobs(client: ILunaSolve | str | None = None) -> list[SolveJob]

Load and return a list of SolveJob objects for the model instance.

Parameters:

  • client (Optional[Union[ILunaSolve, str]], default: None ) –

    The client object or client type for fetching solve jobs, by default None.

Returns:

  • list[SolveJob]

    A list of SolveJob objects related to the model instance.