You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/21 14:40:10 UTC
[GitHub] [airflow] potiuk commented on a change in pull request #22331: Add import_notebook method to databricks hook
potiuk commented on a change in pull request #22331:
URL: https://github.com/apache/airflow/pull/22331#discussion_r831183683
##########
File path: airflow/providers/databricks/hooks/databricks.py
##########
@@ -379,20 +379,27 @@ def import_notebook(self, notebook_name: str, raw_code: str, language: str, over
raise ValueError(f"results: format must be one of the following: {str(format_options)}")
# encode notebook
- encodedBytes = base64.b64encode(raw_code.encode("utf-8"))
- encodedStr = str(encodedBytes, "utf-8")
+ encoded_bytes = base64.b64encode(raw_code.encode("utf-8"))
+ encoded_str = str(encoded_bytes, "utf-8")
# create parent directory if not exists
- self._do_api_call(WORKSPACE_MKDIR_ENDPOINT, {'path': "/Shared/airflow"})
+ path_parts = dbfs_path.split('/')
+ path_parts.pop(0)
+ path_parts = path_parts[:-1]
+
+ path = ''
+ for part in path_parts:
+ path += f'/{part}'
+ self._do_api_call(WORKSPACE_MKDIR_ENDPOINT, {'path': path})
Review comment:
Yeah. I think dbfs path on databricks FS is "standardized" with '/` so there is no need to use pathlib for those.
--
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