import os import time import newrelic.agent from celery import task from django.conf import settings from django.core.management import call_command from treeherder.model.exchanges import TreeherderPublisher from treeherder.model.models import (Job, Repository) from treeherder.model.pulse_publisher import load_schemas # Load schemas for validation of messages published on pulse SOURCE_FOLDER = os.path.dirname(os.path.realpath(__file__)) SCHEMA_FOLDER = os.path.join(SOURCE_FOLDER, '..', '..', 'schemas') PULSE_SCHEMAS = load_schemas(SCHEMA_FOLDER) class LazyPublisher(): """ Singleton for lazily connecting to the pulse publisher. """ def __init__(self): self.publisher = None def get_publisher(self): """ Attempt to get the publisher. """ # Create publisher, if username and password is present if not self.publisher and settings.PULSE_EXCHANGE_NAMESPACE:
import os from celery import task from django.conf import settings from django.core.management import call_command from treeherder.model.error_summary import load_error_summary from treeherder.model.exchanges import TreeherderPublisher from treeherder.model.models import Repository from treeherder.model.pulse_publisher import load_schemas # Load schemas for validation of messages published on pulse SOURCE_FOLDER = os.path.dirname(os.path.realpath(__file__)) SCHEMA_FOLDER = os.path.join(SOURCE_FOLDER, '..', '..', 'schemas') PULSE_SCHEMAS = load_schemas(SCHEMA_FOLDER) class LazyPublisher(): """ Singleton for lazily connecting to the pulse publisher. """ def __init__(self): self.publisher = None def get_publisher(self): """ Attempt to get the publisher. """ # Create publisher, if username and password is present if not self.publisher and settings.PULSE_EXCHANGE_NAMESPACE:
jm = JobsModel(project) for t_range in settings.TREEHERDER_PERF_SERIES_TIME_RANGES: for signature in series_data: jm.store_performance_series(t_range['seconds'], series_type, signature, series_data[signature]) jm.disconnect() from treeherder.model.exchanges import TreeherderPublisher from treeherder.model.pulse_publisher import load_schemas import os # Load schemas for validation of messages published on pulse source_folder = os.path.dirname(os.path.realpath(__file__)) schema_folder = os.path.join(source_folder, '..', '..', 'schemas') schemas = load_schemas(schema_folder) # Create publisher, if username and password is present publisher = None if settings.PULSE_USERNAME and settings.PULSE_PASSWORD: publisher = TreeherderPublisher(client_id=settings.PULSE_USERNAME, access_token=settings.PULSE_PASSWORD, schemas=schemas) @task(name='publish-to-pulse') def publish_to_pulse(project, ids, data_type): # If we don't have a publisher (because of missing configs), then we can't # publish any pulse messages. This is okay, local installs etc. doesn't # need to publish on pulse, and requiring a pulse user is adding more # overhead to an already large development setup process.
for t_range in settings.TREEHERDER_PERF_SERIES_TIME_RANGES: for signature in series_data: jm.store_performance_series( t_range['seconds'], series_type, signature, series_data[signature] ) jm.disconnect() from treeherder.model.exchanges import TreeherderPublisher from treeherder.model.pulse_publisher import load_schemas import os # Load schemas for validation of messages published on pulse source_folder = os.path.dirname(os.path.realpath(__file__)) schema_folder = os.path.join(source_folder, '..', '..', 'schemas') schemas = load_schemas(schema_folder) # Create publisher, if username and password is present publisher = None if settings.PULSE_USERNAME and settings.PULSE_PASSWORD: publisher = TreeherderPublisher( client_id = settings.PULSE_USERNAME, access_token = settings.PULSE_PASSWORD, schemas = schemas ) @task(name='publish-to-pulse') def publish_to_pulse(project, ids, data_type): # If we don't have a publisher (because of missing configs), then we can't # publish any pulse messages. This is okay, local installs etc. doesn't # need to publish on pulse, and requiring a pulse user is adding more