Code Monkey home page Code Monkey logo

backend.ai-client-py's People

Contributors

achimnol avatar adrysn avatar fregataa avatar gofeel avatar hephaex avatar inureyes avatar jil8885 avatar kmkwon94 avatar ksy9164 avatar kyujin-cho avatar leksikov avatar lizable avatar miraliahmadli avatar nokchalatte avatar rlatjcj avatar sonminwoo avatar tink-expo avatar vesselofgod avatar yongkyunlee avatar zeniuus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backend.ai-client-py's Issues

쿼리 요청이 불가능합니다.

from ai.backend.client import Kernel로 되있으나 실제로는
from ai.backend.client.kernel import Kernel해야 작동이 됩니다.
또한 위와 같이 변경하여 아래와 같이 요청을 시도하여도

from ai.backend.client.kernel import Kernel

kern = Kernel.get_or_create('python', client_token='abcdef')
result = kern.execute('print("hello world")', mode='query')
print(result['console'])
kern.destroy()

AssertionError: You must use API wrapper functions via a Session object. 에러가 발생합니다.
get_or_create가 클래스 메소드이다보니 세션을 어느시점에 어떻게 넣어줘야 하는지 궁금합니다.

마지막으로 사소한 부분이긴 하나 실세 샘플 코드에서는 클라이언트 토큰이 'abc'로 적혀있는데
실제로 그대로 돌려볼경우
assert 4 <= len(client_token) <= 64, 'Client session token should be 4 to 64 characters long.'
에러가 막히지 않을까 싶습니다. 그래서 4자 이상으로 변경하시면 처음 시도하시는 분이 에러없이 테스트 해보실수 있지 않을까 싶습니다.

Show username in config for session mode

It would be better to have a way to check username for logged in user.

  • Store config.json file in appdir in login with username information.
  • Delete config.json when logout.

Automatic legacy support

Automatically use --legacy option when server API is v3.

  • Automatically use --legacy option when server API is v3.

Handle redirects in API requests

This is for forward compatibility.
Currently requests module automatically handles redirects but the authentication header is not updated and causes authorization failures.

Add X-Method-Override support

New Sorna gateway will support custom HTTP methods using X-Method-Override header.
Let's add a configuration option to enable to use this instead of directly sending custom HTTP methods.

Basic API specification

  • Basic API specification
  • Requirements
    • Authentication method
    • Policy for anonymous users
    • Specification
    • REST API
    • XML-RPC API?
    • GET / POST simple API (for traditional users?)
    • WebSocket API for web terminals

Python Client Library

Let's write a basic Python client library that conforms with the API specification.

Drop Python 3.5 support

It's September 2019.

  • Even Python 3.6 has reached the "security fix only" phase. (PEP-494)
  • Ubuntu 18.04 LTS: Python 3.6
  • Debian "Buster" 10 stable: Python 3.6
  • CentOS: Anyway the users need to install Python 3 separately

Local insecure API proxy

Let's add a command python -m ai.backend.client.cli proxy which opens an insecure HTTP server where all requests are proxied to the original API server with configured authorization headers.
This will allow use of many convenient API development tools such as GraphiQL.

Windows-specific issues

  • aiohttp is not installed automatically when pip install backend.ai-client.
  • CLI command's colored outputs are not compatible with command prompt.
    image
  • PowerShell doesn't allow me to execute virtualenv script.
    image
    • PowerShell security exception can be solved if the user runs Set-ExecutionPolicy RemoteSigned and choose "Y" in a PowerShell run as administrator. The user manual will include this case.

Cannot download file(s) from compute session

backend.ai download <sess-id> <filepath> command is broken with following traceback:

Traceback (most recent call last):c51362187f653ee5745d6906b...
  File "/Users/adrysn/.pyenv/versions/playground/bin/backend.ai", line 11, in <module>
    sys.exit(main())
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/cli/__init__.py", line 104, in main
    args.function(args)
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/cli/__init__.py", line 40, in wrapped
    handler(args)
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/cli/files.py", line 44, in download
    kernel.download(args.files, show_progress=True)
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/base.py", line 79, in _caller
    return self._handle_response(resp, gen)
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/base.py", line 37, in _handle_response
    meth_gen.send(resp)
  File "/Users/adrysn/.pyenv/versions/3.7.0/envs/playground/lib/python3.7/site-packages/ai/backend/client/kernel.py", line 191, in _download
    total=resp.stream_reader.total_bytes,
AttributeError: 'Response' object has no attribute 'stream_reader'

Meanwhile, downloading from vfolders is working.

Make optional parameters keyword-only

The current Python API has many optional parameters (with default values) but they can be passed as either positional or keyword arguments.

Let's restrict them to be passed as only keyword arguments, so that adding new arguments does not break existing Python API-based codes elsewhere.

python client 문서 갱신 요청드립니다.

Description

http://docs.backend.ai/en/latest/gsg/clientlib.html 현재 sorn-client는 pip에서 0.9.3버전이라
pip install backend.ai-client로 변경 및 해당문서의 샘플 코드도 갱신이 필요해 보입니다.

샘플코드의 경우 아래와 같이 변경하여 연동을 시도해봤습니다.

from ai.backend.client.request import Request
req = Request('GET', '/authorize', {'echo': 'test'})
rep = request.send()
print(rep.status)
print(rep.json())

하지만 새로이 변경된 클라이언트는 메소드 대신 세션을 요구하는데 세션 생성에 관련한 가이드라인 문서가 없어
연동에 어려움이 있습니다.

Expected / actual behavior

How to reproduce?

Your environment

  • OS Version:
  • Python:
  • Docker:
  • Accelerator:
  • Backend.AI:
    • Using cloud.backend.ai
    • Using a privately installed cluster
    • Using a demo container/VMs

Tunneling proxy to access service ports (e.g., TensorBoard)

Configuring a network is often painful for end-users.
Let's provide a better way in the CLI of sorna client, and let the users just open "localhost:8081" to magically connect to a web page served by the kernel session.
We could use the SSH socks proxy or just some custom-built ones via WebSockets.

Provide shortcut / alias

  • Provide shortcut or aliases for intuitive understanding about the sorna system

Suggestion

  • lcc : C/C++ on lablup.ai cloud.
  • lpython : python on lablup.ai cloud.

Commands for agent watcher

Let's add commands for managing agent through agent watcher.

  • Get agent/watcher status.
  • Start agent.
  • Stop agent.
  • Restart agent.

Make client accept humanized memory resource unit

Currently, the memory unit is GB: 0.5 == 512 MiB, 1 == 1024MiB. Let use can deliver humanized unit. For example, -r ram=512mb, -r ram=2.5GB.

Comments by Achimnol

I think stripping "b" would be better though we could optionally support it. (e.g., -r ram=512m)
Also, how about using -r mem=... instead of -r ram=...? (or maybe we could treat ram, mem, memory as the same key)

Make a debian package

Let's apt-get install backend.ai-client.

Top priority: 18.04
Second priorities: 18.10, 19.04
Dropped: 16.04 due to Python 3.5.1

AttributeError: 'ComputeSession' object has no attribute 'id'

After removing no longer needed argument when using client.request.Request instances, AttributeError: 'ComputeSession' object has no attribute 'id' was occured in src/ai/backend/client/versioning.py:33 with the command, backend.ai app ID jupyterlab.

def get_id_or_name(api_version: Tuple[int, str], obj: ComputeSession) -> str:
    if api_version[0] <= 4:
        return obj.name
    return obj.id

As shown in the picture below, the variable api_version[0] was printed 6, but ComputeSession had no attribute 'id'. When the version check was removed, it worked normally again. Should the version check be removed from the source code?
image

Config displays the latest API version always

backend.ai config command displays current settings including API endpoint and API version. However, the API version displays always the latest version (v5.20191215 for current master). For example, https://api.backend.ai endpoint currently serves v4.20181215 as shown below:

image

When running backend.ai config, you'll see API version of v5.20191215.

image

I think we need to display the correct API version of the endpoint by fetching the information from the endpoint. Or, at least we need to provide users to be able to set API version by environment variables, such as BACKEND_API_VERSION.

버츄얼 폴더에 get 메소드 버그

session = Session()
vf = session.VFolder
name = "first_vf"
vf.create(name)
vf.get(name)

을 할경우 아래와 같이 에러가 발생합니다.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-586f79b79e3d> in <module>
----> 1 vf.get('first_vf')

~/code/brgg/CodeLion/.venv/lib/python3.6/site-packages/ai/backend/client/base.py in _caller(cls, *args, **kwargs)
     63                    'You must use API wrapper functions via a Session object.'
     64             gen = meth(*args, **kwargs)
---> 65             resp = cls._make_request(gen)
     66             return cls._handle_response(resp, gen)
     67 

~/code/brgg/CodeLion/.venv/lib/python3.6/site-packages/ai/backend/client/base.py in _make_request(gen)
     49     @staticmethod
     50     def _make_request(gen):
---> 51         rqst = next(gen)
     52         resp = rqst.fetch()
     53         return resp

TypeError: 'VFolder' object is not an iterator

get메소드는 다른 메소드와 달리 별도의 처리가 되지 않아 발생한 상황인듯 하여 확인 부탁드립니다.

Command line interface

  • Make it available via python -m sorna or python -m sorna.client
  • Provide batch-mode access via CLI.
    • --build, --exec, --lang, --mount, --limit, --gpu params. If some params are omitted, infer them with some heuristics: e.g., choose the only script file in the arguments as --exec target; if the argument contains a Makefile then use it as --build target.)
    • --sess-id to manually specify client-side session ID (i.e., unique identifier of the session). If omitted, auto-create a new session and show an arbitrary ID so that the user can refer it in subsequent executions.
    • Add -d / --detach option Add --rm option (like Docker).
  • Provide list/control of active kernel sessions for the configured keypair.
    • Let's provide this as "ps" command (an alias of "admin sessions")
  • Show resource statistics of the configured keypair.

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.