Package: automanpy
AutomanPyPython bindings for AutoMan. SeeAutoMan.
This package is currently in development.System RequirementsTo use this package you must be running Python 2.7.15 or 3.2+,Java 8, and Scala 2.11.7+. This package relies onScalaPBandgRPC. If you use SBT to build this project, all Scala dependencies will be downloaded. To install gRPC for Python (needed for the Python client), follow theseinstructions.How to InstallUse pip to install AutoManPy.pip install automanpyThis software package is currently in development, and will be updated regularly for bug fixes, etc.
If you want to upgrade, or force the installation of the latest version, use '--no-cache-dir' and '--upgrade'pip install --no-cache-dir automanpy --upgradeHow to Build SourceThe easiest way to build this project is by usingSBT.To build the source automatically, you can run./buildproject.shlocated in the root directory. This relies on sbt being installed.To build this project manually, from the /AutomanPy directory, runsbt clean compile packSBT will also compile the necessary .proto into Scala classes automatically. To generate the the python files needed,grpcio-toolsandgoogleapis-common-protosneed to be installed. These python dependencies are automatically installed by pip if this package is installed from the provided tarball (). To install the necessary packages manually, run the following two commands:pip install grpcio-tools
pip install googleapis-common-protosTo use gRPC generate the python files needed for interacting with the RPC service, from the /AutomanPy directory, run the following command:python -m grpc_tools.protoc -I src/main/protobuf/ --python_out=src/main/automanpy/automanpy/core/grpc_gen_classes/ --grpc_python_out=src/main/automanpy/automanpy/core/grpc_gen_classes src/main/protobuf/core/grpc_gen_classes/automanlib_rpc.proto src/main/protobuf/core/grpc_gen_classes/automanlib_classes.proto src/main/protobuf/core/grpc_gen_classes/automanlib_wrappers.protoMove the files compiled by sbt into the correct directory by copying them:cp -r target/pack/ src/main/automanpy/automanpy/core/rpc/server/Then change to the directory containing setup.py and run it from there:cd src/main/automanpy/
python setup.py clean sdistHow to UseTo run tasks, first create an Automan object. The constructor for Automan objects requires an adapter, and take optional parameters for the RPC server address and port number (default is 'localhost' and 50051).  The adapter we pass to the constructor is simply a dictionary with the following required fields:access_id - the login id for the crowdsource backendaccess_key - the login access key for the crowdsource backendtype - the type of crowdsource backend. currently only "mturk" is an accepted typeany optional arguments for the adapter (currently only "sandbox_mode" for MTurk adapter)First, import the Automan and EstimateOutcome classes from automanpy.automan, then create an adapterPython2.7.15|Anaconda,Inc.|(default,May12018,18:37:05)[GCC4.2.1CompatibleClang4.0.1(tags/RELEASE_401/final)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>fromautomanpy.automanimportAutoman,EstimateOutcome>>>adapter={..."access_id":"access id here",..."access_key":"access key here",..."sandbox_mode":"true",..."type":"MTurk"...}When an Automan object is being initialized, if the server_addr is 'localhost' it will start a local AutoMan RPC server as a new process, configured to listen on the provided port number. Future functionality will allow users to connect to remote RPC servers. We can now use the Automan object to submit tasks to the crowdsource back-end. Currently, only theestimatefunction of Automan is available. See example code for usage.>>>a=Automan(adapter,server_addr='localhost',port=50051)pythonclientisstartingserver...ServerStartedonport50051...>>>photo_url="https://docs.google.com/uc?id=1ZQ-oL8qFt2tx_T_-thev2O4dsugVbKI2">>>estim=a.estimate(text="How many cars are in this parking lot?",budget=6.00,title="Car Counting",image_url=photo_url)Each type of task has fields that are required. All tasks requiretext(a text description of the task), andbudget(desired upper limit of cost of task). We specify the tasks we would like AutoMan to carry out, and either when the question has timed out and budget is exceeded (resulting in a low confidence or overbudget outcome respectively) or the desired confidence level has been met.The outcome can be either:Confident estimateLow Confidence estimateOverbudgetIf the task went overbudget, theneedandhavefields of the returned EstimateOutcome are initialized, otherwisehigh,low,est,cost, andconfare initialized. AutomanPy uses gRPC's implementation of Futures. To ensure the future is resolved before values are accessed, only try to access respective values within code blocks that ensure those values are set. See methodsisConfident(),isLowConfidence(), andisOverBudget()below. To see more example code, and an example for posting multiple tasks, see AutomanPy/examplesTo simply print the result of the task, useprintOutcome().estim.printOutcome()>>>estim.printOutcome()Outcome:LowConfidenceEstimateEstimatelow:62.000000high:62.000000est:62.000000Example CodeSee example usage for submitting single and multiple estimate tasks inexamples/APISee the API underexamples/