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

[FLINK-16248][python][ml] Add interfaces for MLEnvironment and MLEnvironmentFactory #11198

Merged
merged 2 commits into from Feb 26, 2020

Conversation

hequn8128
Copy link
Contributor

What is the purpose of the change

Align interface for MLEnvironment and MLEnvironmentFactory, so Python users can use Python MLEnvironmentFactory to maintain execution environment and table environment.

Brief change log

  • Add MLEnvironment and MLEnvironmentFactory interface.
  • Remove is_blink_planner parameter for TableEnvironment init method.
  • Add tests.

Verifying this change

This change added tests and can be verified as follows:

  • Add MLEnvironmentTest to test the logic in MLEnvironment.
  • Add MLEnvironmentFactoryTest to test the logic in MLEnvironmentFactory.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (Yes)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (yes)
  • If yes, how is the feature documented? (PythonDocs)

@hequn8128 hequn8128 assigned dianfu and unassigned dianfu Feb 24, 2020
@dianfu dianfu self-assigned this Feb 24, 2020
@hequn8128
Copy link
Contributor Author

@becketqin @walterddr Would be great if you can also take a look.

@flinkbot
Copy link
Collaborator

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 2683ef7 (Mon Feb 24 07:31:21 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Feb 24, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@becketqin becketqin left a comment

Choose a reason for hiding this comment

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

Made a quick pass. LGTM in general. Just two minor comments.

_inited = False

@staticmethod
def _ensure_path(pattern):
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 method be in pyflink.testing.test_case_util?

Copy link
Contributor Author

@hequn8128 hequn8128 Feb 25, 2020

Choose a reason for hiding this comment

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

It sounds like a good idea. I will move it there.

@@ -76,14 +76,24 @@ class TableEnvironment(object):

__metaclass__ = ABCMeta

def __init__(self, j_tenv, is_blink_planner, serializer=PickleSerializer()):
def __init__(self, j_tenv, serializer=PickleSerializer()):
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the changes in this class relevant to the MLEnvironment and MLEnvironmentFactory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will be more friendly to create the corresponding table environment in MLEnvironmentFactory.get_default(), e.g., we don not need to pass the is_blink_planner variable when creating StreamTableEnvironment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect others to construct TableEnvironment? Isn't this a public constructor?

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 is an internal constructor which takes a java table environment object as a parameter. For users, the StreamTableEnvironment.create() is called to create the Environment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Thanks for the explanation.

@hequn8128
Copy link
Contributor Author

hequn8128 commented Feb 25, 2020

@becketqin Thanks a lot for your review. I have updated the PR according to your comments. (Have also fixed some checkstyle problems.)

@becketqin
Copy link
Contributor

The patch LGTM.

@becketqin
Copy link
Contributor

@flinkbot approve all

Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @hequn8128 . The patch looks good to me overall.
I am not expert in python, but I have one question left. please kindly take a look.

_map = {_default_ml_environment_id: None}

@staticmethod
def get(ml_env_id: int) -> Optional[MLEnvironment]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the ID in Java is Long type?

Copy link
Contributor Author

@hequn8128 hequn8128 Feb 26, 2020

Choose a reason for hiding this comment

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

Hi, appreciate your feedback! There is no Long type in Python3 and we drop Python2 support a few months ago. Integers in Python 3 are of unlimited size.

@hequn8128
Copy link
Contributor Author

@becketqin @walterddr Hi, thanks a lot for your review and nice feedback. 👍
I will merge this PR late today. Let me know if there are any other problems. Thanks.

Best, Hequn

@hequn8128 hequn8128 merged commit ce0366d into apache:master Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants