Skip to main content

Services

Services group attribute groups together for serving to your applications.

There are two ways to define the attribute groups in your service:

  • AttributeGroup objects: use the objects directly if you have them available in your code
  • Dictionaries: refer to the attribute group by name and version, in the format {"name": "group_name", "version": 1}

This example code shows both options:

from snowplow_signals import Service

# Refers to the attribute groups by name
my_service = Service(
name='my_service',
description='A collection of attribute groups',
owner="user@company.com",
attribute_groups=[
# Specify exact versions using dictionaries
{"name": "user_attributes", "version": 2},
{"name": "session_attributes", "version": 1},
],
)

# Uses the objects directly
my_service = Service(
name='my_service',
description='A collection of attribute groups',
owner="user@company.com",
attribute_groups=[
# Previously defined attribute groups
my_attribute_group,
another_attribute_group
],
)

The table below lists all available arguments for a Service

ArgumentDescriptionTypeRequired?
nameThe name of the servicestring
descriptionA description of the servicestring
ownerThe owner of the service, typically the email of the primary maintainerstring
attribute_groupsList of attribute groups with optional version specificationlist of AttributeGroup or dict

Publishing services

Use the publish() method to register services with Signals. This makes them available for use.

from snowplow_signals import Signals

# Connect to Signals
sp_signals = Signals(
{{ config }}
)

# Publish services
sp_signals.publish([
my_service,
my_other_service
])

On this page

Want to see a custom demo?

Our technical experts are here to help.