{ "info": { "author": "Eran Agmon, Ryan Spangler", "author_email": "eagmon@stanford.edu, spanglry@stanford.edu", "bugtrack_url": null, "classifiers": [], "description": "# Environment\n\nModels of environments, which can be interfaced with cells via the agent module.\nIncludes command line tools `environment.boot` for running environment and cell agents\nand `environment.control` for sending commands to agents.\n\n## Setup\n\nSee the top-level [README.md](../README.md) for general setup instructions, and the\n[actor/README.md](lens/actor/README.md) for multi-agent simulation setup.\n\n1. To run Whole Cell E.coli simulations, you need to have the sim_data files. You can generate them via the\nrunFitter manual runscript. In the wcEcoli directory:\n\n `> PYTHONPATH=\"$PWD\" python runscripts/manual/runFitter.py`\n\n## Zookeeper and Kafka\n\n2. See [actor/README.md](lens/actor/README.md) for instructions to set up, start, and stop your Zookeeper and Kafka servers. To recap:\n\n 1. Start Zookeeper in the directory where you untarred the Kafka and Zookeeper software:\n\n `> bin/zookeeper-server-start.sh config/zookeeper.properties`\n\n 2. Then start the Kafka server in another shell tab in the same directory:\n\n `> bin/kafka-server-start.sh config/server.properties --override listeners=PLAINTEXT://127.0.0.1:9092`\n\n3. **Optional:** Start the \"Lens\" environment visualization server and browser window per the instructions on the [CovertLab/shepherd](https://github.com/CovertLab/shepherd) page. To recap:\n\n 1. Run the Lens visualization server in the root directory of the [CovertLab/shepherd](https://github.com/CovertLab/shepherd) repository:\n\n `> lein run -m shepherd.lens`\n\n 2. Open a browser window onto [http://localhost:33332](http://localhost:33332)\n\n## One Agent Per Terminal Tab (esp. for debugging)\n\n**Note:** This section describes how to launch Environment and Cell agent processes directly\nfrom the command line. We usually use the \"Agent Shepherd\" approach described in the next section,\nbut the direct approach lets you launch agents under a debugger. You can use it for one or more\nagents together with others running under a shepherd.\n\n**Tip:** Run each process in a new terminal tab. Use iTerm split windows to make it easy to watch them all at once.\n\n4. In the first terminal tab, launch an Environment agent:\n\n `> python -m lens.environment.boot --type lattice --id lattice`\n\n The Environment agent will wait for Cell simulation agents to register.\n You can optionally pass in a JSON `--config '{...}'` dictionary.\n\n5. Now start a Cell agent in a new tab:\n\n `> python -m lens.boot_compartment --outer-id lattice --type lookup --id 1`\n\n Vary the agent type and other parameters as needed. Each agent needs an `id` that's unique among the\n currently running agents.\n\n You'll see messages like this one from the Cell agent to the Environment agent,\n declaring itself to the environment and giving its current state:\n\n `<-- environment-receive (CELL_DECLARE) [1]: {\"inner_id\": \"1\", \"agent_config\": {...}, \"state\": {\"volume\": 1.2, \"environment_change\": {}}, \"event\": \"CELL_DECLARE\", \"agent_id\": \"lattice\"}`\n\n In turn, the cell will receive messages like this:\n\n `--> cell-receive (ENVIRONMENT_SYNCHRONIZE) [1]: {u'inner_id': u'1', u'state': {u'time': 0}, u'outer_id': u'lattice', u'event': u'ENVIRONMENT_SYNCHRONIZE'}`\n\n6. To debug an agent using the PyCharm debugger, first create a Run/Debug Configuration with the\nmodule name and parameters on the command lines above, e.g.\n\n ```\n Name: cell agent\n\n Module name: environment.boot\n Parameters: ecoli --id 40\n Python interpreter: Python 2.7 (wcEcoli2)\n Working directory: /Users/YOU/dev/wcEcoli\n \u2611\ufe0e Add content roots to PYTHONPATH\n \u2611\ufe0e Add source roots to PYTHONPATH\n \u2611\ufe0e Run with Python console\n ```\n\n Then set your breakpoints and invoke the `Debug 'cell agent'` menu command.\n\n6. Start as many cells as desired, each with its own unique `id` agent name; each in a\nseparate terminal tab or PyCharm run/debug tab.\n\n7. Finally, use another terminal tab to start the simulation running:\n\n `> python -m lens.environment.control run --id lattice`\n\n You can `pause` and `run` it whenever you want.\n\n8. To shut down the simulation, run `shutdown` in the command tab:\n\n `> python -m lens.environment.control shutdown`\n\n## Agent Shepherd\n\nThe usual way to start the simulation is to use the agent \"Shepherd\", which is a process\nthat spawns agents in subprocesses (as requested via Kafka messages) so you don't have to\nlaunch each agent in its own terminal tab.\nFurthermore, this enables cell division wherein a cell agent process ends and two\nnew ones begin.\nBut to debug an agent, see the \"One Agent Per Terminal Tab\" instructions, above.\n\nClone the [CovertLab/shepherd](https://github.com/CovertLab/shepherd) repo and run:\n\n `> lein run`\n\nUse a \"Lens\" browser page to view the agents in action. To do this, open another shell\ntab onto the shepherd repo directory and run:\n\n `> lein run -m shepherd.lens`\n\nthen open a browser window onto [http://localhost:33332/](http://localhost:33332/)\n\nNow you can start a virtual microscope experiment in a \"command\" terminal tab:\n\n `> python -m lens.environment.control experiment --number 3`\n\nThis will send four `ADD_AGENT` messages to the shepherd: one for the _lattice environment_ agent and three for the _cell simulation_ agents. Note the `agent_id` for the lattice as you will need this for future control messages (like `run` and `shutdown`). These messages are received by the shepherd and you will see all the agents' logs in the \"shepherd\" tab.\n\nYou can `run`/`pause` the simulation at will:\n\n `> python -m lens.environment.control run`\n\n `> python -m lens.environment.control pause`\n\nYou can add another cell agent:\n\n `> python -m lens.environment.control add`\n\n(If you're running multiple environment agents, you can specify a lattice environment agent id via the `--id` option.)\n\nYou can remove a cell agent using the prefix of the agent's id (you don't have to type the whole id):\n\n `> python -m lens.environment.control remove --id dgaf`\n\nFinally, to shut down the experiment, run `shutdown`:\n\n `> python -m lens.environment.control shutdown`\n\nNotice this just shuts down the agents. The Shepherd is still running and ready for a new experiment.\nUse `Ctrl-C` to stop the Shepherd and Lens processes.\n\n## command summary\n\nThis is just a summary.\nUse the `-h` argument to get complete usage help on these command line programs.\n\nThe environment.boot commands run an agent in the current shell tab:\n\n* ecoli - an ecoli cell agent\n* lattice - a two dimensional lattice environment agent\n* chemotaxis - a chemotaxis surrogate that can move up glucose gradients within a chemotaxis_experiment\n\nThe environment.control commands include:\n\n* run - start/resume the simulation clock\n* pause - pause the simulation clock\n* shutdown - shutdown the simulation\n\nSome environment.control commands require an [agent shepherd](https://github.com/CovertLab/shepherd), including:\n\n* add - ask the shepherd to spawn an agent and add it to an environment\n* remove - ask the shepherd to remove an agent\n* experiment - ask the shepherd to spawn a lattice and multiple cell agents\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/CovertLab/Lens", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "lens-interface", "package_url": "https://pypi.org/project/lens-interface/", "platform": "", "project_url": "https://pypi.org/project/lens-interface/", "project_urls": { "Homepage": "https://github.com/CovertLab/Lens" }, "release_url": "https://pypi.org/project/lens-interface/0.0.27/", "requires_dist": [ "confluent-kafka (==0.11.5)", "numpy (==1.14.6)", "pymongo (==3.6.1)", "pytest (==4.6.5)" ], "requires_python": "", "summary": "", "version": "0.0.27" }, "last_serial": 5942209, "releases": { "0.0.26": [ { "comment_text": "", "digests": { "md5": "3bd2a4b2db02bd4f89b6b9f1e29b8983", "sha256": "4023709e6995e242fd439af41b550c1ab0be08e4886c03ab95bb011f32bf8ca2" }, "downloads": -1, "filename": "lens_interface-0.0.26-py2-none-any.whl", "has_sig": false, "md5_digest": "3bd2a4b2db02bd4f89b6b9f1e29b8983", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 32648, "upload_time": "2019-10-08T00:28:12", "url": "https://files.pythonhosted.org/packages/0e/a2/a6486bfc39a65a810c126579a0540866a305aeeb85fbf7c62aa5c2315580/lens_interface-0.0.26-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5355e6ab13269bbba666af5a9785f62e", "sha256": "c89a49e7cbb490827f9a108abb1ca8b70d1c4b2ec8b9340e43e7f3f7cdb09a49" }, "downloads": -1, "filename": "lens-interface-0.0.26.tar.gz", "has_sig": false, "md5_digest": "5355e6ab13269bbba666af5a9785f62e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29514, "upload_time": "2019-10-08T00:28:14", "url": "https://files.pythonhosted.org/packages/b8/10/53b2672f1100bb86bcc3f90edf03209dd20d63bd9ce39379ff6eb2458c5b/lens-interface-0.0.26.tar.gz" } ], "0.0.27": [ { "comment_text": "", "digests": { "md5": "037efa65c14be7de5396be11ca586343", "sha256": "ffa5ff348701a5c2b1784387b615542faff3a28e5736d607cf83844290bf25f4" }, "downloads": -1, "filename": "lens_interface-0.0.27-py2-none-any.whl", "has_sig": false, "md5_digest": "037efa65c14be7de5396be11ca586343", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 32859, "upload_time": "2019-10-08T00:36:43", "url": "https://files.pythonhosted.org/packages/5d/c7/a810bb51240a58b45febea916cd37cd3728107b9093847d2b06bc551da16/lens_interface-0.0.27-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bc77706068d12825d145fc6c5c5892d7", "sha256": "d34d82b3b27d17fe20988c6f3ea81a80377759135f798ca91c52facf45c11f0f" }, "downloads": -1, "filename": "lens-interface-0.0.27.tar.gz", "has_sig": false, "md5_digest": "bc77706068d12825d145fc6c5c5892d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29507, "upload_time": "2019-10-08T00:36:44", "url": "https://files.pythonhosted.org/packages/30/0b/0d7450bc05992d4291e5c53af01610c8a3ceac4d9e3fc88f984f28eaeb25/lens-interface-0.0.27.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "037efa65c14be7de5396be11ca586343", "sha256": "ffa5ff348701a5c2b1784387b615542faff3a28e5736d607cf83844290bf25f4" }, "downloads": -1, "filename": "lens_interface-0.0.27-py2-none-any.whl", "has_sig": false, "md5_digest": "037efa65c14be7de5396be11ca586343", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 32859, "upload_time": "2019-10-08T00:36:43", "url": "https://files.pythonhosted.org/packages/5d/c7/a810bb51240a58b45febea916cd37cd3728107b9093847d2b06bc551da16/lens_interface-0.0.27-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bc77706068d12825d145fc6c5c5892d7", "sha256": "d34d82b3b27d17fe20988c6f3ea81a80377759135f798ca91c52facf45c11f0f" }, "downloads": -1, "filename": "lens-interface-0.0.27.tar.gz", "has_sig": false, "md5_digest": "bc77706068d12825d145fc6c5c5892d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29507, "upload_time": "2019-10-08T00:36:44", "url": "https://files.pythonhosted.org/packages/30/0b/0d7450bc05992d4291e5c53af01610c8a3ceac4d9e3fc88f984f28eaeb25/lens-interface-0.0.27.tar.gz" } ] }