Code Monkey home page Code Monkey logo

metatarget's Introduction

MetaTarget 1.1

Features

  • 使用异步函数实现并发
  • 使用装饰器来进行重试
  • 更具体的异常捕,利于后期维护

接口监控

SEA Swiss PassOnline Targrt Hunter Target Net
sea testing swiss testing passOnline testing targetHunter testing targetNet testing

PPB2 系列

DNN(ECfp4) NB(ECfp4) NN(MQN) + NB(ECfp4) NN(Xfp) + NB(ECfp4)
ppb2_dnn_ecfp4 testing ppb2_nb_ecfp4 testing ppb2_nnmqn_nbecfp4 testing ppb2_nn_xfp testing
NN(ECfp4) + NB(ECfp4) NN(MQN) NN(Xfp) NN(ECfp4)
ppb2_nnnb_ecfp4 testing ppb2_nn_mqn testing ppb2_nn_xfp testing ppb2_nn_xfp testing

安装

安装依赖

pip install -r requirements.txt

安装metaTarget

python setup.py install

使用

单接口预测

通过调用asyncio运行异步函数

import asyncio
import json

import pandas as pd

from metaTarget import targetNet

if __name__ == "__main__":
    smiles = "FC1=CC=C(CC2=NNC(=O)C3=CC=CC=C23)C=C1C(=O)N1CCN(CC1)C(=O)C1CC1"
    jsonRes = asyncio.run(targetNet(smiles))
    # print(jsonRes)  # 结果为JSON字符串,用json和pandas转换成DataFrame
    res = json.loads(jsonRes)
    out = pd.DataFrame(res).T
    print(out)

多接口并发

使用asynciogather()实现并发

import asyncio
import json

import pandas as pd

from metaTarget import targetNet, passOnline, targetHunter


async def main(smiles):
    return await asyncio.gather(
        targetNet(smiles),
        passOnline(smiles),
        targetHunter(smiles)
    )

if __name__ == "__main__":
    smiles = "FC1=CC=C(CC2=NNC(=O)C3=CC=CC=C23)C=C1C(=O)N1CCN(CC1)C(=O)C1CC1"
    jsonRes = asyncio.run(main(smiles))
    # print(jsonRes)

    res = [json.loads(_) for _ in jsonRes]
    out = [pd.DataFrame(_).T for _ in res]
    # print(out)

注意

请勿在Spyder、Jupyter或其他以IPython为运行环境的IDE中直接运行本程序,否则会抛出以下异常

RuntimeError: asyncio.run() cannot be called from a running event loop.

这是由于它们已经运行在事件循环(event loop)。

Spyder

复制代码在IPython中运行

Jupyter

asyncio.run()替换成await关键字

jsonRes = await targetNet(smiles)

Attention

The exception would be raised while running directly this code in Spyder, Jupyter or other IDE based on Ipython.

RuntimeError: asyncio.run() cannot be called from a running event loop.

Since IPython is already running an event loop, the asyncio.run()should not be instead.

Spyder

Paste the code block to Ipython to excute.

Jupyter

Use await to instead all asyncio.run()

jsonRes = await targetNet(smiles)

metatarget's People

Contributors

kotori-y avatar

Stargazers

Neuron-Cell avatar Pweni avatar  avatar  avatar Juno Xiong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.