You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "philipgray (via GitHub)" <gi...@apache.org> on 2023/09/26 18:20:55 UTC

[GitHub] [airflow] philipgray commented on a diff in pull request #34533: Defined constants for repo routes in databricks hook

philipgray commented on code in PR #34533:
URL: https://github.com/apache/airflow/pull/34533#discussion_r1337616686


##########
airflow/providers/databricks/hooks/databricks.py:
##########
@@ -536,7 +540,7 @@ def delete_repo(self, repo_id: str):
         :param repo_id: ID of Databricks Repos
         :return:
         """
-        repos_endpoint = ("DELETE", f"api/2.0/repos/{repo_id}")
+        repos_endpoint = DELETE_REPO_ENDPOINT[1].format(repo_id=repo_id)

Review Comment:
   Piggybacking off what @frankcash suggested, how does this change look @hussein-awala? 
   
   `    def update_repo(self, repo_id: str, json: dict[str, Any]) -> dict:
           """
           Updates given Databricks Repos.
   
           :param repo_id: ID of Databricks Repos
           :param json: payload
           :return: metadata from update
           """
           modify_route = lambda t, repo_id: (t[0], t[1].format(repo_id=repo_id))
           modified_update_repo_endpoint = modify_route(UPDATE_REPO_ENDPOINT, repo_id)
           return self._do_api_call(modified_update_repo_endpoint, json)
   
       def delete_repo(self, repo_id: str):
           """
           Deletes given Databricks Repos.
   
           :param repo_id: ID of Databricks Repos
           :return:
           """
           modify_route = lambda t, repo_id: (t[0], t[1].format(repo_id=repo_id))
           modified_delete_repo_endpoint = modify_route(DELETE_REPO_ENDPOINT, repo_id)
           self._do_api_call(modified_delete_repo_endpoint)`
           
   Wasn't too sure if it would be more helpful to just create a helper function instead to do this. Let me know what you think! 



##########
airflow/providers/databricks/hooks/databricks.py:
##########
@@ -536,7 +540,7 @@ def delete_repo(self, repo_id: str):
         :param repo_id: ID of Databricks Repos
         :return:
         """
-        repos_endpoint = ("DELETE", f"api/2.0/repos/{repo_id}")
+        repos_endpoint = DELETE_REPO_ENDPOINT[1].format(repo_id=repo_id)

Review Comment:
   Piggybacking off what @frankcash suggested, how does this change look @hussein-awala? 
   
   `def update_repo(self, repo_id: str, json: dict[str, Any]) -> dict:
           """
           Updates given Databricks Repos.
   
           :param repo_id: ID of Databricks Repos
           :param json: payload
           :return: metadata from update
           """
           modify_route = lambda t, repo_id: (t[0], t[1].format(repo_id=repo_id))
           modified_update_repo_endpoint = modify_route(UPDATE_REPO_ENDPOINT, repo_id)
           return self._do_api_call(modified_update_repo_endpoint, json)
   
       def delete_repo(self, repo_id: str):
           """
           Deletes given Databricks Repos.
   
           :param repo_id: ID of Databricks Repos
           :return:
           """
           modify_route = lambda t, repo_id: (t[0], t[1].format(repo_id=repo_id))
           modified_delete_repo_endpoint = modify_route(DELETE_REPO_ENDPOINT, repo_id)
           self._do_api_call(modified_delete_repo_endpoint)`
           
   Wasn't too sure if it would be more helpful to just create a helper function instead to do this. Let me know what you think! 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org