Coscine Python SDK Examples

Here are a few examples along with a short explanation.

Inviting a list of project members

Sometimes you need to invite a lot of people to a project. If you already have a list of their E-Mail addresses, you can easily iterate over the list and invite every single one of them.

Uploading a file to a resource

Modifying/Setting metadata of files inside an (S3-)resource

Files stored in an s3-resource do not require you to specify metadata on upload. However it is considered good practice to tag each file with metadata anyway. Here is an easy way of doing just that. The example assumes you've got a few files present inside an s3-resource, all of which have little to no metadata yet.

Establishing an S3-connection

Using the S3 library of your choice it's quite easy to connect to an S3 resource. The following short snippet shows how to use amazons boto3 SDK to connect to a Coscine S3 resource.

Silly oneliners or how to quickly get the PID

If you are working from an interactive shell, you might at some point use one of those silly oneliners to quickly query some information.

You get the idea...

GUI integration

The Coscine Python SDK has been implicitly written with GUIs in mind. Building a GUI around it is very easy, assuming you have some understanding of your GUI library of choice. The Qt Framework is well established in commercial, industrial and scientific use. We'll be using its python binding PyQt5. If you are just starting out, we recommend ditching TKinter and similar libraries in favor of Qt or WxWidgets.

GUI Metadata Editor

You can easily edit a metadata form with a GUI.

Going beyond

That wraps it up for the examples. The author this has also created a simple GUI file explorer (similar to WinSCP, Cyberduck, etc.) based on the Coscine Python SDK and PyQt5. Have a look at that project if you plan on doing something similar. It should be easy to build upon the existing codebase, extend it or steal some code from it. :^)