From 47a6d7d7a732bc2c2110870880b107a32b4d037b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves?= Date: Mon, 9 Dec 2024 20:10:11 +0000 Subject: [PATCH] test --- singlestoredb/magics/run_personal.py | 12 ++++-------- singlestoredb/magics/run_shared.py | 10 ++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/singlestoredb/magics/run_personal.py b/singlestoredb/magics/run_personal.py index 6c624b8f..f6daa616 100644 --- a/singlestoredb/magics/run_personal.py +++ b/singlestoredb/magics/run_personal.py @@ -1,5 +1,4 @@ import os -import time from typing import Any from IPython.core.interactiveshell import InteractiveShell @@ -42,16 +41,13 @@ def run_personal(self, line: str, local_ns: Any = None) -> Any: if not personal_file: raise ValueError('No personal file specified.') - local_filename = ( - f'{int(time.time() * 1_000_000)}_{personal_file}'.replace(' ', '_') - ) - sql_command = f"DOWNLOAD PERSONAL FILE '{personal_file}' TO '{local_filename}'" + sql_command = f"DOWNLOAD PERSONAL FILE '{personal_file}' TO '{personal_file}'" # Execute the SQL command self.shell.run_line_magic('sql', sql_command) # Run the downloaded file - self.shell.run_line_magic('run', local_filename) + self.shell.run_line_magic('run', personal_file) # Delete the local file after running it - if os.path.exists(local_filename): - os.remove(local_filename) + if os.path.exists(personal_file): + os.remove(personal_file) diff --git a/singlestoredb/magics/run_shared.py b/singlestoredb/magics/run_shared.py index 393ca4bd..ed18e8c2 100644 --- a/singlestoredb/magics/run_shared.py +++ b/singlestoredb/magics/run_shared.py @@ -1,5 +1,4 @@ import os -import time from typing import Any from IPython.core.interactiveshell import InteractiveShell @@ -42,14 +41,13 @@ def run_shared(self, line: str, local_ns: Any = None) -> Any: if not shared_file: raise ValueError('No personal file specified.') - local_filename = f'{int(time.time() * 1_000_000)}_{shared_file}'.replace(' ', '_') - sql_command = f"DOWNLOAD SHARED FILE '{shared_file}' TO '{local_filename}'" + sql_command = f"DOWNLOAD SHARED FILE '{shared_file}' TO '{shared_file}'" # Execute the SQL command self.shell.run_line_magic('sql', sql_command) # Run the downloaded file - self.shell.run_line_magic('run', local_filename) + self.shell.run_line_magic('run', shared_file) # Delete the local file after running it - if os.path.exists(local_filename): - os.remove(local_filename) + if os.path.exists(shared_file): + os.remove(shared_file)