yuqi1129 commented on code in PR #7954:
URL: https://github.com/apache/gravitino/pull/7954#discussion_r2262539594


##########
clients/client-python/gravitino/client/gravitino_client.py:
##########
@@ -99,3 +102,112 @@ def enable_catalog(self, name: str):
 
     def disable_catalog(self, name: str):
         return self.get_metalake().disable_catalog(name)
+
+    def list_job_templates(self) -> List[JobTemplate]:
+        """Lists all job templates in the current metalake.
+
+        Returns:
+            A list of JobTemplate objects representing the job templates in 
the metalake.
+        """
+        return self.get_metalake().list_job_templates()
+
+    def register_job_template(self, job_template) -> None:
+        """Register a job template with the specified job template to 
Gravitino. The registered
+        job will be maintained in Gravitino, allowing it to be executed later.

Review Comment:
   The registered job template ...



##########
clients/client-python/gravitino/client/gravitino_client.py:
##########
@@ -99,3 +102,112 @@ def enable_catalog(self, name: str):
 
     def disable_catalog(self, name: str):
         return self.get_metalake().disable_catalog(name)
+
+    def list_job_templates(self) -> List[JobTemplate]:
+        """Lists all job templates in the current metalake.
+
+        Returns:
+            A list of JobTemplate objects representing the job templates in 
the metalake.
+        """
+        return self.get_metalake().list_job_templates()
+
+    def register_job_template(self, job_template) -> None:
+        """Register a job template with the specified job template to 
Gravitino. The registered
+        job will be maintained in Gravitino, allowing it to be executed later.
+
+        Args:
+            job_template: The job template to register.
+
+        Raises:
+            JobTemplateAlreadyExists: If a job template with the same name 
already exists.
+        """
+        self.get_metalake().register_job_template(job_template)
+
+    def get_job_template(self, job_template_name: str) -> JobTemplate:
+        """Retrieves a job template by its name.
+
+        Args:
+            job_template_name: The name of the job template to retrieve.
+
+        Returns:
+            The JobTemplate object corresponding to the specified name.
+
+        Raises:
+            NoSuchJobTemplateException: If no job template with the specified 
name exists.
+        """
+        return self.get_metalake().get_job_template(job_template_name)
+
+    def delete_job_template(self, job_template_name: str) -> bool:
+        """
+        Deletes a job template by its name. This will remove the job template 
from Gravitino, and it
+        will no longer be available for execution. Only when all the jobs 
associated with this job
+        template are completed, failed or cancelled, the job template can be 
deleted successfully,
+        otherwise it will return false.
+
+        The deletion of a job template will also delete all the jobs 
associated with this template.
+
+        Args:
+            job_template_name: The name of the job template to delete.
+
+        Returns:
+            bool: True if the job template was deleted successfully, False if 
the job template
+            does not exist.
+
+        Raises:
+            InUseException: If there are still queued or started jobs 
associated with this job template.
+        """
+        return self.get_metalake().delete_job_template(job_template_name)
+
+    def list_jobs(self, job_template_name: str = None) -> List[JobHandle]:
+        """Lists all the jobs in the current metalake.
+
+        Args:
+            job_template_name: Optional; if provided, filters the jobs by the 
specified job template name.
+
+        Returns:
+            A list of JobHandle objects representing the jobs in the metalake.
+        """
+        return self.get_metalake().list_jobs(job_template_name)
+
+    def get_job(self, job_id: str) -> JobHandle:
+        """Retrieves a job by its ID.
+
+        Args:
+            job_id: The ID of the job to retrieve.
+
+        Returns:
+            The JobHandle object corresponding to the specified job ID.
+
+        Raises:
+            NoSuchJobException: If no job with the specified ID exists.
+        """
+        return self.get_metalake().get_job(job_id)
+
+    def run_job(self, job_template_name: str, job_conf: Dict[str, str]) -> 
JobHandle:
+        """Runs a job using the specified job template and configuration.
+
+        Args:
+            job_template_name: The name of the job template to use for running 
the job.
+            job_conf: A dictionary containing the configuration for the job.
+
+        Returns:
+            A JobHandle object representing the started job.
+
+        Raises:
+            NoSuchJobTemplateException: If no job template with the specified 
name exists.
+        """
+        return self.get_metalake().run_job(job_template_name, job_conf)
+
+    def cancel_job(self, job_id: str) -> JobHandle:
+        """Cancels a running job by its ID.

Review Comment:
   What if the status of a job is `queue`?



##########
clients/client-python/gravitino/client/gravitino_metalake.py:
##########
@@ -255,3 +270,186 @@ def disable_catalog(self, name: str):
         self.rest_client.patch(
             url, json=catalog_disable_request, 
error_handler=CATALOG_ERROR_HANDLER
         )
+
+    def list_job_templates(self) -> List[JobTemplate]:
+        """List all the registered job templates in Gravitino.
+
+        Returns:
+            List of job templates.
+        """
+        params = {"details": "true"}
+        url = 
self.API_METALAKES_JOB_TEMPLATES_PATH.format(encode_string(self.name()))
+        response = self.rest_client.get(
+            url, params=params, error_handler=JOB_ERROR_HANDLER
+        )
+        resp = JobTemplateListResponse.from_json(response.body, 
infer_missing=True)
+        resp.validate()
+
+        return [
+            DTOConverters.from_job_template_dto(dto) for dto in 
resp.job_templates()
+        ]
+
+    def register_job_template(self, job_template: JobTemplate) -> None:
+        """Register a job template with the specified job template to 
Gravitino. The registered
+        job will be maintained in Gravitino, allowing it to be executed later.

Review Comment:
   dito



##########
clients/client-python/gravitino/client/gravitino_client.py:
##########
@@ -99,3 +102,112 @@ def enable_catalog(self, name: str):
 
     def disable_catalog(self, name: str):
         return self.get_metalake().disable_catalog(name)
+
+    def list_job_templates(self) -> List[JobTemplate]:
+        """Lists all job templates in the current metalake.
+
+        Returns:
+            A list of JobTemplate objects representing the job templates in 
the metalake.
+        """
+        return self.get_metalake().list_job_templates()
+
+    def register_job_template(self, job_template) -> None:
+        """Register a job template with the specified job template to 
Gravitino. The registered
+        job will be maintained in Gravitino, allowing it to be executed later.
+
+        Args:
+            job_template: The job template to register.
+
+        Raises:
+            JobTemplateAlreadyExists: If a job template with the same name 
already exists.
+        """
+        self.get_metalake().register_job_template(job_template)
+
+    def get_job_template(self, job_template_name: str) -> JobTemplate:
+        """Retrieves a job template by its name.
+
+        Args:
+            job_template_name: The name of the job template to retrieve.
+
+        Returns:
+            The JobTemplate object corresponding to the specified name.
+
+        Raises:
+            NoSuchJobTemplateException: If no job template with the specified 
name exists.
+        """
+        return self.get_metalake().get_job_template(job_template_name)
+
+    def delete_job_template(self, job_template_name: str) -> bool:
+        """
+        Deletes a job template by its name. This will remove the job template 
from Gravitino, and it
+        will no longer be available for execution. Only when all the jobs 
associated with this job
+        template are completed, failed or cancelled, the job template can be 
deleted successfully,
+        otherwise it will return false.

Review Comment:
   The definition is not consistent with that of JAVA API, see java 
   ```
   true if the job template was successfully deleted, false if the job template 
does not
      *     exist
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to