From c6f50c331d77140058ef03e403043d00b876502f Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 27 Nov 2018 16:56:32 +0800 Subject: [PATCH] add setup.py for installation (#30) * add setup.py for installation * rename agent.py to make it consistent with other framework base * namespace bug --- parl/__init__.py | 6 ++++ parl/framework/__init__.py | 3 ++ .../{computation_task.py => agent_base.py} | 14 ++++---- parl/layers/__init__.py | 2 +- setup.py | 35 +++++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) rename parl/framework/{computation_task.py => agent_base.py} (88%) create mode 100644 setup.py diff --git a/parl/__init__.py b/parl/__init__.py index eca2dce..cec8b25 100644 --- a/parl/__init__.py +++ b/parl/__init__.py @@ -11,3 +11,9 @@ # 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. +""" +generates new PARL python API +""" +from parl.framework import * +from parl.utils import * +from parl.plutils import * diff --git a/parl/framework/__init__.py b/parl/framework/__init__.py index eca2dce..8ca1bb9 100644 --- a/parl/framework/__init__.py +++ b/parl/framework/__init__.py @@ -11,3 +11,6 @@ # 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 parl.framework.model_base import * +from parl.framework.algorithm_base import * +from parl.framework.agent_base import * diff --git a/parl/framework/computation_task.py b/parl/framework/agent_base.py similarity index 88% rename from parl/framework/computation_task.py rename to parl/framework/agent_base.py index aca2a8d..3c32327 100644 --- a/parl/framework/computation_task.py +++ b/parl/framework/agent_base.py @@ -15,20 +15,20 @@ import paddle.fluid as fluid import parl.layers as layers from parl.framework.algorithm_base import Algorithm -from parl.framework.base import Model +from parl.framework.model_base import Model -__all__ = ['ComputationTask'] +__all__ = ['Agent'] -class ComputationTask(object): +class Agent(object): """ - A ComputationTask is responsible for the general data flow + A Agent is responsible for the general data flow outside the algorithm. - A ComputationTask is created in a bottom-up way: + A Agent is created in a bottom-up way: a. create a Model b. create an Algorithm with the model as an input - c. define a ComputationTask with the algorithm + c. define a Agent with the algorithm """ def __init__(self, algorithm): @@ -68,6 +68,6 @@ class ComputationTask(object): def learn(self, obs, action, reward, next_obs, terminal): """pass data to the training program to update model, - this function is the training interface for ComputationTask. + this function is the training interface for Agent. """ raise NotImplementedError diff --git a/parl/layers/__init__.py b/parl/layers/__init__.py index a615ae1..fd86c43 100644 --- a/parl/layers/__init__.py +++ b/parl/layers/__init__.py @@ -16,4 +16,4 @@ This file wraps Fluid layers that have parameters to support parameter sharing. For other layers that don't have parameters, we simply copy them to this namespace. """ from paddle.fluid.layers import * -from .layer_wrappers import * +from parl.layers.layer_wrappers import * diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c096733 --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed 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. + +import sys +import os +import re +from setuptools import setup, find_packages + + +def _find_packages(prefix=''): + packages = [] + path = '.' + prefix = prefix + for root, _, files in os.walk(path): + if '__init__.py' in files: + packages.append(re.sub('^[^A-z0-9_]', '', root.replace('/', '.'))) + return packages + + +setup( + name='parl', + version=0.1, + packages=_find_packages(), + package_data={'': ['*.so']}) -- GitLab