Skip to content

Commit

Permalink
[Docs] Fix docstring format/publish (#5645)
Browse files Browse the repository at this point in the history
  • Loading branch information
jillnogold committed Jun 3, 2024
1 parent d8bf9f4 commit 3f74769
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 41 deletions.
1 change: 1 addition & 0 deletions mlrun/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ def decode_base64_config_and_load_to_object(
):
"""
decodes and loads the config attribute to expected type
:param attribute_path: the path in the default_config e.g. preemptible_nodes.node_selector
:param expected_type: the object type valid values are : `dict`, `list` etc...
:return: the expected type instance
Expand Down
63 changes: 41 additions & 22 deletions mlrun/db/httpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def api_call(
:param version: API version to use, None (the default) will mean to use the default value from config,
for un-versioned api set an empty string.
:return: `requests.Response` HTTP response object
:returns: `requests.Response` HTTP response object
"""
url = self.get_base_api_url(path, version)
kw = {
Expand Down Expand Up @@ -1526,6 +1526,7 @@ def deploy_nuclio_function(
):
"""
Deploy a Nuclio function.
:param func: Function to build.
:param builder_env: Kaniko builder pod env vars dict (for config/credentials)
"""
Expand Down Expand Up @@ -3225,7 +3226,7 @@ def get_model_endpoint(
:param feature_analysis: When True, the base feature statistics and current feature statistics will
be added to the output of the resulting object.
:return: A `ModelEndpoint` object.
:returns: A `ModelEndpoint` object.
"""

path = f"projects/{project}/model-endpoints/{endpoint_id}"
Expand Down Expand Up @@ -3570,7 +3571,7 @@ def get_hub_asset(
:param version: Get a specific version of the item. Default is ``None``.
:param tag: Get a specific version of the item identified by tag. Default is ``latest``.
:return: http response with the asset in the content attribute
:returns: http response with the asset in the content attribute
"""
path = f"hub/sources/{source_name}/items/{item_name}/assets/{asset_name}"
params = {
Expand Down Expand Up @@ -3601,9 +3602,10 @@ def verify_authorization(
def list_api_gateways(self, project=None) -> mlrun.common.schemas.APIGatewaysOutput:
"""
Returns a list of Nuclio api gateways
:param project: optional str parameter to filter by project, if not passed, default project value is taken
:return: :py:class:`~mlrun.common.schemas.APIGateways`.
:returns: :py:class:`~mlrun.common.schemas.APIGateways`.
"""
project = project or config.default_project
error = "list api gateways"
Expand All @@ -3614,10 +3616,11 @@ def list_api_gateways(self, project=None) -> mlrun.common.schemas.APIGatewaysOut
def get_api_gateway(self, name, project=None) -> mlrun.common.schemas.APIGateway:
"""
Returns an API gateway
:param name: API gateway name
:param project: optional str parameter to filter by project, if not passed, default project value is taken
:return: :py:class:`~mlrun.common.schemas.APIGateway`.
:returns: :py:class:`~mlrun.common.schemas.APIGateway`.
"""
project = project or config.default_project
error = "get api gateway"
Expand All @@ -3628,6 +3631,7 @@ def get_api_gateway(self, name, project=None) -> mlrun.common.schemas.APIGateway
def delete_api_gateway(self, name, project=None):
"""
Deletes an API gateway
:param name: API gateway name
:param project: Project name
"""
Expand All @@ -3646,11 +3650,12 @@ def store_api_gateway(
) -> mlrun.common.schemas.APIGateway:
"""
Stores an API Gateway.
:param api_gateway :py:class:`~mlrun.runtimes.nuclio.APIGateway`
or :py:class:`~mlrun.common.schemas.APIGateway`: API Gateway entity.
:param api_gateway {py:class}`~mlrun.runtimes.nuclio.APIGateway` or
{py:class}`~mlrun.common.schemas.APIGateway`: API Gateway entity.
:param project: project name. Mandatory if api_gateway is mlrun.common.schemas.APIGateway.
:return: :py:class:`~mlrun.common.schemas.APIGateway`.
:returns: :py:class:`~mlrun.common.schemas.APIGateway`.
"""

if isinstance(api_gateway, mlrun.runtimes.nuclio.api_gateway.APIGateway):
Expand All @@ -3668,6 +3673,7 @@ def store_api_gateway(
def trigger_migrations(self) -> Optional[mlrun.common.schemas.BackgroundTask]:
"""Trigger migrations (will do nothing if no migrations are needed) and wait for them to finish if actually
triggered
:returns: :py:class:`~mlrun.common.schemas.BackgroundTask`.
"""
response = self.api_call(
Expand All @@ -3690,6 +3696,7 @@ def set_run_notifications(
):
"""
Set notifications on a run. This will override any existing notifications on the run.
:param project: Project containing the run.
:param run_uid: UID of the run.
:param notifications: List of notifications to set on the run. Default is an empty list.
Expand All @@ -3715,6 +3722,7 @@ def set_schedule_notifications(
):
"""
Set notifications on a schedule. This will override any existing notifications on the schedule.
:param project: Project containing the schedule.
:param schedule_name: Name of the schedule.
:param notifications: List of notifications to set on the schedule. Default is an empty list.
Expand Down Expand Up @@ -3863,15 +3871,16 @@ def load_project(
) -> str:
"""
Loading a project remotely from the given source.
:param name: project name
:param url: git or tar.gz or .zip sources archive path e.g.:
git://github.com/mlrun/demo-xgb-project.git
http://mysite/archived-project.zip
The git project should include the project yaml file.
git://github.com/mlrun/demo-xgb-project.git
http://mysite/archived-project.zip
The git project should include the project yaml file.
:param secrets: Secrets to store in project in order to load it from the provided url. For more
information see :py:func:`mlrun.load_project` function.
information see :py:func:`mlrun.load_project` function.
:param save_secrets: Whether to store secrets in the loaded project. Setting to False will cause waiting
for the process completion.
for the process completion.
:returns: The terminal state of load project process.
"""
Expand Down Expand Up @@ -3969,9 +3978,10 @@ def generate_event(
):
"""
Generate an event.
:param name: The name of the event.
:param name: The name of the event.
:param event_data: The data of the event.
:param project: The project that the event belongs to.
:param project: The project that the event belongs to.
"""
project = project or config.default_project
endpoint_path = f"projects/{project}/events/{name}"
Expand All @@ -3990,10 +4000,11 @@ def store_alert_config(
) -> AlertConfig:
"""
Create/modify an alert.
:param alert_name: The name of the alert.
:param alert_data: The data of the alert.
:param project: the project that the alert belongs to.
:return: The created/modified alert.
:param project: The project that the alert belongs to.
:returns: The created/modified alert.
"""
project = project or config.default_project
endpoint_path = f"projects/{project}/alerts/{alert_name}"
Expand All @@ -4013,9 +4024,11 @@ def store_alert_config(
def get_alert_config(self, alert_name: str, project="") -> AlertConfig:
"""
Retrieve an alert.
:param alert_name: The name of the alert to retrieve.
:param project: The project that the alert belongs to.
:return: The alert object.
:param project: The project that the alert belongs to.
:returns: The alert object.
"""
project = project or config.default_project
endpoint_path = f"projects/{project}/alerts/{alert_name}"
Expand All @@ -4026,8 +4039,10 @@ def get_alert_config(self, alert_name: str, project="") -> AlertConfig:
def list_alerts_configs(self, project="") -> list[AlertConfig]:
"""
Retrieve list of alerts of a project.
:param project: The project name.
:return: All the alerts objects of the project.
:returns: All the alerts objects of the project.
"""
project = project or config.default_project
endpoint_path = f"projects/{project}/alerts"
Expand All @@ -4052,6 +4067,7 @@ def delete_alert_config(self, alert_name: str, project=""):
def reset_alert_config(self, alert_name: str, project=""):
"""
Reset an alert.
:param alert_name: The name of the alert to reset.
:param project: The project that the alert belongs to.
"""
Expand All @@ -4065,8 +4081,10 @@ def get_alert_template(
) -> mlrun.common.schemas.AlertTemplate:
"""
Retrieve a specific alert template.
:param template_name: The name of the template to retrieve.
:return: The template object.
:returns: The template object.
"""
endpoint_path = f"alert-templates/{template_name}"
error_message = f"get template alert-templates/{template_name}"
Expand All @@ -4076,7 +4094,8 @@ def get_alert_template(
def list_alert_templates(self) -> list[mlrun.common.schemas.AlertTemplate]:
"""
Retrieve list of all alert templates.
:return: All the alert template objects in the database.
:returns: All the alert template objects in the database.
"""
endpoint_path = "alert-templates"
error_message = "get templates /alert-templates"
Expand Down
6 changes: 2 additions & 4 deletions mlrun/model_monitoring/applications/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ModelMonitoringApplicationBaseV2(StepToDict, ABC):
Inherit from this class to create a custom model monitoring application.
example for very simple custom application::
# mlrun: start-code
class MyApp(ApplicationBase):
def do_tracking(
self,
Expand All @@ -49,7 +49,6 @@ def do_tracking(
)
# mlrun: end-code
"""

kind = "monitoring_application"
Expand Down Expand Up @@ -119,7 +118,7 @@ class ModelMonitoringApplicationBase(StepToDict, ABC):
Inherit from this class to create a custom model monitoring application.
example for very simple custom application::
# mlrun: start-code
class MyApp(ApplicationBase):
def do_tracking(
self,
Expand All @@ -145,7 +144,6 @@ def do_tracking(
)
# mlrun: end-code
"""

kind = "monitoring_application"
Expand Down
41 changes: 26 additions & 15 deletions mlrun/projects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,7 @@ def set_model_monitoring_function(
call `fn.deploy()` where `fn` is the object returned by this method.
examples::
project.set_model_monitoring_function(
name="myApp", application_class="MyApp", image="mlrun/mlrun"
)
Expand Down Expand Up @@ -1996,6 +1997,7 @@ def create_model_monitoring_function(
Create a monitoring function object without setting it to the project
examples::
project.create_model_monitoring_function(
application_class_name="MyApp", image="mlrun/mlrun", name="myApp"
)
Expand All @@ -2017,6 +2019,7 @@ def create_model_monitoring_function(
:param application_kwargs: Additional keyword arguments to be passed to the
monitoring application's constructor.
"""

_, function_object, _ = self._instantiate_model_monitoring_function(
func,
application_class,
Expand Down Expand Up @@ -2546,10 +2549,10 @@ def pull(
def create_remote(self, url, name="origin", branch=None):
"""Create remote for the project git
This method creates a new remote repository associated with the project's Git repository.
If a remote with the specified name already exists, it will not be overwritten.
This method creates a new remote repository associated with the project's Git repository.
If a remote with the specified name already exists, it will not be overwritten.
If you wish to update the URL of an existing remote, use the `set_remote` method instead.
If you wish to update the URL of an existing remote, use the `set_remote` method instead.
:param url: remote git url
:param name: name for the remote (default is 'origin')
Expand Down Expand Up @@ -2904,9 +2907,10 @@ def run(
For using the pre-defined workflow's schedule, set `schedule=True`
:param timeout: Timeout in seconds to wait for pipeline completion (watch will be activated)
:param source: Source to use instead of the actual `project.spec.source` (used when engine is remote).
Can be a one of:
1. Remote URL which is loaded dynamically to the workflow runner.
2. A path to the project's context on the workflow runner's image.
Can be one of:
* Remote URL which is loaded dynamically to the workflow runner.
* A path to the project's context on the workflow runner's image.
Path can be absolute or relative to `project.spec.build.source_code_target_dir` if defined
(enriched when building a project image with source, see `MlrunProject.build_image`).
For other engines the source is used to validate that the code is up-to-date.
Expand Down Expand Up @@ -3874,15 +3878,15 @@ def store_api_gateway(
on MLRun and Nuclio sides, such as the 'host' attribute.
Nuclio docs here: https://docs.nuclio.io/en/latest/reference/api-gateway/http.html
:param api_gateway: An instance of :py:class:`~mlrun.runtimes.nuclio.APIGateway` representing the configuration
of the API Gateway to be created or updated.
:param wait_for_readiness: (Optional) A boolean indicating whether to wait for the API Gateway to become ready
after creation or update (default is True)
:param max_wait_time: (Optional) Maximum time to wait for API Gateway readiness in seconds (default is 90s)
:param api_gateway: An instance of :py:class:`~mlrun.runtimes.nuclio.APIGateway` representing the
configuration of the API Gateway to be created or updated.
:param wait_for_readiness: (Optional) A boolean indicating whether to wait for the API Gateway to become
ready after creation or update (default is True).
:param max_wait_time: (Optional) Maximum time to wait for API Gateway readiness in seconds (default is 90s)
@return: An instance of :py:class:`~mlrun.runtimes.nuclio.APIGateway` with all fields populated based on the
information retrieved from the Nuclio API
:returns: An instance of :py:class:`~mlrun.runtimes.nuclio.APIGateway` with all fields populated based on the
information retrieved from the Nuclio API
"""

api_gateway_json = mlrun.db.get_run_db().store_api_gateway(
Expand All @@ -3904,8 +3908,8 @@ def list_api_gateways(self) -> list[mlrun.runtimes.nuclio.api_gateway.APIGateway
"""
Retrieves a list of Nuclio API gateways associated with the project.
@return: List of :py:class:`~mlrun.runtimes.nuclio.api_gateway.APIGateway` objects representing
the Nuclio API gateways associated with the project.
:returns: List of :py:class:`~mlrun.runtimes.nuclio.api_gateway.APIGateway` objects representing
the Nuclio API gateways associated with the project.
"""
gateways_list = mlrun.db.get_run_db().list_api_gateways(self.name)
return [
Expand Down Expand Up @@ -3946,6 +3950,7 @@ def store_alert_config(
) -> AlertConfig:
"""
Create/modify an alert.
:param alert_data: The data of the alert.
:param alert_name: The name of the alert.
:return: the created/modified alert.
Expand All @@ -3958,6 +3963,7 @@ def store_alert_config(
def get_alert_config(self, alert_name: str) -> AlertConfig:
"""
Retrieve an alert.
:param alert_name: The name of the alert to retrieve.
:return: The alert object.
"""
Expand All @@ -3967,6 +3973,7 @@ def get_alert_config(self, alert_name: str) -> AlertConfig:
def list_alerts_configs(self) -> list[AlertConfig]:
"""
Retrieve list of alerts of a project.
:return: All the alerts objects of the project.
"""
db = mlrun.db.get_run_db(secrets=self._secrets)
Expand All @@ -3977,6 +3984,7 @@ def delete_alert_config(
):
"""
Delete an alert.
:param alert_data: The data of the alert.
:param alert_name: The name of the alert to delete.
"""
Expand All @@ -3996,6 +4004,7 @@ def reset_alert_config(
):
"""
Reset an alert.
:param alert_data: The data of the alert.
:param alert_name: The name of the alert to reset.
"""
Expand All @@ -4013,6 +4022,7 @@ def reset_alert_config(
def get_alert_template(self, template_name: str) -> AlertTemplate:
"""
Retrieve a specific alert template.
:param template_name: The name of the template to retrieve.
:return: The template object.
"""
Expand All @@ -4022,6 +4032,7 @@ def get_alert_template(self, template_name: str) -> AlertTemplate:
def list_alert_templates(self) -> list[AlertTemplate]:
"""
Retrieve list of all alert templates.
:return: All the alert template objects in the database.
"""
db = mlrun.db.get_run_db(secrets=self._secrets)
Expand Down

0 comments on commit 3f74769

Please sign in to comment.