def get_models( self, sort_by: ModelSortBy = ModelSortBy.NAME, order_by: ModelOrderBy = ModelOrderBy.ASCENDING, name: str = "", description: str = "", ) -> List[Model]: """ Get a list of all models in the model registry. Arguments: sort_by: Which field to sort by. See :class:`~determined.experimental.ModelSortBy`. order_by: Whether to sort in ascending or descending order. See :class:`~determined.experimental.ModelOrderBy`. name: If this parameter is set, models will be filtered to only include models with names matching this parameter. description: If this parameter is set, models will be filtered to only include models with descriptions matching this parameter. """ r = api.get( self._session._master, "/api/v1/models/", params={ "sort_by": sort_by.value, "order_by": order_by.value, "name": name, "description": description, }, ) models = r.json().get("models") return [Model.from_json(m, self._session._master) for m in models]
def get_model(self, name: str) -> Model: """ Get the :class:`~determined.experimental.Model` representing the model with the provided name. """ r = api.get(self._session._master, "/api/v1/models/{}".format(name)) return Model.from_json(r.json().get("model"), self._session._master)
def get_model(self, name: str) -> Model: """ Get the :class:`~determined.experimental.Model` from the model registry with the provided name. If no model with that name is found in the registry, an exception is raised. """ r = api.get(self._session._master, "/api/v1/models/{}".format(name)) return Model.from_json(r.json().get("model"), self._session._master)
def create_model(self, name: str, description: Optional[str] = "", metadata: Optional[Dict[str, Any]] = None) -> Model: """ Add a model to the registry. Arguments: name (string): The name of the model. This name must be unique. description (string): A description of the model. metadata (dict): Dictionary of metadata to add to the model. """ r = api.post( self._session._master, "/api/v1/models/{}".format(name), body={ "description": description, "metadata": metadata }, ) return Model.from_json(r.json().get("model"), self._session._master)