Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Update Python SDK to use MLMD gRPC service #156

Merged
merged 9 commits into from Nov 12, 2019

Conversation

zhenghuiwang
Copy link
Contributor

@zhenghuiwang zhenghuiwang commented Nov 4, 2019

What this PR does / why we need it:
Related to #155

This PR updates the python SDK.

  • New Store class is introduced for connecting to MLMD gRPC service, which returns ml_metadata.metadata_store.MetadataStore.
  • Old backend_url option for connecting to HTTP service is deprecated.
  • Change E2E test to test python SDK with gRPC service.

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 the backend_url is set.

I will update the demo notebook and upload the package to pypi in next PR.


This change is Reviewable

sdk/python/kubeflow/metadata/metadata.py Outdated Show resolved Hide resolved
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
Copy link
Member

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?

Copy link
Contributor Author

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.

test/scripts/setup-services-run-tests.sh Show resolved Hide resolved
@zhenghuiwang
Copy link
Contributor Author

Thanks for the review @jinchihe

I updated the PR and it is ready for review @gaoning777

@zhenghuiwang zhenghuiwang marked this pull request as ready for review November 5, 2019 04:08
@zhenghuiwang
Copy link
Contributor Author

/test kubeflow-metadata-presubmit

@jinchihe
Copy link
Member

jinchihe commented Nov 7, 2019

/lgtm

config.host = grpc_host
config.port = grpc_port
if root_certificates or private_key or certificate_chain:
config.ssl_config = config.SSLConfig()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.

@zhenghuiwang
Copy link
Contributor Author

Thanks @gaoning777 @jinchihe for review!

@gaoning777 addressed your comments. PTAL

@gaoning777
Copy link
Contributor

/lgtm

@zhenghuiwang
Copy link
Contributor Author

/approve

@k8s-ci-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit a38effc into kubeflow:master Nov 12, 2019
kwasi pushed a commit to kwasi/metadata that referenced this pull request Nov 12, 2019
* 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
k8s-ci-robot pushed a commit that referenced this pull request Nov 14, 2019
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants