Giter Site home page Giter Site logo

arkitektio / arkitekt Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 3.71 MB

arkitekt is the python api client for the arkitekt-framework

Home Page: https://arkitekt.live

License: MIT License

Python 96.26% JavaScript 1.62% CSS 0.72% TypeScript 1.17% MDX 0.08% Dockerfile 0.14%
arkitekt

arkitekt's Introduction

arkitekt

codecov PyPI version Maintenance Maintainer PyPI pyversions PyPI status

streaming analysis for mikroscopy

Idea

arkitekt is the python client for the arkitekt platform. It allows you to utilize the full extent of the platform from your python code. To understand the idea behind arkitekt, you need to understand the idea behind the arkitekt platform. (More on this in the documentation)

Features

  • Host your python functions and make them to your team
  • Use functions from your team in your code
  • Interact with and store data in a secure and scalable way on the platform
  • Use the platform as a central storage for your data

Install

pip install arkitekt[all]

This installs all dependencies for the arkitekt platform, inlcuding the arkitekt CLI, which can be used to develop and create apps, containerize them and deploy t

arkitekt is relying heavily on asyncio patters and therfore supports python 3.8 and above. It also relies on the pydantic stack for serialization.

App

You can use the cli to create python based apps for the arkitekt platform, profiting from a battery of features like easy GUI creation based on type annotations, orchestration of real-time (in memoery) workflows, data hosting, easy packaging and distribution in docker containers, etc...

To get started create a directory and run

arkitekt init

Which will lead you throught an app creation process. Apps can simply registered functions, through the register decorator

from arkitekt import register

