Skip to main content

Official python wrapper for the FURTHRmind rest api.

Project description

FURTHRmind python package

This package provides a simple and user-friendly way to interact with your FURTHRmind application. It enables users to effortlessly retrieve existing data or write new data into the application.

Install

You can conveniently install furthrmind from PyPi using the following command:

pip install furthrmind

Basic usage

Retrieve objects

To initiate an interaction with your server through the Furthrmind class, you need to create an instance of it. You will pass in your server's URL and API key. Don’t forget to provide the name or ID of the project you want to work with.

from furthrmind import Furthrmind
fm = FURTHRmind(host, api_key, project_name="my project")

Retrieving data necessitates the importation of the relevant collection class. This can be attained either from your Furthrmind instance or by direct import.

Experiment = fm.Experiment
from furthrmind.collection import Experiment

To fetch a specific experiment, invoke the get method of the Experiment class, passing in the desired experiment's ID.

exp = fm.Experiment.get(exp_id)

or

exp = Experiment.get(exp_id)

Both these commands are identical provided the Experiment class was previously imported.

You can fetch all the experiments from a project by calling the get_all method which returns a list of instances of the Experiment class.

exp_list = Experiment.get_all()

The Experiment class instance encapsulates all data pertinent to your experiment. For convenience, this class provides several methods including: add_field, add_many_fields, remove_field, update_field_value, update_field_unit, add_file, remove_file, and add_datatable. Details about the available methods for each collection class can be found below.

Nested objects

In the preceding example, we retrieved one or more experiments from the Furthrmind server. Each experiment encompasses various attributes such as the corresponding samples, research items, and the group to which it belongs. Note that these entities are nested objects.

For instance, the 'groups' attribute comprises a list of group instances belonging to the group collection class. To optimize network traffic, these nested objects do not load completely. In other words, all properties, except for the ' id' and 'name', remain unretrieved.

To verify whether an object has been fully loaded, you can inspect the _fetched attribute of the object. If an object hasn't been fetched yet, you can invoke the get() method on that object to retrieve it.

Fields and FieldData: How to locate specific field value within an item

The targeted experiment contains an attribute known as 'fielddata', which is a list comprising FieldData objects. Unlike Field objects that represent field definitions within a project, FieldData merges these definitions with a specific value and unit applicable to a particular item, such as an experiment.

If you wish to locate a field value related to a specific item, you can iterate through the 'fielddata' list and compare the field names. For example, to search for the value of a field named "width", you could do the following:

for fielddata in exp.fielddata:
    if fielddata.field_name == "width":
        value = fielddata.value

Create new objects

To generate a new experiment, you should invoke the create() or create_many() method. It's important to correctly supply the input arguments suitable for each collection class. Specifically, the create method of the Experiment class necessitates passing the new experiment's name, and the name or ID of the group to which it should belong.

In case your requirement entails adding an experiment to a subgroup, supplying this subgroup's ID becomes paramount. The create method subsequently gives back an instance of the Experiment class, whereas the create_many method yields a list of Experiment class instances.

new_exp = Experiment.create("myexperiment2", group_name="My group"

Alternatively, to create multiple experiments:

experiments = Experiment.create_many([{"name": "exp1", "group": "group1"}, {"name": "exp2", "group": "group2"}])

Adding fields, files, and datatables

After you created the new experiment you might want to add some fields, files, and datatables to your experiment. This can be achieved with:

new_exp.add_field(field_name="My field namy", field_type="Numeric",
                  value=5, unit="cm")
new_exp.add_many_fields([
        {
            "name": "May field name,
            "field_type" ="Numeric",
            "value: 5, 
            "unit": "cm"
        },
        {
            "name": "May second field name,
            "field_type" ="Numeric",
            "value: 10, 
            "unit": "m"
        }
])
new_exp.add_file(my_file_path)
new_exp.add_datatable(name=my data table, columns=[
        {
            "name": "my 1st column"
            "type": "Numeric,
            "unit": "cm",
            "data": [1,2,3]
        },
        {
            "name": "my 2nd column"
            "type": "Numeric,
            "unit": "cm",
            "data": [4,5,6]
        },
])

Detailed information about each collection and its attributes and methods can be found here:

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

furthrmind-0.2.1.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

furthrmind-0.2.1-py3-none-any.whl (61.4 kB view details)

Uploaded Python 3

File details

Details for the file furthrmind-0.2.1.tar.gz.

File metadata

  • Download URL: furthrmind-0.2.1.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Windows/10

File hashes

Hashes for furthrmind-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1dfec221c855f8fbb30815bdd413c91ddafde05fd60a3c1dcb328cb066b0c0f8
MD5 ce8bd99bcef2a0414cc1955f06ad54fe
BLAKE2b-256 5e8e7d638e2020d68d4f9d0afe2f1c4007bf9234edb43ebe5248349818361398

See more details on using hashes here.

File details

Details for the file furthrmind-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: furthrmind-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 61.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Windows/10

File hashes

Hashes for furthrmind-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c7464e50bcce0641d6b5eb249972842b0983dfc2e8060e67e2f5e9b29348427
MD5 cc414fcb58d9fed13148db7930204c1b
BLAKE2b-256 f3cc9c10c6f57480a20897908b5ef694ef323287a7e929aafaec0da6b6919572

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page