Skip to content

🏷️ Tags

You can define custom groupings of pipes with tags. Consider the example below:

Although both pipes have different connectors and metrics, they share the tag baz, so they can be selected together with --tags baz.

This seems like a useful feature, especially if you have dozens of pipes! But how can we assign these tags?

✍️ Writing Tags

Like in the above example, you can define tags in the Pipe constructor:

1
2
3
4
5
6
>>> import meerschaum as mrsm
>>> mrsm.Pipe(
...   "sql:foo", "bar",
...   tags=['tag1', 'tag2'],
... )
>>>

Tags Live in Parameters

To edit your tags interactively, just define a list under the tags key from edit pipes:

1
mrsm edit pipes -c sql:foo -m bar
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
###################################################
# Edit the parameters for the Pipe 'sql_foo_bar'. #
###################################################

tags:
  - tag1
  - tag2
columns:
  datetime: date
  id: station_id

Finally, you can also add tags to an existing pipe by setting .tags:

1
2
3
4
>>> import meerschaum as mrsm
>>> pipe = mrsm.get_pipes(as_list=True)[0]
>>> pipe.tags = ['tag1', 'tag2']
>>> pipe.edit() ### Persist the tags in the database.