@register()
def rpc_function(x: int, name: str) -> str
    """
    A rpc function that we can
    simple call from anywhere

    ""

And then connected to a local or remote server by running

Run example:

arkitekt run dev

For more details on how to create an app follow the tutorials on https://arkitekt.live.

Usage with complex Datastructures

Arkitekt takes care of serialization and documentation of standard python datastructures

  • str
  • bool
  • int
  • float
  • Enum
  • Dict
  • List

To increase performance and reduce latency it is not possible to serialize complex python objects like numpy arrays into the messages. These are best transformed into immutable objects on a centrally accessible storage and then only the reference is passed.

Arkitekt does not impose any rules on how you handle this storage (see mikro for ideas), it provides however a simple api.

class ComplexStructure:
    id: str # A reference for this structure on central storage

    async def shrink(self):
        return self.id

    @classmethod
    async def expand(cls, value):
        return cls.load_from_server(value)

by providing two functions:

  • shrink
  • expand

You can now use this Structure with simple typehints and arkitekt will automaticall shrink (serialize) and expand (deserialize) the structure on calling.

def complex_call(x: ComplexStrucuture) -> int:
    return x.max()

Check out the arkitekt documentation for usage of this libary

arkitekt's People

Contributors

jhnnsrs avatar

Stargazers

Nikolaus Schlemm avatar

Watchers

 avatar

Forkers

alexschroeter

arkitekt's Issues

Support for Flavors

To have an easy test case for the support of flavors I have created the test repository (https://github.com/alexschroeter/tensorflow-test).

These are the issues I have encountered:

I cannot pass parameters to the docker run command

Since the different vendors want different parameters passed to docker, we need the ability to add these parameters to the docker run command.

CUDA: docker run --gpus all <image>
ROCM: docker run --device=/dev/kfd --device=/dev/dri --group-add video <image>
DPC++: docker run --device=/dev/dri -v /dev/dri/by-path:/dev/dri/by-path <image>

I believe the config.yaml will be the right location for these docker_params as I have called them in the example repository. I went looking through the code a bit and I was wondering if the selectors (https://github.com/arkitektio/arkitekt/blob/e8762476e08ec850d3e27d2a41b0c8c63863bbb3/arkitekt/cli/types.py#L343C30-L343C39) are meant to be for that or if this part is not there yet.

I am also wondering if you already passed --gpus all for Nvidia somewhere or if this is not strictly necessary anymore and this is the reason I could not find it.

Select GPUs

Related to the topic above I am wondering how to handle the selection of specific GPUs, and if you already had some thoughts regarding this. I believe for Nvidia and AMD you can pass [CUDA|HIP]_VISIBLE_DEVICES=[list of numbers] or something similar but I don't know yet where you would add this (Instantiation of the App) and how.

Because I cannot pass parameters, "arkitekt port build" fails since it cannot find the GPUs.

I believe this problem will be solved by adding the parameters to config.yaml but I am wondering if build should fail if the container cannot be started or if the build should work as long as the container can be built. As a side note, this issue only happened with the Intel container the other ones didn't fail if they couldn't find the GPU where the Intel one did.

arkitekt port publish takes the last flavor build

I don't know if there are other reasons but for consistency, I believe publish should publish all of them, and -f flavor can be used to publish a certain flavor only. Right now, I have to work around it by building the one that I want to publish again and publish after, which takes the last one it seems.

Deploy in Port

I am unable to deploy in Port but I am wondering if this is because some containers (the Intel one) are missing or because I am using a version that doesn't support this yet.

Cheers,
Alex

What is Arkitekt's license?

There is no LICENSE file, although the pyproject.toml says CC BY-NC 3.0. However, CC BY-NC 3.0 is not an OSI-approved open source license, due to the non-commercial clause. It would be helpful to add LICENSE files to each of arkitekt's source repositories, and choose a license compatible with open source. Thanks!

ModuleNotFoundError in fresh installation with python 3.12

Tried a fresh install but I get this error with python 3.12.

(arkitekt) aschroeter@Moriarty:~$ arkitekt
Traceback (most recent call last):
  File "/home/aschroeter/mambaforge/envs/arkitekt/bin/arkitekt", line 5, in <module>
    from arkitekt.cli.main import cli
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/__init__.py", line 1, in <module>
    from arkitekt.apps import Arkitekt
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/__init__.py", line 1, in <module>
    from .default import Arkitekt
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/default.py", line 1, in <module>
    from arkitekt.apps.connected import ConnectedApp
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/connected.py", line 1, in <module>
    from arkitekt.apps.mikro import MikroApp
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/mikro.py", line 41, in <module>
    from arkitekt.apps.herre import HerreApp
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/herre.py", line 1, in <module>
    from arkitekt.apps.fakts import FaktsApp
  File "/home/aschroeter/mambaforge/envs/arkitekt/lib/python3.12/site-packages/arkitekt/apps/fakts.py", line 4, in <module>
    from fakts.grants.remote.device_code import DeviceCodeGrant
ModuleNotFoundError: No module named 'fakts.grants.remote.device_code'

allow arkitekt to run without gpu support

Even without needing gpu capability I was unable to run arkitekt port stage without the nvidia-container-toolkit. I believe this should probably be possible since some people might not even have nvidia GPUs installed.

Error when running without nvidia-container-toolkit

(arkitekt) aschroeter:~/src/arkitekt-matlab-example$ arkitekt port stage                                                                                                                             
Running inside docker: arkitekt-matlab-example:0.0.1
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
ERRO[0000] error waiting for container:                 
╭─ Error ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Docker container exited                                                                                                                                                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                                                                                                                                                                                                                   
 To find out more, visit https://arkitekt.live                                                                                                                                                                     

arkitekt port build is failing for cuda

It seems there is something missing for the inspect part of my Dockerfile (see below) although the build is working

Dockerfile

FROM nvidia/cuda:12.3.1-runtime-ubuntu22.04

RUN apt update && apt install -y python3 python3-pip nvidia-opencl-dev clinfo nvidia-opencl-icd-384

RUN pip install "arkitekt[all]"

RUN pip install pyclesperanto-prototype

RUN mkdir /app
WORKDIR /app
COPY .arkitekt /app/.arkitekt
COPY app.py /app/app.py

Error:

Traceback (most recent call last):
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/arkitekt/cli/commands/port/build.py", line 106, in inspect_definitions
    output = json.loads(result.stdout)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/bin/arkitekt", line 8, in <module>
    sys.exit(cli())
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/arkitekt/cli/commands/port/build.py", line 221, in build
    inspection = inspect_build(build_tag)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/arkitekt/cli/commands/port/build.py", line 133, in inspect_build
    definitions = inspect_definitions(build_id)
  File "/home/aschroeter/miniconda3/envs/pyclesperanto-arkitekt/lib/python3.9/site-packages/arkitekt/cli/commands/port/build.py", line 109, in inspect_definitions
    raise InspectionError(
arkitekt.cli.commands.port.build.InspectionError: Could not decode JSON output of docker inspect. 
==========
== CUDA ==
==========

CUDA Version 12.3.1

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

WARNING: The NVIDIA Driver was not detected.  GPU functionality will not be available.
   Use the NVIDIA Container Toolkit to start this container with GPU support; see
   https://docs.nvidia.com/datacenter/cloud-native/ .

{"definitions": [{"description": "Computes the absolute value of every individual pixel x in a given image.\n\nf(x) = |x|", "collections": [], "name": "absolute", "portGroups": [], "args": [{"identifier": "@mikro/representation", "key": "source", "scope": "GLOBAL", "label": "source", "kind": "STRUCTURE", "description": "The input image to be processed.", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "returns": [{"identifier": "@mikro/representation", "key": "return0", "scope": "GLOBAL", "kind": "STRUCTURE", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "interfaces": [], "kind": "FUNCTION"}, {"description": "No Description", "collections": [], "name": "test", "portGroups": [], "args": [{"identifier": "@mikro/representation", "key": "source", "scope": "GLOBAL", "kind": "STRUCTURE", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "returns": [{"identifier": "@mikro/representation", "key": "return0", "scope": "GLOBAL", "kind": "STRUCTURE", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "interfaces": [], "kind": "FUNCTION"}, {"description": "No Description", "collections": [], "name": "create voronoi labels", "portGroups": [], "args": [{"identifier": "@mikro/representation", "key": "representation", "scope": "GLOBAL", "label": "representation", "kind": "STRUCTURE", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "returns": [{"identifier": "@mikro/representation", "key": "return0", "scope": "GLOBAL", "kind": "STRUCTURE", "description": "A string with Hello {n}", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "interfaces": [], "kind": "FUNCTION"}, {"description": "No Description", "collections": [], "name": "create voronoi labels", "portGroups": [], "args": [{"identifier": "@mikro/representation", "key": "representation", "scope": "GLOBAL", "label": "representation", "kind": "STRUCTURE", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}, {"key": "radius_x", "scope": "GLOBAL", "kind": "INT", "default": 5, "nullable": true, "annotations": []}, {"key": "radius_y", "scope": "GLOBAL", "kind": "INT", "default": 5, "nullable": true, "annotations": []}, {"key": "spot_sigma", "scope": "GLOBAL", "kind": "INT", "default": 1, "nullable": true, "annotations": []}, {"key": "radius", "scope": "GLOBAL", "kind": "INT", "default": 10, "nullable": true, "annotations": []}], "returns": [{"identifier": "@mikro/representation", "key": "return0", "scope": "GLOBAL", "kind": "STRUCTURE", "description": "A string with Hello {n}", "assignWidget": {"kind": "SearchWidget", "query": "query search_representation($search: String, $values: [ID]) {\n  options: representations(name: $search, limit: 20, ids: $values) {\n    value: id\n    label: name\n  }\n}", "ward": "mikro"}, "nullable": false}], "interfaces": [], "kind": "FUNCTION"}]}

add python 3.12 support

This is related to Issue: #10

I don't know if there is any technical reason or if at the time 3.11 was just the latest available version.

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.