Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the use of ipynbname package in our SDK #184

Merged
merged 9 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions sdk/aqueduct/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from aqueduct.operators import Operator
from aqueduct.enums import OperatorType

import ipynbname
import cloudpickle as cp
import tempfile
import os
Expand Down Expand Up @@ -209,21 +208,23 @@ def _package_files_and_requirements(
if not file_dependencies:
file_dependencies = []

current_directory_path = os.getcwd()

func_filepath = inspect.getsourcefile(func)
if not func_filepath:
raise Exception("Unable to find source file of function.")

# In Python3.8, `inspect.getsourcefile` only returns the file's relative path,
# so we need the line below to get the absolute path.
func_filepath = os.path.abspath(func_filepath)
if "JPY_PARENT_PID" in os.environ:
func_filepath = str(ipynbname.path())

current_directory_path = os.getcwd()
func_dirpath = os.path.dirname(func_filepath)
func_file = os.path.basename(func_filepath)

os.chdir(func_dirpath)
# We check if the directory `func_dirpath` exists. If not, this means `func` is from within a
# Jupyter notebook that the user is currently running, so we don't switch the working directory.
# The goal of switching the working directory is that if a user specifies relative paths
# in `file_dependencies` and if `func` is imported from a Python script located in another
# directory, we can locate them.
if os.path.isdir(func_dirpath):
os.chdir(func_dirpath)

for file_index, file_path in enumerate(file_dependencies):
if file_path in RESERVED_FILE_NAMES:
Expand Down Expand Up @@ -264,8 +265,6 @@ def _package_files_and_requirements(
python_version = ".".join((str(x) for x in sys.version_info[:2]))
with open(os.path.join(dir_path, PYTHON_VERSION_FILE_NAME), "w") as f:
f.write(python_version)
if os.path.exists(os.path.join(dir_path, func_file)):
os.remove(os.path.join(dir_path, func_file))

os.chdir(current_directory_path)

Expand Down
1 change: 0 additions & 1 deletion sdk/requirements/python-3-10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pandas
IPython
croniter
pydantic
ipynbname
plotly
pyyaml
great_expectations
Expand Down
1 change: 0 additions & 1 deletion sdk/requirements/python-3-7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pandas<=1.3.5
IPython
croniter
pydantic
ipynbname
plotly
pyyaml
great_expectations
Expand Down
1 change: 0 additions & 1 deletion sdk/requirements/python-3-8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pandas
IPython
croniter
pydantic
ipynbname
plotly
pyyaml
great_expectations
Expand Down
1 change: 0 additions & 1 deletion sdk/requirements/python-3-9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pandas
IPython
croniter
pydantic
ipynbname
plotly
pyyaml
great_expectations
Expand Down