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: loading service from an absolute path #4415

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Conversation

frostming
Copy link
Contributor

@frostming frostming commented Jan 18, 2024

Signed-off-by: Frost Ming [email protected]

What does this PR address?

This is the case when running Service.serve_http()

Fixes #(issue)

Before submitting:

@frostming frostming requested a review from a team as a code owner January 18, 2024 02:07
@frostming frostming requested review from ssheng and bojiang and removed request for a team and ssheng January 18, 2024 02:07
return service_identifier, pathlib.Path(working_dir or ".")
if not module_path.is_absolute():
module_path = pathlib.Path(working_dir or ".").joinpath(module_path)
return f"{module_path.stem}:{service_path}", module_path.parent
Copy link
Member

Choose a reason for hiding this comment

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

Shall we return CWD as the bento path?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bento_path here is to tell import_service where to import the service, so it makes sense to return the parent dir of it.

This is to handle the case where bento_identifier is a path.

Copy link
Member

@bojiang bojiang Jan 18, 2024

Choose a reason for hiding this comment

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

bento_path is used as the working directory of sub-processes. When bento_identifier is a absolute path, I'm not sure if module parent directory works for all the case. Thinking about

|
|- service/service.py
|- utils/some_utils.py

And in service.py, utils is imported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So normalize_identifier is to return two values, import string and bento_path. For a bento identifier as absolute path. What shall it return? normalize_identifier("/path/to/package.py:Inference")

Copy link
Member

Choose a reason for hiding this comment

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

You just said this case happens when user call service.serve_http(), thus I think we should inherit the working directory, which is '.'
Will that work?
@frostming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but the first return value will be directly feed to import_service. An absolute path isn't a valid import string right?

@frostming frostming merged commit fc95886 into 1.2 Jan 18, 2024
38 of 41 checks passed
@frostming frostming deleted the fix/load-absolute-path branch January 18, 2024 10:36
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.

2 participants