Package: cadcadgolem
cadCAD GolemWork in progress - due date 5 January 2021 - (https://gitcoin.co/issue/golemfactory/hackathons/3/100024408)This package is a wrapper for cadCAD to dispatch the simulation workload to multiple Golem nodes.cadCADis a Python package that assists in the processes of designing, testing and validating complex systems through simulation, with support for Monte Carlo methods, A/B testing and parameter sweeping.Golemis a global, open source, decentralized supercomputer that anyone can access. It is made up of the combined power of users' machines, from PC's to entire data centers.NoteJupyter Notebook support added.The Golem network is still under development, and not all nodes behave perfectly. If your simulatino fails, try again a few times.Getting StartedInitialise/Create environment and working directoryIf you are already using cadCAD, activate the virtual environment that you use for cadCAD. This might look something like:source~/.venv/cadcadIf you do not yet have a working directory or virtual environment, creat both and activate. Something like so:mkdir-p~/projects/cadcad-expcd~/projects/cadcad-exp
python3-mvenv.venvsource.venv/bin/activateNow you have an isolated environment where you can install your python packages without fear of bloating the rest of your system.Install cadcadgolemRequires>= Python 3.8Install Usingpip$pip3installcadcadgolemInstallyagna daemonThe Yagna daemon is what you will use to interface with the Golem network. It runs in the background, waiting for API calls from your applications, in our case, fromcadcadgolem.To install yagna, you can use their helper script:curl -sSf https://join.golem.network/as-requestor | bash -For manual installation instructions, see: (https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development)To check it is installed corretly, run:yagna --versionPrepareyagna daemonTo run the yagna daemon, follow the following sequence. This sequence will need to be followed everytime you restartyagna.Start the daemonThis will initialise the daemonyagna service runGenerate the app key (This only has to done once after initial install ofyagna)yagna app-key create requestorThis should produce a 32-character-long hexadecimal app key that you need to note down as it will be needed in your code to run the requestor agent.Get some coinageGolem currently has a faucet where you can get free tokens to pay for the processing that you will perform on the network.yagna payment init -rCheck that the fund transfer was successfull.yagna payment statusAdd your app-key to your codeWhen using cadcadgolem, a dictionary is passed that contains the parameters for your interaction with the network. One of them is yor app-key, which allows you to speak to theyagnadaemon that you started earlier. Place your app-key into your dictionary (see dictionary below).Using cadcad GolemTo use cadcad Golem, you need to do three things:Import the cadcad Golem Ambassador:from cadcadgolem.golem_embassy import AmbassadorDefine the golem_conf dictionary:golem_conf = {
        'NODES': 3, # Number of nodes to utilise from the Golem Network. If you've got a big simulation to run, try pushing this up to 30. Remember you need at least twice as many simulation runs as you have nodes.
        'BUDGET': 10.0, # Maximum amount of crypto you are prepared to spend
        'SUBNET': "community.3", # choose your subnet, currently this is the test network
        'YAGNA_APPKEY': '<YOUR-YAGNA_APPKEY-GOES HERE>', # get this from `yagna app-key list`
        'TIMEOUT': 120 # In seconds - you will need to figure this out for your workload. Max currently is 25min, so 25 * 60 seconds
        }ExampleWrap your cadcadExecutorin the cadcad GolemAmbassador:Executor = Ambassador(Executor, golem_conf)ExampleFor a simple Jupyter Notebook example, seeparam_sweep.ipynbFor a simple python script implementation, seesimple_cadcad.pySystem initialisation after first installyagna service runyagna payment init -rRun your cadCAD code!cadCAD Examples/DemosYou can find more cadCAD demos to play with here:https://github.com/cadCAD-org/demosTo modify them them to work with cadcadGolem, just add the golem_conf dictionary declaration as above, and then wrap the cadCADExecutorwith the cadCADGolemAmbassadorand you're done.Security NoticeThe communication on the Golem network is currently not encrypted, so do not use this for any sensitive data.CaveatsYou need at least twice as many simulation runs as you have nodes, else it the simulation will fail.