ephraimbuddy commented on code in PR #27446:
URL: https://github.com/apache/airflow/pull/27446#discussion_r1015790782
##########
airflow/providers/databricks/hooks/databricks.py:
##########
@@ -152,29 +152,38 @@ def submit_run(self, json: dict) -> int:
response = self._do_api_call(SUBMIT_RUN_ENDPOINT, json)
return response["run_id"]
- def list_jobs(self, limit: int = 25, offset: int = 0, expand_tasks: bool =
False) -> list[dict[str, Any]]:
+ def list_jobs(
+ self, limit: int = 25, offset: int = 0, expand_tasks: bool = False,
job_name: str | None = None
+ ) -> list[dict[str, Any]]:
"""
Lists the jobs in the Databricks Job Service.
:param limit: The limit/batch size used to retrieve jobs.
:param offset: The offset of the first job to return, relative to the
most recently created job.
:param expand_tasks: Whether to include task and cluster details in
the response.
+ :param job_name: Optional name of a job to search.
:return: A list of jobs.
"""
has_more = True
jobs = []
while has_more:
- json = {
+ jsn = {
"limit": limit,
- "offset": offset,
"expand_tasks": expand_tasks,
+ "offset": offset,
}
- response = self._do_api_call(LIST_JOBS_ENDPOINT, json)
- jobs += response["jobs"] if "jobs" in response else []
+ if job_name:
+ jsn["name"] = job_name
+ response = self._do_api_call(LIST_JOBS_ENDPOINT, jsn)
+ jbs = response.get("jobs", [])
Review Comment:
These abbreviations feel somehow, `databrick_jobs`...
##########
airflow/providers/databricks/hooks/databricks.py:
##########
@@ -152,29 +152,38 @@ def submit_run(self, json: dict) -> int:
response = self._do_api_call(SUBMIT_RUN_ENDPOINT, json)
return response["run_id"]
- def list_jobs(self, limit: int = 25, offset: int = 0, expand_tasks: bool =
False) -> list[dict[str, Any]]:
+ def list_jobs(
+ self, limit: int = 25, offset: int = 0, expand_tasks: bool = False,
job_name: str | None = None
+ ) -> list[dict[str, Any]]:
"""
Lists the jobs in the Databricks Job Service.
:param limit: The limit/batch size used to retrieve jobs.
:param offset: The offset of the first job to return, relative to the
most recently created job.
:param expand_tasks: Whether to include task and cluster details in
the response.
+ :param job_name: Optional name of a job to search.
:return: A list of jobs.
"""
has_more = True
jobs = []
while has_more:
- json = {
+ jsn = {
Review Comment:
How about we call this `json_data`? I feel it's better than an abbreviation.
No strong opinion here
--
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]