hequn8128 commented on a change in pull request #11198: [FLINK-16248][python][ml] Add interfaces for MLEnvironment and MLEnvironmentFactory URL: https://github.com/apache/flink/pull/11198#discussion_r384232990
########## File path: flink-python/pyflink/ml/ml_environment_factory.py ########## @@ -0,0 +1,113 @@ +################################################################################ +# 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 typing import Optional +from pyflink.ml.ml_environment import MLEnvironment +from pyflink.dataset import ExecutionEnvironment +from pyflink.datastream import StreamExecutionEnvironment +from pyflink.table import BatchTableEnvironment, StreamTableEnvironment +from pyflink.java_gateway import get_gateway +import threading + + +class MLEnvironmentFactory: + """ + Factory to get the MLEnvironment using a MLEnvironmentId. + """ + _lock = threading.RLock() + _default_ml_environment_id = 0 + _next_id = 1 + _map = {_default_ml_environment_id: None} + + @staticmethod + def get(ml_env_id: int) -> Optional[MLEnvironment]: Review comment: There is no `Long` type in Python3 and we drop Python2 support a few months ago. Integers in Python 3 are of unlimited size. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
