Tags
What are Tags?
Tags are a simple organisational tool for finding your objects. Because ursa allows you to construct arbitrary timeseries on a massive scale, it’s convenient to be able to tag the items you construct for later retrieval.
Tag Functions
TimeSeries, DataTables, and other CrudObject entity classes can be organized, and subsequently queried using tags.
Adding Tags
# Import required objects
from ursa_sync.backend import TimeSeries
from ursa_sync import session
# Open a session with the database
db = session()
# Loading up existing feature objects
TS1 = TimeSeries.load(1, db)
TS2 = TimeSeries.load(2, db)
# Creating a new feature object
TS3 = TS1 * TS2 / 10
TS3.save()
# Tagging TS1, TS2 and TS3 for later retrieval:
my_tag = "experiment1"
TS1.add_tag(my_tag)
TS2.add_tag(my_tag)
TS3.add_tag(my_tag)
db.close()
Querying by Tags
Now suppose some days pass, and you’d like to build some tables from the features you were working with in experiment 1:
# Import required objects
from ursa_sync.backend import TimeSeries
from ursa_sync import session
# Open a session with the database
db = session()
TSS = TimeSeries.query_by_tag(
"experiment1",
db
)
... # Now you have your tagged timeseries in a list, and can do whatever work you'd like with them.
Removing Tags
To remove a tag from a TimeSeries (or other CrudObject class) object, simply run:
TS3 = TSS[0] # Grab the first TimeSeries object with "experiment1" tag
TS3.remove_tag("experiment1")