Skip to content

Commit

Permalink
SNOW-1418523: Remove session variable that can be local (#2279)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aalam authored Sep 17, 2024
1 parent 3f60507 commit 8414933
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ def __init__(
)
self._custom_package_usage_config: Dict = {}
self._conf = self.RuntimeConfig(self, options or {})
self._tmpdir_handler: Optional[tempfile.TemporaryDirectory] = None
self._runtime_version_from_requirement: str = None
self._temp_table_auto_cleaner: TempTableAutoCleaner = TempTableAutoCleaner(self)
_logger.info("Snowpark Session information: %s", self._session_info)
Expand Down Expand Up @@ -1710,8 +1709,8 @@ def _upload_unsupported_packages(

try:
# Setup a temporary directory and target folder where pip install will take place.
self._tmpdir_handler = tempfile.TemporaryDirectory()
tmpdir = self._tmpdir_handler.name
tmpdir_handler = tempfile.TemporaryDirectory()
tmpdir = tmpdir_handler.name
target = os.path.join(tmpdir, "unsupported_packages")
if not os.path.exists(target):
os.makedirs(target)
Expand Down Expand Up @@ -1796,9 +1795,7 @@ def _upload_unsupported_packages(
for requirement in supported_dependencies + new_dependencies
]
)
metadata_local_path = os.path.join(
self._tmpdir_handler.name, metadata_file
)
metadata_local_path = os.path.join(tmpdir_handler.name, metadata_file)
with open(metadata_local_path, "w") as file:
for key, value in metadata.items():
file.write(f"{key},{value}\n")
Expand Down Expand Up @@ -1834,9 +1831,8 @@ def _upload_unsupported_packages(
f"-third-party-packages-from-anaconda-in-a-udf."
)
finally:
if self._tmpdir_handler:
self._tmpdir_handler.cleanup()
self._tmpdir_handler = None
if tmpdir_handler:
tmpdir_handler.cleanup()

return supported_dependencies + new_dependencies

Expand Down

0 comments on commit 8414933

Please sign in to comment.