Oracles (see mr_world) written in python. This repository contains 'utility oracles' to simplify daily operations e.g. mining data (parsing csv files), among other things. It also serves as an example/tutorial how to write and use oracles. Furthermore it will reveal important structures outside of proto definitions. For example that an oracle should provide a create_oracle, create_scenario helper functions to easily add it to a mr_world configuration. It is by no means complete and isn't supposed to be a metarepository for all python oracles.
Aside from the usual suspects (git, python, pip, protoc, grpc header files) one needs
pip install grpcio-tools
The repository contains mr_world_proto as
a git submodule. The corresponding generated python files should be in grpc_generated
, while
the actual oracle code is in oracles
.
For code generation run
python -m grpc_tools.protoc -I=mr_world_proto/world/ --python_out=grpc_generated --grpc_python_out=grpc_generated mr_world_proto/world/*.proto
Unfortunately there is a known issue
in dealing with packages, so one has to run the following python code from the proto root (grpc_generated
)
import os
path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) # run in a file
path = os.path.join(path, 'src') # package name where generated files are reside
file_path = f'{path}/*_pb2*.py*'
os.system(f'2to3 -wn -f import {file_path}')
for correct imports in the generated repository.
After installing the package via
python install .
it can be imported into other python files as
import oracles
Read the markdown files in oracles
for details on the specific oracles.
Author: Niklas Jona Lohmann