Skip to content

Commit

Permalink
Do not copy flytekit itself during fast registration (#2775)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
  • Loading branch information
thomasjpfan authored Sep 28, 2024
1 parent 8bcb9d0 commit cc4d27b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions flytekit/tools/script_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from types import ModuleType
from typing import List, Optional, Tuple, Union

import flytekit
from flytekit.constants import CopyFileDetection
from flytekit.loggers import logger
from flytekit.tools.ignore import IgnoreGroup
Expand Down Expand Up @@ -192,6 +193,7 @@ def list_imported_modules_as_files(source_path: str, modules: List[ModuleType])
site_packages_set = set(site_packages)
bin_directory = os.path.dirname(sys.executable)
files = []
flytekit_root = os.path.dirname(flytekit.__file__)

for mod in modules:
try:
Expand All @@ -206,6 +208,10 @@ def list_imported_modules_as_files(source_path: str, modules: List[ModuleType])
# installed packages & libraries that are not user files. This happens when
# there is a virtualenv like `.venv` in the working directory.
try:
# Do not upload code if it is from the flytekit library
if os.path.commonpath([flytekit_root, mod_file]) == flytekit_root:
continue

if os.path.commonpath(site_packages + [mod_file]) in site_packages_set:
# Do not upload files from site-packages
continue
Expand Down

0 comments on commit cc4d27b

Please sign in to comment.