-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: enable automatically syncing project files with databricks (#44
- Loading branch information
Showing
7 changed files
with
162 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import concurrent.futures | ||
import os | ||
import subprocess | ||
|
||
from rocket.logger import logger | ||
|
||
|
||
def execute_for_each_multithreaded(lst, func, max_threads=None): | ||
""" | ||
Execute a given function for each entry in the list using multiple threads. | ||
Parameters: | ||
- lst: List of items to process | ||
- func: Function to apply to each item | ||
- max_threads: Maximum number of threads to use (default is None, which means as many as items in the list) | ||
Returns: | ||
- List of results after applying the function | ||
""" | ||
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor: | ||
return list(executor.map(func, lst)) | ||
|
||
|
||
def extract_package_name_from_wheel(wheel_filename): | ||
# Split the filename on '-' and take the first part | ||
return wheel_filename.split('-')[0] | ||
|
||
|
||
def extract_project_name_from_wheel(wheel_filename): | ||
return extract_package_name_from_wheel(wheel_filename).replace("_", "-") | ||
|
||
|
||
def extract_python_package_dirs(root_dir): | ||
packages = [] | ||
for item in os.listdir(root_dir): | ||
item_path = os.path.join(root_dir, item) | ||
if os.path.isdir(item_path) and '__init__.py' in os.listdir(item_path): | ||
packages.append(item_path) | ||
return packages | ||
|
||
|
||
def execute_shell_command(cmd) -> str: | ||
logger.debug(f"Running shell command: {cmd} ") | ||
return subprocess.check_output(cmd, shell=True).decode("utf-8") | ||
|
||
|
||
def extract_python_files_from_folder(path): | ||
py_files = [] | ||
|
||
for root, dirs, files in os.walk(path): | ||
for file in files: | ||
if file.endswith('.py'): | ||
py_files.append(os.path.join(root, file)) | ||
|
||
return py_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
from watchdog.events import FileSystemEventHandler | ||
|
||
|
||
class Watcher(FileSystemEventHandler): | ||
|
||
def __init__(self, observer): | ||
self.modified_files = [] | ||
self.observer = observer | ||
|
||
def on_modified(self, event): | ||
if event.is_directory: | ||
return | ||
if os.path.splitext(event.src_path)[1] == '.py': | ||
self.modified_files.append(event.src_path) | ||
self.observer.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
setuptools.setup( | ||
name="databricks-rocket", | ||
version="1.2.0", | ||
version="1.3.0", | ||
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", | ||
|