CyREST : Problem in my function to copy a network

觀看次數:33 次
跳至第一則未讀訊息

Pascal KREZEL

未讀,
2016年11月29日 上午5:34:3129/11/2016
收件者︰ cytoscape-helpdesk
Hi,

I made the following function to copy a network:

def copy_network(net,collection="Recon2",name="copie"):
    SUID=net.get_id()
    netId=cy.network.create(suid=SUID)
    net2=cy.network.create(suid=None,data=netId.to_json(),collection=collection,name=name)
    return(net2)

Normally it works but now it fails with the following error :

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-95-eafd171c9acb> in <module>()
      1 # Copy of recon2
----> 2 recon2_h1=copy_network(recon2)

<ipython-input-76-2f9702310ba8> in copy_network(net, collection, name)
      2     SUID=net.get_id()
      3     netId=cy.network.create(suid=SUID)
----> 4     net2=cy.network.create(suid=None,data=netId.to_json(),collection=collection,name=name)
      5     return(net2)

/home/pkrezel/Programmes/anaconda3/lib/python3.5/site-packages/py2cytoscape/data/network_client.py in create(self, suid, name, collection, data)
    105             res = self.session.post(self.__url + '?collection=' + network_collection,
    106                                     data=json.dumps(network_data), headers=HEADERS)
--> 107             check_response(res)
    108             result = res.json()
    109             network_id = result['networkSUID']

/home/pkrezel/Programmes/anaconda3/lib/python3.5/site-packages/py2cytoscape/data/cynetwork.py in check_response(res)
    371                                        % list(err_info.keys()))
    372         exc.args += (err_msg,)
--> 373         raise exc

/home/pkrezel/Programmes/anaconda3/lib/python3.5/site-packages/py2cytoscape/data/cynetwork.py in check_response(res)
    359     """ Check HTTP response and raise exception if response is not OK. """
    360     try:
--> 361         res.raise_for_status() # ALternative is res.ok
    362     except Exception as exc:
    363         # Bad response code, e.g. if adding an edge with nodes that doesn't exist

/home/pkrezel/Programmes/anaconda3/lib/python3.5/site-packages/requests/models.py in raise_for_status(self)
    860 
    861         if http_error_msg:
--> 862             raise HTTPError(http_error_msg, response=self)
    863 
    864     def close(self):

HTTPError: ('412 Client Error: Precondition Failed for url: http://127.0.0.1:1234/v1/networks?collection=Recon2', 'Could not parse the given network JSON.')



What can I do ?

Pascal

Kei

未讀,
2016年12月1日 下午12:09:361/12/2016
收件者︰ cytoscape-helpdesk
Hi.

Do you have a small network example to reproduce this copy problem?

Thanks,
Kei



2016年11月29日火曜日 2時34分31秒 UTC-8 Pascal KREZEL:

Pascal KREZEL

未讀,
2016年12月5日 上午3:11:105/12/2016
收件者︰ cytoscape-helpdesk
Hi, Kei,

Thank you for your answer.

I tried to replicate the problem this morning but with my new notebook it doesn't happen any more.

There is an instability.

Pascal
回覆所有人
回覆作者
轉寄
0 則新訊息