Git Product home page Git Product logo

pycloudmessenger's Introduction

travis-badge_

pycloudmessenger

The purpose of this project is to provide sample code for interacting with various messaging based cloud platforms provided by IBM Research Europe - Dublin.

Prerequisites

It is assumed that all development takes place in Python, using at least version 3.6.

Testing

Unit tests are contained in the tests directory.

To run the unit tests, a local RabbitMQ container is launched automatically. Settings and credentials to match the latest RabbitMQ docker image are also provided. To run the test:

creds=local.json make test 

Examples

Sample code for basic messaging as well as federated learning and castor are contained in the examples directory. To run various samples, invoke the appropriate make target, as follows.

# The basic messaging sample
creds=local.json make basic
# The federated learning sample (online, requires cloud credentials)

python -m examples.ffl.register --credentials=<CLOUDCREDENTIALS> --user=<USER> --password=<PASSWORD> > credentials.json
python -m examples.ffl.sample --credentials=credentials.json
python -m examples.ffl.deregister --credentials=credentials.json
# The castor sample
creds=credentials.json make castor

Note: For online platforms, <CLOUDCREDENTIALS> must be available. Please request from the IBM team.

References

This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 824988. https://musketeer.eu/

image

pycloudmessenger's People

Contributors

bradleyjeck avatar cclauss avatar fearghalodonncha avatar jdsheehan avatar kant avatar mathsinn avatar mkepurcell avatar mkpurcell avatar robertgo-ibm avatar stefano81 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycloudmessenger's Issues

The participant list in the aggregator is duplicated

Bug in Local platform:
The participant list in the aggregator is duplicated since it is updated everytime we call the receive and it contains a Notification.participant_joined but also when calling the method get_participants. I have created a task with 2 users (Marcos and Jaime) and this is the print from the ML library after calling get_participants:
Participants: ['Marcos', 'Jaime', 'Marcos', 'Jaime']

Task additional user info

Summary

Make sure you know which tasks the user is participating in and which tasks he is creator of.

Justification

So that you can filter and know which tasks a user is involved in.

Example

We've identified two solutions:

  1. Make sure that within the task model you know which tasks the user is participating in and the ones he is creator of: by name/id or boolean (the model could also be a DTO)

  2. Have a get_tasks_by_user method to return a lists of tasks for which the user is a participant or aggregator

Non-blocking receive functions

E.g. modify the receive methods for aggregator/participants to return a 204 code in case the corresponding queues were empty. With this control can be given back to the aggregator/participant part of the algorithm and avoid blocking the execution.

Additional task status

Summary

It would be helpful to have an intermediate status between CREATED and STARTED.

Justification

When a new task is added to the available ones it gets the CREATED status. As soon as its owner decides
to start the aggregation on the background the master waits for the workers number to reach the task quorum
in order to start the federated learning. Nevertheless, during this time the task status remains the same,
changing to STARTED only when the actual task execution starts. In this way, there is no way for other users
to understand whether that task owner has started the aggregation or not, getting an error if they choose
to join a task which has just been created and not yet aggregated.

"Must have" functionality

The additional task status (something like "PENDING") would have multiple benefits:

  • Aggregator receives a real feedback after the aggregation by checking the task status.
  • All the "participant" calls on tasks which are not waiting for workers are avoided.
  • Improved browsing on the tasks list.

Error classes

Summary

Define error classes.

Justification

In order to capture and handle in a custom way the error that occur.

Example

fflapi.py:

class ServerError(ValueError):
pass

class BadRequestError(ValueError):
pass


if 'error' in result:
raise ServerError(result['error'])

if 'calls' not in result:
raise BadRequestError("Malformed object: " + str(result))

controller.py:

from pycloudmessenger.ffl.fflapi import ServerError
from pycloudmessenger.ffl.fflapi import BadRequestError

@app.errorhandler(ServerError)
def server_error(error):
return jsonify({'message': str(error)}), 500, {'ContentType': 'application/json'}

@app.errorhandler(BadRequestError)
def server_error(error):
return jsonify({'message': str(error)}), 400, {'ContentType': 'application/json'}

Task model enrichment

Summary

Add this information at task level:
- task description
- the name of the task owner
- the POM
- algorithm name
- the quorum
- a “rewards” field to define how the task is rewarded
- a “datasets” field to define the topology and dataset description to be used
- the number or list of participants who have joined the task

Justification

Add useful information for the user who wants to join a task. All of this information should be set by the task creator.

"Must have" functionality

All of these information are stored during the task creation and retrievable by any user (ffl.get_tasks() method); some information may only be retrievable by the task creator.

Example

A JSON model example (we can further discuss about some of this information):

{
"task_name": "Test",
"status": "CREATED",
"description": "Task test",
"added": "2020-01-20T12:00:00",
"topology": "STAR",
"participants": 4,
"owner": "owner_name",
"model_type": "Kmeans",
"POM": 1,
"quorum": 5,
"reward": "collaborative"
"datasets": [
{
"type": "image",
"description": "High-res images depicting people",
"features": {
"extension": "png",
"maxHeight": 16000000,
"maxWidth": 16000000
}
},
{
"type": "tabular",
"description": "Data about people",
"sample": [
"Lucas",
35
],
"features": {
"extension": "csv",
"size": 223000000,
"columns": [
{
"name": "Name",
"type": "string",
"description": "Person first name",
"isLabel": false
},
{
"name": "Age",
"type": "number",
"description": "Person age",
"isLabel": true
}
]
}
}
],
"definition": {
"NC": 2,
"maxIterations": 100
}
}

Delete task method

Summary

Add a "delete_task" method inside fflapi.py

Justification

A user can remove its own tasks if he wants.

"Must have" functionality

Only the user who created his own task can remove it.

Sending of non-JSON serializable messages

Summary

Trying to send certain objects results in an error Object of type ... is not JSON serializable.
Could those be serialized using an encoding like

base64.b64encode(pickle.dumps(x)).decode('utf-8')

A participant with the same name can join a task multiple times

Bug in Local platform:
Currently, a participant with the same name can join a task multiple times, this is not allowable since it can break the logic of the platform, but it is currently assumed to let users to control this issue. However, this issue should be resoloved by the platform itself.

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.