Created
April 8, 2015 01:37
-
-
Save keiono/307893c4d3071b3b512e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 358, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import requests\n", | |
"import json\n", | |
"import py2cytoscape.util as cy\n", | |
"import networkx as nx\n", | |
"\n", | |
"g = nx.scale_free_graph(500)\n", | |
"cyg = cy.from_networkx(g)\n", | |
"\n", | |
"BASE = 'http://192.168.59.103/v1/'\n", | |
"HEADERS = {'Content-Type': 'application/json'}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 383, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"http://192.168.59.103/v1/visualization/layout/fdp\n", | |
"{\n", | |
" \"status\": \"queued\", \n", | |
" \"url\": \"http://192.168.59.103/v1/jobs/a445706f-d818-4e47-b644-0c89765343e0\", \n", | |
" \"job_id\": \"a445706f-d818-4e47-b644-0c89765343e0\"\n", | |
"}\n" | |
] | |
} | |
], | |
"source": [ | |
"# Apply layout URL:\n", | |
"url_apply = BASE + 'visualization/layout/fdp'\n", | |
"print(url_apply)\n", | |
"\n", | |
"res = requests.post(url_apply, data=json.dumps(cyg), headers=HEADERS)\n", | |
"res.json()\n", | |
"print(json.dumps(res.json(), indent=4))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 387, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"http://192.168.59.103/v1/jobs\n", | |
"[\n", | |
" {\n", | |
" \"status\": \"finished\", \n", | |
" \"job_id\": \"6b9ed0c8-6907-435c-a4b3-94d9c71217f0\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"finished\", \n", | |
" \"job_id\": \"5d50e264-37e3-4e95-b0b1-943954e22dcf\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"finished\", \n", | |
" \"job_id\": \"dd6f3dd0-e074-42ad-b82b-f867828c4d90\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"started\", \n", | |
" \"job_id\": \"cd215c4b-13da-4c12-bafe-9bdc83d13bff\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"started\", \n", | |
" \"job_id\": \"9cb2c73a-61bc-4deb-89c4-5bcaf6c77dc5\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"started\", \n", | |
" \"job_id\": \"fb734014-13ed-4afc-bb6e-ec287e4ea753\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"queued\", \n", | |
" \"job_id\": \"2f920e69-152c-4496-bc9e-71a9f4fbf446\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"queued\", \n", | |
" \"job_id\": \"2d5426ef-f2a0-487a-b4c9-32b7030d5ca6\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"queued\", \n", | |
" \"job_id\": \"88f6e1ab-eca7-4a26-b3ff-881ee7dd4eef\"\n", | |
" }, \n", | |
" {\n", | |
" \"status\": \"queued\", \n", | |
" \"job_id\": \"a445706f-d818-4e47-b644-0c89765343e0\"\n", | |
" }\n", | |
"]\n" | |
] | |
} | |
], | |
"source": [ | |
"# Job Status\n", | |
"url_jobs = BASE + 'jobs'\n", | |
"print(url_jobs)\n", | |
"\n", | |
"res = requests.get(url_jobs)\n", | |
"print(json.dumps(res.json(), indent=4))" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment