From a6b10dfd551946d3a3a64e988ae416fa4f4ee5cc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 07:39:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../src/components/ConvertJobToNotebook.tsx | 2 +- .../vdk-jupyterlab-extension/src/index.ts | 2 +- .../src/serverRequests.ts | 2 +- .../vdk_jupyterlab_extension/convert_job.py | 19 ++++++++------ .../vdk_jupyterlab_extension/handlers.py | 2 +- .../test_transform_job_directory_processor.py | 26 ++++++++++++------- .../vdk_jupyterlab_extension/vdk_ui.py | 3 ++- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/components/ConvertJobToNotebook.tsx b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/components/ConvertJobToNotebook.tsx index 2d04561d45..a6290c596b 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/components/ConvertJobToNotebook.tsx +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/components/ConvertJobToNotebook.tsx @@ -290,4 +290,4 @@ export const populateNotebook = async (notebookContent: JupyterCellProps[], note } } }); -} \ No newline at end of file +} diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/index.ts b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/index.ts index acd35b37b3..83def42cb2 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/index.ts +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/index.ts @@ -52,7 +52,7 @@ const plugin: JupyterFrontEndPlugin = { initVDKConfigCell(notebookTracker); }); - const fileBrowser = factory.defaultBrowser; + const fileBrowser = factory.defaultBrowser; updateVDKMenu(commands, docManager, fileBrowser, notebookTracker); diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/serverRequests.ts b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/serverRequests.ts index eff2a7d90e..4d2e79843d 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/serverRequests.ts +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/src/serverRequests.ts @@ -228,4 +228,4 @@ export async function getServerDirRequest(): Promise { ); return ''; } -} \ No newline at end of file +} diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/convert_job.py b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/convert_job.py index f8f7945dca..0ebb2c6db7 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/convert_job.py +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/convert_job.py @@ -1,6 +1,9 @@ +# Copyright 2021-2023 VMware, Inc. +# SPDX-License-Identifier: Apache-2.0 + +import glob import os import shutil -import glob def validate_dir(dir_path): @@ -33,7 +36,7 @@ def get_archive_name(self) -> str: return os.path.join(parent_dir, f"{dir_name}_archive") def archive_folder(self): - shutil.make_archive(self.get_archive_name(), 'zip', self._dir_path) + shutil.make_archive(self.get_archive_name(), "zip", self._dir_path) class ConvertJobDirectoryProcessor: @@ -56,20 +59,20 @@ def __init__(self, dir_path): self._code_structure = [] def process_files(self): - all_files = sorted(glob.glob(os.path.join(self._dir_path, '*'))) + all_files = sorted(glob.glob(os.path.join(self._dir_path, "*"))) self._archiver.archive_folder() for file in all_files: - if file.endswith('.sql'): - with open(file, 'r') as f: + if file.endswith(".sql"): + with open(file) as f: content = f.read() self._code_structure.append(f'job_input.execute_query("""{content}""")') os.remove(file) - elif file.endswith('.py'): - with open(file, 'r') as f: + elif file.endswith(".py"): + with open(file) as f: content = f.read() - if 'def run(job_input: IJobInput)' in content: + if "def run(job_input: IJobInput)" in content: self._code_structure.append(content) os.remove(file) diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/handlers.py b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/handlers.py index 77a63cfbcc..b2224ea01a 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/handlers.py +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/handlers.py @@ -223,4 +223,4 @@ def add_handler(handler, endpoint): add_handler(CreateDeploymentHandler, "deploy") add_handler(GetNotebookInfoHandler, "notebook") add_handler(GetVdkCellIndicesHandler, "vdkCellIndices") - add_handler(GetServerPathHandler, "serverPath") \ No newline at end of file + add_handler(GetServerPathHandler, "serverPath") diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/tests/test_transform_job_directory_processor.py b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/tests/test_transform_job_directory_processor.py index bb6e7d63f5..dc770ae6e5 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/tests/test_transform_job_directory_processor.py +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/tests/test_transform_job_directory_processor.py @@ -1,7 +1,11 @@ +# Copyright 2021-2023 VMware, Inc. +# SPDX-License-Identifier: Apache-2.0 + import os -import unittest -import tempfile import shutil +import tempfile +import unittest + from vdk_jupyterlab_extension.transform_job import TransformJobDirectoryProcessor @@ -18,13 +22,13 @@ def hello(): print("Hello, World!") """ - with open(os.path.join(self.temp_dir, 'test.sql'), 'w') as f: + with open(os.path.join(self.temp_dir, "test.sql"), "w") as f: f.write(self.sql_content) - with open(os.path.join(self.temp_dir, 'test_run.py'), 'w') as f: + with open(os.path.join(self.temp_dir, "test_run.py"), "w") as f: f.write(self.py_content_run) - with open(os.path.join(self.temp_dir, 'test_without_run.py'), 'w') as f: + with open(os.path.join(self.temp_dir, "test_without_run.py"), "w") as f: f.write(self.py_content_without_run) - with open(os.path.join(self.temp_dir, 'config.ini'), 'w') as f: + with open(os.path.join(self.temp_dir, "config.ini"), "w") as f: pass self.processor = TransformJobDirectoryProcessor(self.temp_dir) @@ -39,10 +43,12 @@ def test_process_files(self): self.py_content_run, ] self.assertEqual(self.processor.get_code_structure(), expected_code_structure) - self.assertFalse(os.path.exists(os.path.join(self.temp_dir, 'test.sql'))) - self.assertFalse(os.path.exists(os.path.join(self.temp_dir, 'test_run.py'))) - self.assertTrue(os.path.exists(os.path.join(self.temp_dir, 'test_without_run.py'))) - self.assertTrue(os.path.exists(os.path.join(self.temp_dir, 'config.ini'))) + self.assertFalse(os.path.exists(os.path.join(self.temp_dir, "test.sql"))) + self.assertFalse(os.path.exists(os.path.join(self.temp_dir, "test_run.py"))) + self.assertTrue( + os.path.exists(os.path.join(self.temp_dir, "test_without_run.py")) + ) + self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "config.ini"))) def test_get_code_structure(self): self.processor.process_files() diff --git a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/vdk_ui.py b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/vdk_ui.py index 20bed2904e..e3344f307b 100644 --- a/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/vdk_ui.py +++ b/projects/vdk-plugins/vdk-jupyter/vdk-jupyterlab-extension/vdk_jupyterlab_extension/vdk_ui.py @@ -15,6 +15,7 @@ from vdk_jupyterlab_extension.convert_job import ConvertJobDirectoryProcessor from vdk_jupyterlab_extension.convert_job import DirectoryArchiver + class RestApiUrlConfiguration: @staticmethod def get_rest_api_url(): @@ -242,4 +243,4 @@ def convert_job(job_dir: str): "removed_files": processor.get_removed_files(), } processor.cleanup() - return message \ No newline at end of file + return message