Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: files not updating #49

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog db-rocket

## Version 1.3.6

- Fix bug of updates not getting detected
- Put files into a project folder

## Version 1.3.5

- Replace self-calling CLI with while loop
-

## Version 1.3.4

Expand Down
18 changes: 9 additions & 9 deletions rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,11 @@ def launch(
project_directory = project_directory[:-1]

self.dbfs_folder = dbfs_path + project_directory
self._build_and_deploy(watch)

if not watch:
self._build_and_deploy(watch)
return

if _deploy:
self._deploy(watch)

if watch:
observer = Observer()
watcher = Watcher(observer)
Expand All @@ -94,7 +91,6 @@ def launch(
while True:
time.sleep(2)
if watcher.modified_files:
observer.join()
self._deploy(watch=watch, modified_files=watcher.modified_files)
watcher.reset_modified()

Expand All @@ -116,6 +112,7 @@ def _deploy(self, watch, modified_files=None):
)

base_path = self.dbfs_folder.replace("dbfs:/", "/dbfs/")
project_name = os.path.basename(os.path.abspath(self.project_location))
if not watch:
install_cmd = f'{base_path}/{self.wheel_file}'
install_cmd = _add_index_urls_to_cmd(install_cmd, self.index_urls)
Expand All @@ -133,19 +130,20 @@ def _deploy(self, watch, modified_files=None):
for file in modified_files:
logger.info(f"Finished sync of {file}")
execute_shell_command(
f"databricks fs cp --recursive --overwrite {file} {self.dbfs_folder}/{os.path.relpath(file, self.project_location)}"
f"databricks fs cp --recursive --overwrite {file} {self.dbfs_folder}/{project_name}/{os.path.relpath(file, self.project_location)}"
)
return

logger.info(
"You have watch activated. Your project will be automatically synchronised with databricks. Starting sync process:")
execute_shell_command(f"databricks fs mkdirs {self.dbfs_folder}/{project_name}")
package_dirs = extract_python_package_dirs(self.project_location)
for package_dir in package_dirs:
python_files = extract_python_files_from_folder(package_dir)

def helper(file):
execute_shell_command(
f"databricks fs cp --recursive --overwrite {file} {self.dbfs_folder}/{os.path.relpath(file, self.project_location)}"
f"databricks fs cp --recursive --overwrite {file} {self.dbfs_folder}/{project_name}/{os.path.relpath(file, self.project_location)}"
)
logger.info(f"Finished sync of {file}")

Expand All @@ -156,14 +154,16 @@ def helper(file):
project_file = "pyproject.toml"

execute_shell_command(
f"databricks fs cp --overwrite {self.project_location}/{project_file} {self.dbfs_folder}/"
f"databricks fs cp --overwrite {self.project_location}/{project_file} {self.dbfs_folder}/{project_name}"
)
logger.info(f"Finished sync of {self.project_location}/{project_file}")

install_cmd = f"-e {base_path}/{project_name}"
install_cmd = _add_index_urls_to_cmd(install_cmd, self.index_urls)
logger.info(
f"""Sync completed. To use your library in your databricks notebook & automatically apply local changes add following in one cell:
%pip install --upgrade pip
%pip install -e {base_path}
%pip install {install_cmd}

and then in a new Python cell:
%load_ext autoreload
Expand Down
1 change: 0 additions & 1 deletion rocket/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def on_modified(self, event):
return
if os.path.splitext(event.src_path)[1] == '.py':
self.modified_files.append(event.src_path)
self.observer.stop()

def reset_modified(self):
self.modified_files = []
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="databricks-rocket",
version="1.3.5",
version="1.3.6",
author="GetYourGuide",
author_email="[email protected]",
description="Keep your local python scripts installed and in sync with a databricks notebook. Shortens the feedback loop to develop projects using a hybrid enviroment",
Expand Down