Skip to content
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

Open
cthoyt opened this issue Feb 20, 2017 · 4 comments
Open

Comments

@cthoyt
Copy link
Contributor

cthoyt commented Feb 20, 2017

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:

from ndex import client
ndex = client.Ndex(debug=True)

...

cx = [ ... ]
ndex.save_new_network(cx, public=True)
@cthoyt cthoyt changed the title Add option to ndex.save_new_network to make network public on upload Add option to Ndex.save_new_network to make network public on upload Feb 20, 2017
@cthoyt
Copy link
Contributor Author

cthoyt commented Mar 12, 2017

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)

@dexterpratt
Copy link
Contributor

dexterpratt commented Mar 13, 2017 via email

@dexterpratt
Copy link
Contributor

dexterpratt commented Mar 13, 2017 via email

@cthoyt
Copy link
Contributor Author

cthoyt commented Mar 13, 2017

I'll take that out of the pybel2cx client for now, or at least add it as a separate command line utility.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants