Skip to main content

mikro

codecov PyPI version Maintenance Maintainer PyPI pyversions PyPI status PyPI download month

mikro is the python client for the next version of the mikro-server environment.

Quick Start

Let's discover mikro in less than 5 minutes.

Inspiration

Mikro is the client app for the mikro-server, a graphql compliant server for hosting your microscopy data. Mikro tries to facilitate a transition to use modern technologies for the storage and retrieval of microscopy data. It emphasizes the importance of relations within your data and tries to make them accessible through a GraphQL Interface.

Installation

pip install mikro

Design

Mikro is just a client and therefore only concerns itself with the querying (retrieval) and mutation (altering) of data on the central server. Therefore its only composes two major components:

  • Rath: A graphql client to query complex relationships in your data through simple queries.
  • Datalayer: A way of accessing and retrieving binary data (image arrays, big tables,...) through known python apis like xarray and numpy

Under the hood Mikro is build on the growing ecosystem of graphql and pydantic as well as the amazing toolstack of zarr, dask and xarray for scientific computation.

Features

  • Easy to extend with custom graphql logic (together with turms can generate APIs for very complex relationship)
  • Interoperable and standardization (has bindings for Dataframes and Numpy arrays)
  • Fully Typed and Validated(uses pydantic for validation)

Prerequisits

You need a fully configured mikro-server running in your lab, that mikro can connect to. The easiest way to do this is to use the arkitekt.live platform, which provides a fully managed mikro-server for your lab. Just follow the instructions on the website to get started. If you just want a local test service, check out the tests/integration/docker-compose.yml file, which contains a docker-compose file to start a mikro-server locally with a postgres database and a minio object storage.

Example Use case

The API of Mikro is best explained on this example:

from arkitekt import easy
from mikro.api.schema import get_random_image


with easy("my-app") as app:
    g = get_random_image()

    maximum_intensity_l = g.data.max()
    maximum_intensity = maximum_intensity.compute()
  1. First we construct an App: App is the entrypoint of every client accessing the mikro service, in a more complex example here you would define the configuration of the connection. In this example we use the easy function to construct an arkitekt-app with a default configuration.

  2. Entering the Context: This is the most important concept to learn, every interaction you have with mikro needs to happen within a context. This is needed because mikro uses asyncrhonous programming to retrieve, and save data efficiently. The context ensures that every connection gets cleaned up effienctly and safely.

  3. Retrieving Model: On calling get_random_image we are calling the graphql server and retrieve the metadata of a reandom image. This function just executes a default graphqlquery and constructs a typed python model out of it.

  4. Retrieving Data: Here we are actually doing operations on the image data. Every Image has a data attribute. This data attribute resolves to a lazily loaded xarray that connects to a zarr store on the s3 datalayer. What that means for you is that you can use this as a normal xarray with dask array.

  5. Computing Data Only on Computing Data is the data actually downloaded from the datalayer. If you only act on partial data, only partial data is downloaded. This is the magic of zarr and xarray.

Other usage options

If you dont want to use a context manager you can also choose to use the connect/disconnect methods:

from arkitekt import easy 
from mikro.api.schema import get_image


app = easy()
app.enter()

g = get_image(107)

maximum_intensity = g.data.max().compute()

#later
app.exit()

:::warning If you choose this approach, make sure that you call disconnect in your code at some stage. Especially when using asynchronous links/transports (supporting subscriptions) in a sync environment,as only on disconnect we will close the threaded loop that these transports required to operate. Otherwise this connection will stay open. :::

Async Usage:

If you love asyncio, the way we do, you can also take full control over what happens in your app within an asynchrouns loop. Actually this is the API we would recommend.

from mikro import MikroApp, aget_representation
from fakts import Fakts


app = MikroApp()

async with app:
    g = await aget_representation(107)

    maximum_intensity = g.data.max() # DO NOT DO THIS IN YOUR ASYNC LOOP

:::warning

In this scenario we are using the asyncio event loop and do not spawn a seperate thread, so calling g.data.max() actually calculates the array (e.g downloads everything blockingly in this loop)

:::

If you want to know more about why we use apps, composition and how we handle threads, check out koil (mikros async-sync-helper library)

Release files for mikro 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mikro 3.0.1
File Size Uploaded
mikro-3.0.1.tar.gz 376.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mikro 3.0.1
File Interpreter ABI Platform
mikro-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 773.8 kB

Release files / mikro-3.0.1.tar.gz

Download URL mikro-3.0.1.tar.gz
Size 376.5 kB
Tags Source
SHA-256 checksum
How to use checksums
36f3bd073dc0b3a3d9869385c6e5ac22c480a99ca7c880677d809e4358125f9c
BLAKE2b-256 checksum
How to use checksums
1f8a348413838ac264b971ea8c26ee705a9421813117ce753ff24a8208bbb4aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mikro-3.0.1-py3-none-any.whl

Download URL mikro-3.0.1-py3-none-any.whl
Size 397.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
207a31699fa3d0eae2eddf3f6747662ccf3034d0156f91a4c3adfcaba8d1ef7a
BLAKE2b-256 checksum
How to use checksums
c7540f128b7103ade704ecca23aac916740abbbfad38589e3e92ee9f5916b284
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

4.0.0

2 release files

This release

3.0.1 This release

2 release files

3.0.0

2 release files

0.3.95

2 release files

0.3.93

2 release files

0.3.92

2 release files

0.3.91

2 release files

0.3.90

2 release files

0.3.89

2 release files

0.3.88

2 release files

0.3.87

2 release files

0.3.85

2 release files

0.3.84

2 release files

0.3.82

2 release files

0.3.80

2 release files

0.3.76

2 release files

0.3.75

2 release files

0.3.74

2 release files

0.3.73

2 release files

0.3.72

2 release files

0.3.71

2 release files

0.3.70

2 release files

0.3.69

2 release files

0.3.68

2 release files

0.3.67

2 release files

0.3.66

2 release files

0.3.60

2 release files

0.3.59

2 release files

0.3.58

2 release files

0.3.57

2 release files

0.3.56

2 release files

0.3.55

2 release files

0.3.54

2 release files

0.3.53

2 release files

0.3.52

2 release files

0.3.51

2 release files

0.3.50

2 release files

0.3.49

2 release files

0.3.48

2 release files

0.3.47

2 release files

0.3.46

2 release files

0.3.45

2 release files

0.3.44

2 release files

0.3.43

2 release files

0.3.42

2 release files

0.3.41

2 release files

0.3.34

2 release files

0.3.33

2 release files

0.3.32

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.17

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.27

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.24

2 release files

0.2.22

2 release files

0.2.21

2 release files

0.2.20

2 release files

0.2.19

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.1.74

2 release files

0.1.73

2 release files

0.1.72

2 release files

0.1.71

2 release files

0.1.70

2 release files

0.1.69

2 release files

0.1.68

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.51

2 release files

0.1.50

2 release files

0.1.49

2 release files

0.1.48

2 release files

0.1.47

2 release files

0.1.46

2 release files

0.1.45

2 release files

0.1.44

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page