Update Python SDK to use MLMD gRPC service #156
Update Python SDK to use MLMD gRPC service #156
Conversation
if backend_url_prefix is None or type(backend_url_prefix) != str: | ||
raise ValueError("'backend_url_prefix' must be set and in string type.") | ||
if backend_url_prefix: | ||
raise ValueError("""'backend_url_prefix' is deprecated. Please set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that better to WARNING here and remove from next release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original plan is to do what you suggested, but realized it would require to keep two ways of calling backends and the code would look messy.
Whoever want to use the previous SDK should ping down the version.
Thanks for the review @jinchihe I updated the PR and it is ready for review @gaoning777 |
/test kubeflow-metadata-presubmit |
/lgtm |
config.host = grpc_host | ||
config.port = grpc_port | ||
if root_certificates or private_key or certificate_chain: | ||
config.ssl_config = config.SSLConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be mlpb.MetadataStoreClientConfig.SSLConfig()? Maybe Protobuf support referencing the class through the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out this SubMessage ssl_config field is automatically initialized with properties with None value. So I removed this line.
But I found bug of MLMD when writing unit test:
File "/Users/zhenghui/kubeflow/metadata/.env/lib/python3.6/site-packages/ml_metadata/metadata_store/metadata_store.py", line 103, in _get_channel
certificate_chain)
File "/Users/zhenghui/kubeflow/metadata/.env/lib/python3.6/site-packages/grpc/__init__.py", line 1593, in ssl_channel_credentials
certificate_chain))
File "src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi", line 133, in grpc._cython.cygrpc.SSLChannelCredentials.__cinit__
TypeError: expected certificate to be bytes, got <class 'str'>
gRPC requires all three fields to be bytes (https://grpc.github.io/grpc/python/grpc.html#grpc.ssl_channel_credentials)
But MLMD pass them in as string.
The fix is outside the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind creating a bug for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaoning777 , shall we address this along with the python client grpc server test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM.
Thanks @gaoning777 @jinchihe for review! @gaoning777 addressed your comments. PTAL |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zhenghuiwang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* code complete; test passed * update e2e test * update comments * lint * lint & address comments * lint with yapf --style '{based_on_style: google, indent_width: 2}' * Adding Typing Hints; Rewrite docstrings * address comments * lint
…165) * Add metadata store protos * Add generated grpc protos for ml_metadata * Uses the version from Pipelines * Add generated grpc protos for ml_metadata * Bump `react-scripts` to 3.2.0 to support `EXTEND_ESLINT` environment variable, which is needed to `eslintIgnore` generated protos. * Add `api:metadata` script to regenerate grpc-web protos for ml_metadata. * Proxy requests to server to metadata-envoy-service * Move <rootDir>/__mocks__ into src to work around react-scripts@3.2.0 bug * facebook/create-react-app#7539 * Add `start-proxy.sh` to port forward to metadata-ui:3000 * Regenerate ArtifactList.test.tsx.snap - Old snapshots genreated with node 9.9.0 fail in node 12.13 used by docker image * Whitelist @jest/* packages in gen_licenses.js and point to third_party/jest/LICENSE * Switch ArtifactList getArtifactTypes to ml_metadata * Switch ArtifactList getArtifacts to ml_metadata * Use gRPC to fetch ArtifactDetails and ExecutionDetails * Mock grpc-web network calls * Use ml_metadata.Artifact in ModelInfo * Move repeated test model creation to TestUtils * Regenerate snapshot: ArtifactDetails.test.tsx.snap - Closing `}` were replaced with `)` in the commit to convert the snapshot to include a generated proto instead of a `Object` * Use ml_metadata.Exectuion in ExecutionList * Cleanup unused rpc in ArtifactList * Fix null check in ExecutionDetails * Regenerate ArtifactDetails snapshot after merging tabs with gRPC * Rewrite start-proxy.sh in node * Rewrite start-proxy.sh in node * Cosmetic changes to start-proxy.js * Fix brace styles * Rewrite gen_gprc_web_protos in node * Switch from @improbable-eng/grpc-web to grpc-web * Update grpc-web mock and fix failures in ArtifactDetails.test * Update Python SDK to use MLMD gRPC service (#156) * code complete; test passed * update e2e test * update comments * lint * lint & address comments * lint with yapf --style '{based_on_style: google, indent_width: 2}' * Adding Typing Hints; Rewrite docstrings * address comments * lint * [MLMD Lineage] Initial Lineage explorer draft implemented (#159) * Add metadata store protos * Add generated grpc protos for ml_metadata * Uses the version from Pipelines * Add generated grpc protos for ml_metadata * Bump `react-scripts` to 3.2.0 to support `EXTEND_ESLINT` environment variable, which is needed to `eslintIgnore` generated protos. * Add `api:metadata` script to regenerate grpc-web protos for ml_metadata. * Proxy requests to server to metadata-envoy-service * Move <rootDir>/__mocks__ into src to work around react-scripts@3.2.0 bug * facebook/create-react-app#7539 * Add `start-proxy.sh` to port forward to metadata-ui:3000 * Regenerate ArtifactList.test.tsx.snap - Old snapshots genreated with node 9.9.0 fail in node 12.13 used by docker image * Whitelist @jest/* packages in gen_licenses.js and point to third_party/jest/LICENSE * Switch ArtifactList getArtifactTypes to ml_metadata * Major changes 1.0 - Migrated half of lineage components - Rewrote all components in TS, updated and optimized to work in codebase - Css updated - **Erroneous, will fix** - Added gitignore - Added linter packages - Fixed spacing * Imported all elements * All of Lineage Explorer added: - All lineage components added - Card styles for target / execution cards - Rewrote the EdgeCavas renderer - Dyanmic updates and CSS updates to match live view - State diffing and rendering updates - Mocked data and presented on UI, via dynamic data - Z-indexing logic added to support reverse flipped connectors - State logic updated to match standard - Es6 Magic and refactor - Massive css updates (radio button revamp, et al) * Move changes to LineageView.tsx, which can then be used once Kwasi's changes are in * Resolved Kwasi's comments * Switch ArtifactList getArtifacts to ml_metadata * Rewrite start-proxy.sh in node * Switch from @improbable-eng/grpc-web to grpc-web * Fix package.json change introduced in rebase * Render LineageView in ArtifactDetails.LINEAGE_EXPLORER tab * Update ArtifactDetails snapshot * Update helper scripts - Fix extra parentheses in start-proxy.js and - Remove gen_grpc_web_protos.sh
What this PR does / why we need it:
Related to #155
This PR updates the python SDK.
Store
class is introduced for connecting to MLMD gRPC service, which returnsml_metadata.metadata_store.MetadataStore
.backend_url
option for connecting to HTTP service is deprecated.It is a breaking change, since the way to connect backend service changes. I keep the
backend_url
as optional parameter to ask users to update their code if thebackend_url
is set.I will update the demo notebook and upload the package to pypi in next PR.
This change is