Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ All notable changes to this project will be documented in this file
- replace naming of classes and methods using 'Workbench' to 'Bench'
- replace create_sample, create_container long argument lists with new XXXPost objects

## 2.7.0 2026-07-03

- Added support for Inventory Instruments and Instrument Templates (beta RSpace 2.24
feature): `create_instrument`, `get_instrument_by_id`, `list_instruments`,
`delete_instrument`, `restore_instrument`, `transfer_instrument_owner`,
`update_instrument_to_latest_template_version`, `get_instrument_revisions`,
`get_instrument_revision`, `create_instrument_template`,
`get_instrument_template_by_id`, `delete_instrument_template`,
`list_instrument_templates`, `restore_instrument_template`,
`transfer_instrument_template_owner`, `set_instrument_template_icon`,
`get_instrument_template_icon`, `get_instrument_template_version`,
`update_instrument_template_instruments`, and a new `InstrumentTemplateBuilder`.
`rename`, `set_image`, `duplicate` and `add_extra_fields` now also work on
Instruments and Instrument Templates.

## 2.6.0 2025-02-25

- implementing pyfilesystem API methods for browsing RSpace Gallery and RSpace Inventory
Expand Down
53 changes: 53 additions & 0 deletions examples/create_instrument.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Creates an Instrument Template, and an Instrument based on it.
"""
import rspace_client
from rspace_client.inv import template_builder, sample_builder2

inv_api = rspace_client.utils.createInventoryClient()

print("Creating an Instrument Template")

it_json = (
template_builder.InstrumentTemplateBuilder(
"Microscope template", "A template for the lab's microscopes"
)
.string("Serial Number")
.number("Calibration")
.uri("Manual")
.build()
)
instrument_template = inv_api.create_instrument_template(it_json)
print(
f"Instrument Template with id {instrument_template['id']} was created with "
f"{len(instrument_template['fields'])} fields"
)

print("Creating an Instrument with default field values")

instrument = inv_api.create_instrument(
"My first microscope", instrument_template_id=instrument_template["id"]
)
print(f"Instrument with id {instrument['id']} was created")

print("Creating an Instrument from the template, with field values set")

ForInstrumentCreation = sample_builder2.FieldBuilderGenerator().generate_class(
instrument_template
)
instrument_fields = ForInstrumentCreation()
instrument_fields.serial_number = "SN-1234"
instrument_fields.calibration = 4.7
instrument_fields.manual = "https://example.com/manual.pdf"

instrument_with_fields = inv_api.create_instrument(
"My second microscope",
instrument_template_id=instrument_template["id"],
fields=instrument_fields.to_field_post(),
)
print(
f"Instrument with id {instrument_with_fields['id']} was created with "
f"{len(instrument_with_fields['fields'])} fields set"
)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rspace-client"
version = "2.6.2"
version = "2.7.0"
description = "A client for calling RSpace ELN and Inventory APIs"
license = "Apache-2.0"
authors = ["Research Innovations Ltd <support@researchspace.com>"]
Expand All @@ -25,6 +25,7 @@ python = "^3.9"
requests = "^2.25.1"
beautifulsoup4 = "^4.9.3"
fs = "^2.4.16"
setuptools = "<82"

[tool.poetry.group.dev.dependencies]
python-dotenv = "^1.1.1"
Expand Down
Loading
Loading