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

fix: Path issues with pip modules #4256

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tokotchd
Copy link

@tokotchd tokotchd commented Nov 2, 2023

Always prepend current bentofile directory to system path to avoid unwanted behavior when other bentofiles are on the system PATH
This is especially evident when trying to use bentoml cli on python folders that are also pip modules see #4217

…wanted behavior when other bentofiles are on the system PATH

This is especially evident when trying to use bentoml cli on python folders that are also pip modules
see bentoml#4217
@tokotchd tokotchd requested a review from a team as a code owner November 2, 2023 17:13
@tokotchd tokotchd requested review from bojiang and removed request for a team November 2, 2023 17:13
sauyon
sauyon previously approved these changes Nov 2, 2023
Copy link
Contributor

@sauyon sauyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@@ -172,7 +169,7 @@ def recover_standalone_env_change():
object.__setattr__(instance, "_import_str", f"{module_name}:{attrs_str}")
return instance
except ImportServiceError:
if sys_path_modified and working_dir:
if working_dir:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably don't need this check neither now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check is ensuring that if the assignment fails it doesn't try to remove None.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, I'd suggest we move the working_dir assignment L75-81 out of the try block and remove this if working_dir check as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sauyon made a quick patch, could you help take a look?

@aarnphm
Copy link
Member

aarnphm commented Nov 9, 2023

we probably should note the side effect of doing this here

  • If there is a package/folder named grpc, it will override the default grpc import, which makes serve-grpc not working
  • the same as schema, or literally any folder that have the same name as package module imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants