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

feat(grpc): IO descriptors #2884

Merged
merged 20 commits into from
Aug 14, 2022
Merged

Conversation

aarnphm
Copy link
Contributor

@aarnphm aarnphm commented Aug 9, 2022

adding gRPC support for the remaining of the IO descriptor
Pandas will be handled by @Proto007

Test will be with a follow up PR.

This PR also remove setup.cfg and use pyproject.toml. We will also lock version of setuptools==63.4.0 until 64+ is stable.

since bentoml/_version.py is always generated and included inside the distribution, we should use that for __version__ instead of using importlib.metadata. This will also avoid PackageNotFoundError if bentoml is not yet installed, but attributes for version were accessed before.

@aarnphm aarnphm requested review from ssheng, parano and a team as code owners August 9, 2022 11:27
@aarnphm aarnphm requested review from bojiang and removed request for a team August 9, 2022 11:27
@pep8speaks
Copy link

pep8speaks commented Aug 9, 2022

Hello @aarnphm, Thanks for updating this PR.

There are currently no PEP 8 issues detected in this PR. Cheers! 🍻

Comment last updated at 2022-08-14 00:01:59 UTC

@codecov
Copy link

codecov bot commented Aug 9, 2022

Codecov Report

Merging #2884 (57bcce6) into grpc (6795656) will increase coverage by 0.45%.
The diff coverage is 21.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             grpc    #2884      +/-   ##
==========================================
+ Coverage   59.77%   60.22%   +0.45%     
==========================================
  Files         123      105      -18     
  Lines        9839     9464     -375     
  Branches        0     1656    +1656     
==========================================
- Hits         5881     5700     -181     
+ Misses       3958     3439     -519     
- Partials        0      325     +325     
Impacted Files Coverage Δ
bentoml/_internal/configuration/__init__.py 72.85% <0.00%> (-10.00%) ⬇️
...oml/_internal/server/grpc/interceptors/__init__.py 0.00% <0.00%> (ø)
...ntoml/_internal/server/grpc/interceptors/access.py 0.00% <0.00%> (ø)
...internal/server/grpc/interceptors/opentelemetry.py 0.00% <0.00%> (ø)
...l/_internal/server/grpc/interceptors/prometheus.py 0.00% <0.00%> (ø)
bentoml/_internal/server/grpc/server.py 0.00% <0.00%> (ø)
bentoml/_internal/server/grpc/servicer.py 0.00% <0.00%> (ø)
bentoml/_internal/server/grpc_app.py 0.00% <ø> (ø)
bentoml/_internal/server/http/access.py 85.50% <ø> (-11.60%) ⬇️
bentoml/_internal/server/http/instruments.py 100.00% <ø> (ø)
... and 91 more

@aarnphm aarnphm changed the title feat: IO descriptors feat(grpc): IO descriptors Aug 9, 2022
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
migrate setup.cfg to pyproject.toml

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
@aarnphm aarnphm force-pushed the feat/grpc-io-descriptor branch 3 times, most recently from 90f806e to de74ee7 Compare August 13, 2022 14:44
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 14, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
# https://numpy.org/doc/stable/user/basics.byteswapping.html#introduction-to-byte-ordering-and-ndarrays
bytesorder = "C" # default from numpy (C-order)

self._bytesorder: t.Literal["C", "F", "A"] = bytesorder
Copy link
Member

Choose a reason for hiding this comment

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

remove _bytesorder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_bytesorder can be used for np.frombuffer.

if shapepb:
shape = tuple(shapepb)
if self._shape:
logger.warning(
Copy link
Member

Choose a reason for hiding this comment

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

When force_shape is True, we should always use the shape specified when creating the Numpy io descriptor, not using the shape in request. Let's just raise an exception if the specified shape is different from the shape in the request if enforce shape is True. Make sure to handle the -1 case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is checked on L410 right?

f"'enforce_dtype={self._enforce_dtype}', using '{self._dtype}'..."
)
dtype = self._dtype
field_values = npdtype_to_fieldpb_map()[dtype]
Copy link
Member

Choose a reason for hiding this comment

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

This is not the right behavior. let's just convert the numpy array from proto first, and then check with np.can_cast. reuse the validation function above.

dtype=dtype,
count=num_entries,
offset=0,
).reshape(shape)
Copy link
Member

Choose a reason for hiding this comment

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

add self.validate_array here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to right? we already cast the dtype and reshape it with shape

# validate gRPC content type if content type is specified
validate_content_type(context, self)

field = ast.literal_eval(get_field(request, self))
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can an put a bytes string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should also allow a bytes field in all of the message.

aarnphm added a commit that referenced this pull request Aug 15, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 15, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 17, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 19, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 22, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 24, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 25, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 26, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Aug 31, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Sep 1, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Sep 5, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit that referenced this pull request Sep 8, 2022
See #2771 #2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884

add gRPC context and types

add descriptor metaclass

add metaclass field for proto value

verify_ndarray takes shape and dtype

update types imports to public API

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Co-authored-by: Sadab Hafiz <sadabhafizny@gmail.com>
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm added a commit to aarnphm/BentoML that referenced this pull request Sep 11, 2022
See bentoml#2771 bentoml#2884 bentoml#2906

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
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.

3 participants