Skip to content

Commit

Permalink
[FLINK-16249][python][ml] Add interfaces for Params, ParamInfo and Wi…
Browse files Browse the repository at this point in the history
…thParams

This closes apache#11220.
  • Loading branch information
hequn8128 authored and dianfu committed Mar 6, 2020
1 parent 1a4fb25 commit b7f53c2
Show file tree
Hide file tree
Showing 17 changed files with 745 additions and 12 deletions.
2 changes: 1 addition & 1 deletion flink-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The auto-generated Python docs can be found at [https://ci.apache.org/projects/f

## Python Requirements

Apache Flink Python API depends on Py4J (currently version 0.10.8.1), CloudPickle (currently version 1.2.2), python-dateutil(currently version 2.8.0) and Apache Beam (currently version 2.19.0).
Apache Flink Python API depends on Py4J (currently version 0.10.8.1), CloudPickle (currently version 1.2.2), python-dateutil(currently version 2.8.0), Apache Beam (currently version 2.19.0) and jsonpickle (currently 1.2).

## Development Notices

Expand Down
1 change: 1 addition & 0 deletions flink-python/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Welcome to Flink Python API Docs!
pyflink.table
pyflink.dataset
pyflink.datastream
pyflink.ml


Core Classes:
Expand Down
52 changes: 52 additions & 0 deletions flink-python/docs/pyflink.ml.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. ################################################################################
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
################################################################################
pyflink.ml package
=====================

Module contents
---------------

.. automodule:: pyflink.ml
:members:
:undoc-members:
:show-inheritance:

pyflink.ml.api module
---------------------------
.. automodule:: pyflink.ml.api
:members:
:undoc-members:

pyflink.ml.api.param module
---------------------------
.. automodule:: pyflink.ml.api.param
:members:
:undoc-members:

pyflink.ml.lib module
-------------------------------------
.. automodule:: pyflink.ml.lib
:members:
:undoc-members:

pyflink.ml.lib.param module
---------------------------
.. automodule:: pyflink.ml.lib.param
:members:
:undoc-members:
13 changes: 13 additions & 0 deletions flink-python/pyflink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# limitations under the License.
#################################################################################
import sys
from functools import wraps

if sys.version_info < (3, 5):
raise RuntimeError(
Expand All @@ -37,3 +38,15 @@ def deco(f):
f.__doc__ = original_doc.rstrip() + "\n\n%s.. versionadded:: %s" % (indent, version)
return f
return deco


def keyword(func):
"""
A decorator that forces keyword arguments usage and store actual
input keyword arguments in `_input_kwargs`.
"""
@wraps(func)
def wrapper(self, **kwargs):
self._input_kwargs = kwargs
return func(self, **kwargs)
return wrapper
7 changes: 0 additions & 7 deletions flink-python/pyflink/ml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,3 @@
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

from pyflink.ml.ml_environment import MLEnvironment
from pyflink.ml.ml_environment_factory import MLEnvironmentFactory

__all__ = [
"MLEnvironment", "MLEnvironmentFactory"
]
24 changes: 24 additions & 0 deletions flink-python/pyflink/ml/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
################################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

from pyflink.ml.api.ml_environment import MLEnvironment
from pyflink.ml.api.ml_environment_factory import MLEnvironmentFactory

__all__ = [
"MLEnvironment", "MLEnvironmentFactory"
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
################################################################################

from typing import Optional
from pyflink.ml.ml_environment import MLEnvironment
from pyflink.ml.api.ml_environment import MLEnvironment
from pyflink.dataset import ExecutionEnvironment
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.table import BatchTableEnvironment, StreamTableEnvironment
Expand Down
21 changes: 21 additions & 0 deletions flink-python/pyflink/ml/api/param/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
################################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

from pyflink.ml.api.param.base import WithParams, Params, ParamInfo, TypeConverters

__all__ = ['WithParams', 'Params', 'ParamInfo', 'TypeConverters']
Loading

0 comments on commit b7f53c2

Please sign in to comment.