Code Monkey home page Code Monkey logo

osbrain's People

Contributors

flood1993 avatar fmonera avatar ileacristian avatar minrk avatar nicoddemus avatar ocaballeror avatar peque avatar radw2020 avatar rezabehzadpour avatar sgaist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osbrain's Issues

Refactor agent sockets

Agent code is starting to be a little mess right now. We should refactor sockets to inherit from zmq.sockets (we probably need to subclass zmq.Context too, then).

Sockets should store address information to avoid looking up tables (dictionaries) and to reduce the agent's number of attributes.

The API should be more homogeneous. In example, instead of multiple if-else cases, implement .send() methods in the sub-classed sockets that take care of peculiarities or special cases.

Changelog

A changelog file should be created starting on v1.0.0 to track future changes.

Documentation structure for 1.0.0

  • About
    • Feature overview
    • What can you use osBrain for?
    • Performance
  • Introduction
    • Installation
    • Hello world
    • Agents and Proxies
    • The name server
  • Basic communication patterns
    • Push pull pattern
      • Example
      • List of handlers
    • Request reply pattern
      • Example
      • Yield vs. return (reply early)
    • Publish subscribe pattern
      • Example
      • Filtering
  • Other considerations
    • Clients versus servers
    • Adding new methods
    • Lambdas
    • Shutting down
    • OOP
  • Other patterns? (i.e.: stream)
    • ...
  • Timers
    • Repeated actions
    • Delayed actions
    • Closing timers (#38, #22)
  • Transport protocol (#37, #25)
    • Introduction
    • Global configuration
    • Per-agent configuration
    • Per socket configuration
  • Serialization
    • Introduction
    • Global configuration
    • Per-agent configuration
    • Per socket configuration
  • Advanced proxy handling
    • Understanding proxies better
    • Executing unsafe calls
  • Distributed systems (#4)
    • Accessing agents from another terminal through proxies
    • Example of distributed systems in the documentation
  • Security
  • Developers
    • Workflow
    • Installing dependencies
    • Running the tests
    • Generating documentation
  • API
  • Software license and disclaimer

Safe calls

By default proxies should use safe remote calls (i.e.: through inproc). This, though, should be configurable.

  • Create an UnsafeProxy class?
  • Use proxy.unsafe.<methodcall>?
  • Use unsafe=True parameter?

Steps:

  1. Make all current tests pass changing remote calls to safe (no new functionality).
  2. Create new tests to verify and implement the above functionality.

Concurrent proxies documentation

Add documentation on potentially blocking calls and ways to avoid them:

  • Changing the multiplexed server to a threaded server.
  • Using other communication patterns (i.e. PUB-SUB).
  • Using timers or changing the main loop.
  • Using one-way calls (explain the risks: one-way -> concurrency -> inproc is better -> timers).
  • Using a separate script/terminal for the configuration.

Synchronization with PUB-SUB patterns

osBrain should provide a convenient synchronizartion method when using PUB-SUB patterns. This is very useful for differential updates (i.e.: time series in osMarkets).

Implement two step interruption

Implement two step interruption for agents/name server. First SIGINT captured results in clean exit/kill (i.e.: agent waits for code execution and tear-down and name server waits for all agents to be unregistererd). If another SIGINT is captured, kill with no mercy (as we are doing it right now).

Review old examples

Some examples which do not appear in the online documentation may be outdated. Review and update them:

  • dipatcher
  • ventilator

Timers

Implement timers for agents.

Test SIGINTs

Create tests to verify behavior on interruption signals. In example, an interrupted system should end up with all agents and name server killed (no Python process should linger).

See 7cb8c6f (revert) for an example of how agents can remain alive after SIGINT.

Docs: Serialization

Documentation on serialization should include instructions on how to change the serialization method (i.e.: global setting, per-agent configuration and per-socket configuration).

Ideally, an example should be added to the examples folder.

There should be a subsection in this documentation page to warn about differences in PUB-SUB when using raw sockets (i.e.: topic is not separated from the message, the user must take care of that...). It just makes sense to have a "raw" ZeroMQ behavior when using the raw serialization.

Test handlers

  • Test handler with 2 parameters (agent, message)
  • Test handler with 3 parameters (agent, message, topic)
  • Test topic is properly filtered (no match, partial match, full match)

Safe/unsafe configurable proxy calls

Document #30.

Implemented:

  • proxy.safe.<methodcall> and proxy.unsafe.<methodcall> for per-call configuration.
  • Proxy(..., safe=True/False) initialization parameter.
  • Global OSBRAIN_DEFAULT_SAFE environment variable.

Replies with `yield`

Instead of manually executing .send(...) to reply earlier, could we use yield?

API review

  • BaseAgent --> Agent (keep "class BaseAgent(Agent): pass" for a while?)
  • Agent --> AgentProcess
  • run_agent(..., base=...) --> run_agent(..., agent=...)

Timer exception

Timers can reach a maximum recursion level and throw an exception.

Implement async calls

To avoid REQ-REP blocking, which would be useful for non-blocking safe calls, PUB-SUB synchronization, etc..

Migrate documentation to readthedocs

The documentation is up and running in readthedocs, but all the links/references to the documentation (i.e.: github, readme...) should be updated.

Old documentation from pypi (pythonhosted) should be removed.

95+% coverage

Reach at least 95% coverage, including branch coverage.

The only file currently under 95% is core.py.

asyncio

Integrate asyncio syntax in osBrain where possible? (it could be very convenient in some cases)

Configurable serialization

As of now, the default method for communication between agents is through pickle serialization. This makes feeding data through outside Python a difficult task. Use of picke should be optional. Add raw message passing?

Multiplex vs. thread server

The default, currently, is a multiplexed server. This, however, prevents the user from accessing concurrently an agent unless configured to use a threaded server before running it.

In order to allow fine-grained control, a threaded server approach would be better as long as, by default, proxies always used safe calls (serializing calls to the main thread using an inproc socket). With this approach, the user would be able to explicitly change the call to be unsafe and decide, for each call, between safe/unsafe.

Some calls like send could be async by default (i.e.: no return value).

Some calls could be changed to be unsafe by default (for example addr, or calls that are only reading memory).

  • Depends on #30.

Improve process dead/alive detection for tests

Depends on #59

Perhaps we could use https://github.com/giampaolo/psutil

import psutil
psutil.pids()

[1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224,
268, 1215, 1216, 1220, 1221, 1243, 1244, 1301, 1601, 2237, 2355,
2637, 2774, 3932, 4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 
4263, 4282, 4306, 4311, 4312, 4313, 4314, 4337, 4339, 4357, 4358, 
4363, 4383, 4395, 4408, 4433, 4443, 4445, 4446, 5167, 5234, 5235, 
5252, 5318, 5424, 5644, 6987, 7054, 7055, 7071]

New serialization options

Perhaps JSON should be added (included in Python standard libraries) and others could be considered such as MessagePack.

Tutorial expansion

Part II:

  • Dill serialization.
  • Timers.
  • Shutting down systems.
  • Accessing agents from another terminal through proxies.

NameServer proxy, methods and tests

Some name server methods are not accessible from a proxy. This should be fixed and a separate file for name server tests should be created.

Async safe calls

Make all safe calls async (try to call _loopback to see how it currently blocks: second message to inproc never gets processed...).

Depends on #30, #31.

Use memory view

For better performance, memoryview should be used to split subject and content in messages. Perhaps there are other parts in the code where this could be used (?).

Configurable transport protocol

Make the (default) transport protocol configurable in osBrain. Probably socket addresses should integrate information about the transport protocol (i.e.: a connect should always use the appropriate transport protocol).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.