Skip to content

Boss Reserve Ids Tutorial

Tim Gion edited this page Jan 25, 2017 · 2 revisions

Reserving Object Ids

Introduction

Before writing ids to an annotation channel, ids may be reserved to ensure that unique ids are used. The Boss provides a reserve_ids() method to enable this.

The example below assumes the resources created in the [Boss Project Setup](https://github.com/jhuapl-boss/intern/wiki/Boss Project Setup Tutorial) tutorial exist.

Warning

The Boss does not check if non-reserved ids are used. Thus, if you use the reserve id feature, then you should use it for consistently for all ids that are written to an annotation channel. If you only use it some of the time, you will most likely cause problems for yourself.

Example

from intern.remote.boss import BossRemote
from intern.resource.boss.resource import *

rmt = BossRemote()

ann_chan = ChannelResource(
    'Algorithm1', 'JHUAPL', 'Mouse17', 'annotation')

# Reserve a block of 30 ids.  The first id of the block of 30 is returned.
first_id = rmt.reserve_ids(ann_chan, 30)