Skip to main content

Zegami Python SDK

An SDK and general wrapper for the lower level Zegami API for Python. This package provides higher level collection interaction and data retrieval.

Getting started

Grab this repo, open the script, and load an instance of ZegamiClient into a variable.

from zegami_sdk.client import ZegamiClient

zc = ZegamiClient(username=USERNAME, password=PASSWORD)

Credentials

The client operates using a user token. By default, logging in once with a valid username/password will save the acquired token to your home directory as zegami.token. The next time you need to use ZegamiClient, you may call zc = ZegamiClient() with no arguments, and it will look for this stored token.

Example Usage

zc = ZegamiClient()

Workspaces

To see your available workspaces, use:

zc.show_workspaces()

You can then ask for a workspace by name, by ID, or just from a list

all_workspaces = zc.workspaces
first_workspace = all_workspaces[0]

or:

zc.show_workspaces()

# Note the ID of a workspace
my_workspace = zc.get_workspace_by_id(id)

Collections

my_workspace.show_collections()

# Note the name of a collection
coll = my_workspace.get_collection_by_name(name_of_collection)

You can get the metadata in a collection as a Pandas DataFrame using:

rows = coll.rows

This data can then be modified or augmentated and added back to the collection using:

coll.replace_data(modified_rows)

You can get the images of a collection using:

first_10_img_urls = coll.get_image_urls(list(range(10)))
imgs = coll.download_image_batch(first_10_img_urls)

Sources

If a collection contains multiple image sources, these can be seen using:

coll.show_sources()

Many operations require specifying which image source should be used. This can be specified by index or name for most functions.

first_10_source2_img_urls = coll.get_image_urls(list(range(10)), source=2)

# To see the first of these:
coll.download_image(first_10_source2_img_urls[0])

Using with onprem zegami

To use the client with an onprem installation of zegami you have to set the home keyword argument when instantiating ZegamiClient.

zegami_config = {
  'username': <user>,
  'password': <password>,
  'home': <url of onprem zegami>,
  'allow_save_token': True,
}

zc = ZegamiClient(**zegami_config)

If your onprem installation has self-signed certificates you can disable SSL verification using the environment variable ALLOW_INSECURE_SSL before running the python.

export ALLOW_INSECURE_SSL=true
python myscript.py

or

ALLOW_INSECURE_SSL=true python myscript.py

WARNING! You should not need to set this when using the SDK for cloud zegami

In Development

This SDK is in active development. Features are actively being developed according to user feedback. Please share your suggestions or fork this repository and feel free to raise a PR

Developer Conventions

Keeping the SDK easy and fluent to use externally and internally is crucial. If contributing PRs, some things to consider:

Relevant

MOST IMPORTANT - Zegami has concepts used internally in its data engine, like 'imageset', 'dataset'. Strive to never require the user to have to know anything about these, or even see them. If the user needs an image, they should ask for an image from a concept they ARE expected to understand like a 'collection' or a 'workspace'. Anything obscure should be hidden, for example: _get_imageset(), so that auto-suggestions of a class will always contain relevant and useful methods/attribs/properties.

Obvious

Avoid ambiguous parameters. Use the best worded, lowest level parameters types for functions/methods. Give them obvious names. Any ambiguity or unobvious parameters MUST be described in detail in the docstring. Avoid parameters like 'target' or 'action', or describe them explicitly. If an instance is needed, describe how/where that instance should come from.

Exceptions

If you expect an RGB image, check that your input is an array, that its len(shape) == 3, that shape[2] == 3, and throw an exception to clearly feed back to the user what has wrong. The message should help the user to solve the problem for themselves.

Minimal

Do not ask for more information than is already obtainable. A source knows its parent collection, which knows how to get its own IDs and knows the client. A method never needs to reference a source, the owning collection, and the client all together. Moreover, these chains should have sensible assertions and checks built in, and potentially property/method-based shortcuts (with assertions).

Helpful

Use sensible defaults wherever possible for minimal effort when using the SDK. V1 collections typically use source=None, while V2 collections use source=0. This allows a user with an old/new (single source) collection to never even have to know what a source is when fetching images.

Metadata

Release files for zegami-sdk 0.4.9

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

Source distribution (sdist)

Source distribution for zegami-sdk 0.4.9
File Size Uploaded
zegami-sdk-0.4.9.tar.gz 36.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zegami-sdk 0.4.9
File Interpreter ABI Platform
zegami_sdk-0.4.9-py3-none-any.whl Python 3 none any Details

Total release size: 79.0 kB

Release files / zegami-sdk-0.4.9.tar.gz

Download URL zegami-sdk-0.4.9.tar.gz
Size 36.9 kB
Tags Source
SHA-256 checksum
How to use checksums
75f88351e42b647c3cec831f23b24fd2c575ea699ee225ffe31b5379ab51ea49
BLAKE2b-256 checksum
How to use checksums
c5059b697bcacb5dda99fa32a676e37c74cd70d303ba00cd7e4916a54819cad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.10

Release files / zegami_sdk-0.4.9-py3-none-any.whl

Download URL zegami_sdk-0.4.9-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
743e3a2001f6d90fd665c4f1e308e5a570d41c37661e99f9782ca0d974b4a3d6
BLAKE2b-256 checksum
How to use checksums
c30c90ba865d3098775bede72d0116e4b2792c5246ff1918af342e88ac1f687f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.4.9 This release

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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