NDlib-Rest - Network Diffusion Library REST Service.
This project offers a REST interface for the ndlib Python library.
- REST service: ndrest.py
- Web API docs: http://127.0.0.1:5000/docs
- Unittest: ndlib-rest/service_test
- Python REST client: ndlib-rest/client
Python 3.6 required dependencies:
REST service setup
Local testig with multiple workers (using gunicorn web server):
gunicorn -w num_workers -b 127.0.0.1:5000 ndrest:app
In order to change the binding IP/port modify the apidoc.json file. To update the API page run the command:
apidoc -i ndlib-rest/ -o ndlib-rest/static/docs
The web application (REST service and Viz framework) is shipped as a Docker container. You can use the Dockerfile to create a new image and run the web application using the gunicorn application server.
To create the Docker image, install Docker on your machine. To create the image execute the following command from the local copy of the repository
docker build -t [tagname_for_your_image] .
The command create a new image with the specified name. Pay attention to the
. a the end of the command.
docker run -d -i -p 5000:5000 -p 8080:8080 [tagname_for_your_image]
This command execute a container with the previous image, bind the local port 5000 to the internal port of the container.
-d make the container to run in the background (detached)
To have a list of all active container
docker ps -al
To stop a container
docker stop container_name
Prebuilt Docker image
To avoid docker image building just download the full container (beta version)
docker pull rossetti/ndrest:ndrest_beta
Once the image is ready run it as:
docker run -d -i -p 5000:5000 -p 8080:8080 rossetti/ndrest:ndrest_beta
REST service details
In ndrest.py are specified limits for graph sizes. In particular it describes the minimum and maximum numbers of nodes (for both generators and loaded networks) as well as the maximum file sizes for upload.
app.config['MAX_CONTENT_LENGTH'] = 50 * 1024 * 1024 # 50MB limit for uploads max_number_of_nodes = 100000 min_number_of_nodes = 200 # inherited by networkx
- The "complete graph generator" endpoint represents the only exception to the specified lower bound on number of nodes: such model lowers the minimum to 100 nodes. Indeed, the suggested limits can be increased to handle bigger graphs.
- When loading external graphs nodes MUST be identified by integer ids.