From 5ea32c7f7fef42b7790e3a92a9ede48284eb9c43 Mon Sep 17 00:00:00 2001 From: Ionesio Junior Date: Thu, 6 Mar 2025 14:11:13 -0300 Subject: [PATCH 1/2] Small adjustments to make it compatible with Windows --- syftbox/client/plugins/apps.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/syftbox/client/plugins/apps.py b/syftbox/client/plugins/apps.py index 6c368036..9fbfa82a 100644 --- a/syftbox/client/plugins/apps.py +++ b/syftbox/client/plugins/apps.py @@ -69,6 +69,7 @@ def get_clean_env() -> dict: "DISPLAY", # X11 specific (Linux) "DBUS_SESSION_BUS_ADDRESS", # X11 specific (Linux) "SYSTEMROOT", # Windows specific + "USERPROFILE", } # Copy essential and SYFTBOX_* variables @@ -257,7 +258,7 @@ def run_apps(apps_path: Path, client_config: Path) -> None: app_config = load_config(app_path / "config.json") if app_config is None: run_app(app_path, client_config) - elif RUNNING_APPS.get(app, None) is None: + elif RUNNING_APPS.get(os.path.basename(app), None) is None: logger.info("⏱ Scheduling a new app run.") thread = threading.Thread( target=run_custom_app_config, @@ -286,10 +287,14 @@ def output_published(app_output: Union[str, Path], published_output: Union[str, def run_custom_app_config(app_config: SimpleNamespace, app_path: Path, client_config: Path) -> None: app_name = os.path.basename(app_path) - clean_env = { - "PATH": path_without_virtualenvs(), - CONFIG_PATH_ENV: str(client_config), - } + clean_env = get_clean_env() + clean_env.update( + { + "PATH": path_without_virtualenvs(), + CONFIG_PATH_ENV: str(client_config), + } + ) + # Update environment with any custom variables in app_config app_envs = getattr(app_config.app, "env", {}) if not isinstance(app_envs, dict): @@ -315,17 +320,17 @@ def run_custom_app_config(app_config: SimpleNamespace, app_path: Path, client_co current_time = datetime.now() logger.info(f"👟 Running {app_name} at scheduled time {current_time.strftime('%Y-%m-%d %H:%M:%S')}") logger.info(f"Running command: {app_config.app.run.command}") + app_log_dir = app_path / "logs" + log_file = app_log_dir / APP_LOG_FILE_NAME_FORMAT.format(app_name=app_name) try: - app_log_dir = app_path / "logs" run_with_logging( app_config.app.run.command, app_path, clean_env, app_log_dir, ) - log_file = app_log_dir / APP_LOG_FILE_NAME_FORMAT.format(app_name=app_name) logger.info(f"App '{app_name}' ran successfully. \nDetailed logs at: {log_file.resolve()}") - except subprocess.CalledProcessError as _: + except subprocess.CalledProcessError as e: logger.error(f"Error calling subprocess for api '{app_name}'") logger.error(f"Check {app_name}'s api logs at: {log_file.resolve()}") except Exception as _: From 5336c26e446300f79f30353b2cc27b8558bc8724 Mon Sep 17 00:00:00 2001 From: Ionesio Junior Date: Thu, 6 Mar 2025 15:01:50 -0300 Subject: [PATCH 2/2] Remove unused variable --- syftbox/client/plugins/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syftbox/client/plugins/apps.py b/syftbox/client/plugins/apps.py index 9fbfa82a..f1a1988b 100644 --- a/syftbox/client/plugins/apps.py +++ b/syftbox/client/plugins/apps.py @@ -330,7 +330,7 @@ def run_custom_app_config(app_config: SimpleNamespace, app_path: Path, client_co app_log_dir, ) logger.info(f"App '{app_name}' ran successfully. \nDetailed logs at: {log_file.resolve()}") - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: logger.error(f"Error calling subprocess for api '{app_name}'") logger.error(f"Check {app_name}'s api logs at: {log_file.resolve()}") except Exception as _: