-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to Ndex.save_new_network to make network public on upload #10
Comments
Right now, my solution is to write a wrapper function around def cx_to_ndex(cx, username=None, password=None, public=False, debug=False):
"""Uploads a BEL graph to NDEx
:param cx: A CX representation of a BEL Graph
:type cx: dict
:param username: NDEx username
:type username: str
:param password: NDEx password
:type password: str
:param public: If true, makes the network public after uploading. Defaults to ``False``
:type public: bool
:param debug: If true, turn on NDEx client debugging
:type debug: bool
:return: The UUID assigned to the network by NDEx
:rtype: str
"""
ndex = Ndex(username=username, password=password, debug=debug)
res = ndex.save_new_network(cx)
url_parts = urlsplit(res).path
network_id = url_parts.split('/')[-1]
if public:
ndex.make_network_public(network_id)
return network_id As a side note, it would be nice for this function to return the UUID rather than the response, which contains the url that has the UUID in it. Now that i've done this, the The full testing log is available on https://travis-ci.org/cthoyt/pybel2cx/jobs/210230667) |
Hi Jing
This looks like the immediate update issue again, can you discuss our plans with Charlie
Dexter
… On Mar 12, 2017, at 3:47 AM, Charles Tapley Hoyt ***@***.***> wrote:
Right now, my solution is to write a wrapper function around ndex.save_new_network and parse the results from it to get the UUID with the following code in pybel2cx.io:
def cx_to_ndex(cx, username=None, password=None, public=False, debug=False):
"""Uploads a BEL graph to NDEx
:param cx: A CX representation of a BEL Graph
:type cx: dict
:param username: NDEx username
:type username: str
:param password: NDEx password
:type password: str
:param public: If true, makes the network public after uploading. Defaults to ``False``
:type public: bool
:param debug: If true, turn on NDEx client debugging
:type debug: bool
:return: The UUID assigned to the network by NDEx
:rtype: str
"""
ndex = Ndex(username=username, password=password, debug=debug)
res = ndex.save_new_network(cx)
url_parts = urlsplit(res).path
network_id = url_parts.split('/')[-1]
if public:
ndex.make_network_public(network_id)
return network_id
As a side note, it would be nice for this function to return the UUID rather than the response, which contains the url that has the UUID in it.
Now that i've done this, the Ndex.make_network_public function gives an error HTTPError: 500 Server Error: for url: http://public.ndexbio.org/v2/network/53f781b1-0710-11e7-aba2-0ac135e8bacf/systemproperty
The full testing log is available on https://travis-ci.org/cthoyt/pybel2cx/jobs/210230667 <https://travis-ci.org/cthoyt/pybel2cx/jobs/210230667>)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#10 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABDqrPFftvEQ59QfxjAy11WPrtABa5ZFks5rk80sgaJpZM4MGADI>.
|
Hi Charlie,
The current save_new_network() is an asynchronous function. It returns when the server received the CX network. The new network will be put in a queue, validated and indexed by NDEx server. Users can’t make any updates on the network before this process is finished and the network has to be a valid network.
In your use case. Your program need to poll the server (using the get_network_summary function) and check if the network is valid. The server only allows a valid network to be set public.
In the future, we are thinking of adding a set of synchronous save/update network functions in the NDEx server. This will work better for users who don’t require a quick return from those functions.
Thanks,
Jing
From: Dexter Pratt <dexterpratt.bio@gmail.com>
Date: Monday, March 13, 2017 at 8:49 AM
To: ndexbio/ndex-python <reply@reply.github.com>, "Chen, Jing" <jic002@soe.ucsd.edu>, Charles Hoyt <charles.hoyt@scai.fraunhofer.de>
Cc: ndexbio/ndex-python <ndex-python@noreply.github.com>, Subscribed <subscribed@noreply.github.com>
Subject: Re: [ndexbio/ndex-python] Add option to Ndex.save_new_network to make network public on upload (#10)
Hi Jing
This looks like the immediate update issue again, can you discuss our plans with Charlie
Dexter
On Mar 12, 2017, at 3:47 AM, Charles Tapley Hoyt <notifications@github.com<mailto:notifications@github.com>> wrote:
Right now, my solution is to write a wrapper function around ndex.save_new_network and parse the results from it to get the UUID with the following code in pybel2cx.io<http://pybel2cx.io>:
def cx_to_ndex(cx, username=None, password=None, public=False, debug=False):
"""Uploads a BEL graph to NDEx
:param cx: A CX representation of a BEL Graph
:type cx: dict
:param username: NDEx username
:type username: str
:param password: NDEx password
:type password: str
:param public: If true, makes the network public after uploading. Defaults to ``False``
:type public: bool
:param debug: If true, turn on NDEx client debugging
:type debug: bool
:return: The UUID assigned to the network by NDEx
:rtype: str
"""
ndex = Ndex(username=username, password=password, debug=debug)
res = ndex.save_new_network(cx)
url_parts = urlsplit(res).path
network_id = url_parts.split('/')[-1]
if public:
ndex.make_network_public(network_id)
return network_id
As a side note, it would be nice for this function to return the UUID rather than the response, which contains the url that has the UUID in it.
Now that i've done this, the Ndex.make_network_public function gives an error HTTPError: 500 Server Error: for url: http://public.ndexbio.org/v2/network/53f781b1-0710-11e7-aba2-0ac135e8bacf/systemproperty
The full testing log is available on https://travis-ci.org/cthoyt/pybel2cx/jobs/210230667)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#10 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABDqrPFftvEQ59QfxjAy11WPrtABa5ZFks5rk80sgaJpZM4MGADI>.
|
I'll take that out of the What do you think about returning the UUID instead of the URL? Again, this might be my naiveté with good API design, but I think it would be very useful from the programmatic side. |
I would like to have it in the interface so I can automatically have my network be public after I upload such that the following code would make this happen:
The text was updated successfully, but these errors were encountered: