code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
try: self.logger.info('kill: {0} {{'.format(box_config.process_name)) self.logger.info('target process pid={0}'.format(box_config.pid)) if box_config.pid and psutil.pid_exists(box_config.pid): p = psutil.Process(box_config.pid) p.kill(...
def _kill_process(self, box_config)
method is called to kill a running process
2.85126
2.788364
1.022557
try: p = psutil.Process(box_config.pid) return_code = p.wait(timeout=0.01) if return_code is None: # process is already terminated self.logger.info('Process {0} is terminated'.format(box_config.process_name)) return ...
def _poll_process(self, box_config)
between killing a process and its actual termination lies poorly documented requirement - <purging process' io pipes and reading exit status>. this can be done either by os.wait() or process.wait()
3.519307
3.442495
1.022313
try: box_configurations = self.bc_dao.run_query(QUERY_PROCESSES_FOR_BOX_ID(self.box_id)) for box_config in box_configurations: handler = RepeatTimer(TRIGGER_INTERVAL, self.manage_process, args=[box_config.process_name]) self.thread_handlers[box_c...
def start(self, *_)
reading box configurations and starting timers to start/monitor/kill processes
4.839538
4.184868
1.156437
process_name = args[0] try: box_config = self.bc_dao.get_one([self.box_id, process_name]) if not box_config.is_on: if box_config.pid is not None: self._kill_process(box_config) return if not box_config.pid ...
def manage_process(self, *args)
reads box configuration and start/kill processes. performs process monitoring
2.951345
2.681893
1.100471
conn = None chan = None try: conn = Connection() chan = conn.connection.channel() n = chan.queue_purge(mq_queue_name) sys.stdout.write('Purged {0} messages from {1} queue\n'.format(n, mq_queue_name)) return n except Exception as e: sys.stderr.write('U...
def purge_mq_queue(mq_queue_name)
function purges :param mq_queue_name: <string> name of the message queue :return: number of purged messages
2.038403
2.066635
0.986339
if len(self.publishers) == 0: return Publisher(name=self.name, parent_pool=self) else: return self.publishers.pop()
def get(self)
:return valid :mq::flopsy::Publisher instance
6.34869
4.54276
1.39754
for publisher in self.publishers: try: publisher.close() except Exception as e: self.logger.error('Exception on closing Flopsy Publisher {0}: {1}'.format(self.name, e), exc_info=not suppress_logging) self....
def close(self, suppress_logging=False)
purges all connections. method closes ampq connection (disconnects)
4.494187
4.353899
1.032221
if name not in self.pools: self.pools[name] = _Pool(logger=self.logger, name=name) return self.pools[name].get()
def get(self, name)
creates connection to the MQ with process-specific settings :return :mq::flopsy::Publisher instance
3.901148
4.053605
0.96239
if publisher.name not in self.pools: self.pools[publisher.name] = _Pool(logger=self.logger, name=publisher.name) self.pools[publisher.name].put(publisher)
def put(self, publisher)
releases the Publisher instance for reuse
3.19136
3.126296
1.020812
pool_names = list(self.pools) for name in pool_names: self.reset(name, suppress_logging)
def reset_all(self, suppress_logging=False)
iterates thru the list of established connections and resets them by disconnecting and reconnecting
4.570237
4.451923
1.026576
self._close(name, suppress_logging) self.get(name) self.logger.info('Reset Flopsy Pool for {0}'.format(name))
def reset(self, name, suppress_logging=False)
resets established connection by disconnecting and reconnecting
9.466043
8.515718
1.111596
try: pool_names = list(self.pools) if name in pool_names: self.pools[name].close() del self.pools[name] except Exception as e: self.logger.error('Exception on closing Flopsy Pool for {0}: {1}'.format(name, e), ...
def _close(self, name, suppress_logging)
closes one particular pool and all its amqp amqp connections
4.007898
3.721523
1.076951
pool_names = list(self.pools) for name in pool_names: self._close(name, suppress_logging)
def close(self, suppress_logging=False)
iterates thru all publisher pools and closes them
5.826834
3.947876
1.475941
list_of_rows = [] try: list_of_rows = self.bc_dao.get_all() except LookupError as e: self.logger.error('MX Exception {0}'.format(e), exc_info=True) return list_of_rows
def entries(self)
reading box configuration entries for all boxes managed by Synergy Supervisor
5.190976
4.980205
1.042322
return SimData([i.position for i in g.mutations()], [i for i in g.haplotypes()])
def make_SimData(g)
Construct a :class:`libsequence.polytable.SimData` from the output of msprime. :param g: The output from msprime .. note:: Thanks to Jerome Kelleher for pointing out the quick implementation using msprime >= 0.4.0. .. versionchanged:: 0.2.0 Much faster implementation via haplo...
11.768661
8.285632
1.42037
assert isinstance(instance, SiteStatistics) if instance.db_id: query = {'_id': ObjectId(instance.db_id)} else: query = {DOMAIN_NAME: instance.domain_name, TIMEPERIOD: instance.timeperiod} self.ds.update(collection_name, query, instanc...
def update(self, collection_name, instance)
method finds Site Statistics record and update it DB representation
4.343055
3.543499
1.22564
assert isinstance(instance, SiteStatistics) collection = self.ds.connection(collection_name) return collection.insert_one(instance.document).inserted_id
def insert(self, collection_name, instance)
inserts a unit of work into MongoDB.
6.845916
6.574312
1.041313
qualifier = context.process_context[process_name].time_qualifier if qualifier == QUALIFIER_HOURLY: collection_name = COLLECTION_JOB_HOURLY elif qualifier == QUALIFIER_DAILY: collection_name = COLLECTION_JOB_DAILY elif qualifier == QUALIFIER_MONTHLY: ...
def _get_job_collection_name(self, process_name)
jobs are stored in 4 collections: hourly, daily, monthly and yearly; method looks for the proper job_collection base on process TIME_QUALIFIER
2.179308
1.897465
1.148536
collection_name = self._get_job_collection_name(process_name) collection = self.ds.connection(collection_name) document = collection.find_one({'_id': ObjectId(db_id)}) if document is None: raise LookupError('MongoDB has no job record in collection {0} for {1}' ...
def get_by_id(self, process_name, db_id)
method finds a single job record and returns it to the caller
3.887047
3.536986
1.098971
collection_name = self._get_job_collection_name(process_name) collection = self.ds.connection(collection_name) document = collection.find_one({job.PROCESS_NAME: process_name, job.TIMEPERIOD: timeperiod}) if document is None: raise LookupError('MongoDB has no job rec...
def get_one(self, process_name, timeperiod)
method finds a single job record and returns it to the caller
3.893883
3.568001
1.091334
if since is None: query = {} else: query = {job.TIMEPERIOD: {'$gte': since}} collection = self.ds.connection(collection_name) cursor = collection.find(query) if cursor.count() == 0: raise LookupError('MongoDB has no job records in col...
def get_all(self, collection_name, since=None)
method returns all job records from a particular collection that are older than <since>
3.98126
3.60211
1.105258
cursor = self.ds.filter(collection_name, query) return [Job.from_json(document) for document in cursor]
def run_query(self, collection_name, query)
method runs query on a specified collection and return a list of filtered Job records
7.793196
5.636943
1.382522
try: box_id = None config_file = settings.settings['config_file'] with open(config_file) as a_file: for a_line in a_file: a_line = a_line.strip() if a_line.startswith('#'): continue tokens = a_line.split('=...
def get_box_id(logger)
retrieves box id from the /etc/synergy.conf configuration file :raise EnvironmentError: if the configuration file could not be opened :raise LookupError: if the configuration file does not define BOX_ID variable
2.641259
2.431188
1.086407
"Lists all hosts on the LB" format = "%-35s %-25s %-8s" print format % ("HOST", "ACTION", "SUBDOMS") for host, details in sorted(self.client.get_all().items()): if details[0] in ("proxy", "mirror"): action = "%s<%s>" % ( details[0], ...
def action_list(self)
Lists all hosts on the LB
3.034217
2.878633
1.054048
"Adds a hostname to the LB, or alters an existing one" usage = "set <hostname> <action> <subdoms> [option=value, ...]" if hostname is None: sys.stderr.write("You must supply a hostname.\n") sys.stderr.write("Usage: %s\n" % usage) sys.exit(1) if action ...
def action_set(self, hostname=None, action=None, subdoms=None, *args)
Adds a hostname to the LB, or alters an existing one
2.311216
2.201916
1.049639
"Shows stats (possibly limited by hostname)" format = "%-35s %-11s %-11s %-11s %-11s" print format % ("HOST", "OPEN", "COMPLETED", "BYTES IN", "BYTES OUT") for host, details in sorted(self.client.stats(hostname).items()): print format % ( host, ...
def action_stats(self, hostname=None)
Shows stats (possibly limited by hostname)
3.285739
2.834093
1.159362
resp = dict() resp.update(self._search_by_level(COLLECTION_JOB_HOURLY, timeperiod, include_running, include_processed, include_noop, include_failed, include_disabled)) resp.update(self._search_by_level(COLLECTION_JOB_DAILY, timeperiod, include_r...
def retrieve_records(self, timeperiod, include_running, include_processed, include_noop, include_failed, include_disabled)
method looks for suitable job records in all Job collections and returns them as a dict
1.86911
1.795521
1.040985
resp = dict() try: query = unit_of_work_dao.QUERY_GET_FREERUN_SINCE(timeperiod, include_running, include_processed, include_noop, include_failed) records_list = self.uow_dao.run_query(query) if len(...
def retrieve_records(self, timeperiod, include_running, include_processed, include_noop, include_failed, include_disabled)
method looks for suitable UOW records and returns them as a dict
4.843285
4.486337
1.079563
''' Marks the decorated class as a singleton ``service``. Injects following classmethods: .. py:method:: .get(context) Returns a singleton instance of the class for given ``context`` :param context: context to look in :type context: :class:`Context` ...
def service(cls)
Marks the decorated class as a singleton ``service``. Injects following classmethods: .. py:method:: .get(context) Returns a singleton instance of the class for given ``context`` :param context: context to look in :type context: :class:`Context` :returns: ...
6.520767
2.65339
2.457523
''' Marks the decorated class as an abstract interface. Injects following classmethods: .. py:method:: .all(context) Returns a list of instances of each component in the ``context`` implementing this ``@interface`` :param context: context to look in :type con...
def interface(cls)
Marks the decorated class as an abstract interface. Injects following classmethods: .. py:method:: .all(context) Returns a list of instances of each component in the ``context`` implementing this ``@interface`` :param context: context to look in :type context: :class...
3.446328
1.779588
1.936588
''' Marks the decorated class as a component implementing the given ``iface`` :param iface: the interface to implement :type iface: :func:`interface` ''' def decorator(cls): if not cls: return None # Run custom verificator if any if hasattr(cls, '__verify__...
def component(iface)
Marks the decorated class as a component implementing the given ``iface`` :param iface: the interface to implement :type iface: :func:`interface`
4.693804
3.807198
1.232876
if self.address != 'localhost': raise ModHostError('The host configured in the constructor isn''t "localhost". ' 'It is not possible to start a process on another device.') try: subprocess.call([self.process, '-p', str(self.port)]) ...
def start(self)
Invokes the mod-host process. mod-host requires JACK to be running. mod-host does not startup JACK automatically, so you need to start it before running mod-host. .. note:: This function is experimental. There is no guarantee that the process will actually be initiated.
8.864018
7.306
1.213252
if self.host is None: raise ModHostError('There is no established connection with mod-host. ' 'Did you call the `connect()` method?') super(ModHost, self).close() if self._started_with_this_api: self.host.quit() else: ...
def close(self)
Remove the audio plugins loaded and closes connection with mod-host. .. note:: If the mod-host process has been created with :meth:`~pluginsmanager.observer.mod_host.ModHost.start()` method, it will be finished.
7.810884
5.416306
1.442105
logger = get_logger(PROCESS_SCHEDULER) managed_process_dao = ManagedProcessDao(logger) try: process_entries = managed_process_dao.get_all() except LookupError: logger.error('Synergy DB is not initialized. Aborting.') exit(1) for process_entry in process_entries: ...
def synch_db()
function reads managed_process and updates context entries appropriately
3.448369
3.046703
1.131836
logger = get_logger(PROCESS_SCHEDULER) managed_process_dao = ManagedProcessDao(logger) managed_process_dao.clear() for process_name, process_entry in context.process_context.items(): if not isinstance(process_entry, ManagedProcessEntry): continue managed_process_dao.up...
def update_db()
writes to managed_process table records from the context.process_context
4.713569
3.488453
1.351192
logger = get_logger(PROCESS_SCHEDULER) logger.info('Starting *scheduler* DB reset') ds = ds_manager.ds_factory(logger) ds._db_client.drop_database(settings.settings['mongo_db_name']) logger.info('*scheduler* db has been dropped') connection = ds.connection(COLLECTION_MANAGED_PROCESS) ...
def reset_db()
drops the *scheduler* database, resets schema
3.666052
3.607333
1.016278
self.real_list.append(item) self.observer(UpdateType.CREATED, item, len(self.real_list) - 1)
def append(self, item)
See :meth:`list.append()` method Calls observer ``self.observer(UpdateType.CREATED, item, index)`` where **index** is *item position*
7.121583
3.377369
2.108619
index = self.index(item) self.real_list.remove(item) self.observer(UpdateType.DELETED, item, index)
def remove(self, item)
See :meth:`list.remove()` method Calls observer ``self.observer(UpdateType.DELETED, item, index)`` where **index** is *item position*
8.072218
3.74294
2.156652
self.real_list.insert(index, x) self.observer(UpdateType.CREATED, x, index)
def insert(self, index, x)
See :meth:`list.insert()` method Calls observer ``self.observer(UpdateType.CREATED, item, index)``
10.61365
3.345175
3.172824
if item == self[new_position]: return self.remove(item) self.insert(new_position, item)
def move(self, item, new_position)
Moves a item list to new position Calls observer ``self.observer(UpdateType.DELETED, item, index)`` and observer ``self.observer(UpdateType.CREATED, item, index)`` if ``val != self[index]`` :param item: Item that will be moved to new_position :param new_position: Item's new pos...
3.370315
3.640142
0.925874
if 'effect' in json[audio_port]: return Lv2AudioPortBuilder(self.pedalboard) else: return SystemAudioPortBuilder(self.system_effect)
def generate_builder(self, json, audio_port)
:return AudioPortBuilder
12.517247
10.559308
1.185423
'''match a request with parameter to it's corresponding route''' route_dicts = [routes for _, routes in self.api.http.routes.items()][0] routes = [route for route, _ in route_dicts.items()] #no prameters in path if reqpath in routes: return reqpath for route i...
def match_route(self, reqpath)
match a request with parameter to it's corresponding route
6.649982
5.464877
1.216859
self.timetable.add_log_entry(process_name, timeperiod, msg) self.logger.log(level, msg)
def _log_message(self, level, process_name, timeperiod, msg)
method performs logging into log file and Timetable's tree node
4.584501
3.3025
1.388191
uow = UnitOfWork() uow.process_name = process_name uow.timeperiod = timeperiod uow.start_id = str(start_id) uow.end_id = str(end_id) uow.start_timeperiod = start_timeperiod uow.end_timeperiod = end_timeperiod uow.created_at = datetime.utcnow() ...
def _insert_uow(self, process_name, timeperiod, start_timeperiod, end_timeperiod, start_id, end_id)
creates unit_of_work and inserts it into the DB :raise DuplicateKeyError: if unit_of_work with given parameters already exists
2.292495
2.318728
0.988686
process_name = job_record.process_name timeperiod = job_record.timeperiod start_timeperiod = self.compute_start_timeperiod(job_record.process_name, job_record.timeperiod) end_timeperiod = self.compute_end_timeperiod(job_record.process_name, job_record.timeperiod) try: ...
def insert_and_publish_uow(self, job_record, start_id, end_id)
method creates and publishes a unit_of_work. it also handles DuplicateKeyError and attempts recovery :return: tuple (uow, is_duplicate) :raise UserWarning: if the recovery from DuplicateKeyError was unsuccessful
3.415717
3.170563
1.077322
time_grouping = context.process_context[process_name].time_grouping if time_grouping == 1: return timeperiod # step1: translate given timeperiod to the time grouped one process_hierarchy = self.timetable.get_tree(process_name).process_hierarchy timeperiod_di...
def compute_start_timeperiod(self, process_name, timeperiod)
computes lowest *inclusive* timeperiod boundary for job to process for process with time_grouping == 1, it returns given timeperiod with no change for process with time_grouping != 1, it computes first timeperiod, not processed by the previous job run For instance: with time_grouping...
4.219012
3.627289
1.163131
time_qualifier = context.process_context[process_name].time_qualifier end_timeperiod = time_helper.increment_timeperiod(time_qualifier, timeperiod) return end_timeperiod
def compute_end_timeperiod(self, process_name, timeperiod)
computes first *exclusive* timeperiod for job to process
4.590623
4.543389
1.010396
time_grouping = context.process_context[process_name].time_grouping if time_grouping == 1: return False process_hierarchy = self.timetable.get_tree(process_name).process_hierarchy timeperiod_dict = process_hierarchy[process_name].timeperiod_dict return timep...
def _is_noop_timeperiod(self, process_name, timeperiod)
method verifies if the given timeperiod for given process is valid or falls in-between grouping checkpoints :param process_name: name of the process :param timeperiod: timeperiod to verify :return: False, if given process has no time_grouping set or it is equal to 1. False, if t...
5.516912
4.860418
1.135069
job_record.state = job.STATE_NOOP self.job_dao.update(job_record) time_grouping = context.process_context[job_record.process_name].time_grouping msg = 'Job {0}@{1} with time_grouping {2} was transferred to STATE_NOOP' \ .format(job_record.process_name, job_record....
def _process_noop_timeperiod(self, job_record)
method is valid for processes having time_grouping != 1. should a job record fall in-between grouped time milestones, its state should be set to STATE_NOOP without any processing
4.488952
3.681678
1.219268
uow = self.uow_dao.get_one(job_record.related_unit_of_work) if uow.is_processed: self.update_job(job_record, uow, job.STATE_PROCESSED) elif uow.is_noop: self.update_job(job_record, uow, job.STATE_NOOP) elif uow.is_canceled: self.update_job(job...
def _process_state_final_run(self, job_record)
method takes care of processing job records in STATE_FINAL_RUN state
3.308592
3.282146
1.008058
msg = 'Job {0} for {1}@{2} is in the terminal state {3}, ' \ 'and is no further govern by the State Machine {4}' \ .format(job_record.db_id, job_record.process_name, job_record.timeperiod, job_record.state, self.name) self._log_message(WARNING, job_record.process_nam...
def _process_terminal_state(self, job_record)
method logs a warning message notifying that the job is no longer govern by this state machine
5.597886
4.090576
1.368484
is_job_finalizable = self.timetable.is_job_record_finalizable(job_record) if is_job_finalizable: self.manage_job(job_record) else: msg = 'Job {0}@{1} is blocked by unprocessed children/dependencies. Waiting another tick' \ .format(job_record.pro...
def manage_job_with_blocking_children(self, job_record)
method will trigger job processing only if: - all children are finished (STATE_PROCESSED, STATE_SKIPPED, STATE_NOOP) - all external dependencies are finalized (STATE_PROCESSED, STATE_SKIPPED, STATE_NOOP)
5.334341
4.568503
1.167634
composite_state = self.timetable.dependent_on_composite_state(job_record) assert isinstance(composite_state, NodesCompositeState) if composite_state.all_processed: self.manage_job(job_record) elif composite_state.skipped_present: # As soon as among <depe...
def manage_job_with_blocking_dependencies(self, job_record)
method will trigger job processing only if: - all dependencies are in [STATE_PROCESSED, STATE_NOOP] NOTICE: method will transfer current job into STATE_SKIPPED if any dependency is in STATE_SKIPPED
4.759753
4.545618
1.047108
assert isinstance(job_record, Job) try: if self._is_noop_timeperiod(job_record.process_name, job_record.timeperiod): self._process_noop_timeperiod(job_record) return if job_record.is_embryo: self._process_state_embryo(job_...
def manage_job(self, job_record)
method main duty - is to _avoid_ publishing another unit_of_work, if previous was not yet processed In case the State Machine sees that the unit_of_work already exist it could either: - update boundaries of the processing; republish - wait another tick; idle
2.802601
2.750708
1.018865
original_job_state = job_record.state if not job_record.is_finished: job_record.state = job.STATE_SKIPPED self.job_dao.update(job_record) if job_record.related_unit_of_work: uow = self.uow_dao.get_one(job_record.related_unit_of_work) if ...
def skip_job(self, job_record)
method transfers: - given job into STATE_SKIPPED if it is not not in finished state - UOW into STATE_CANCELED if it is not in finished state
3.00725
2.557226
1.175981
job_record = Job() job_record.state = job.STATE_EMBRYO job_record.timeperiod = timeperiod job_record.process_name = process_name self.job_dao.update(job_record) self.logger.info('Created Job {0} for {1}@{2}' .format(job_record.db_id, job...
def create_job(self, process_name, timeperiod)
method creates a job record in STATE_EMBRYO for given process_name and timeperiod :returns: created job record of type <Job>
3.02246
2.540514
1.189704
original_job_state = job_record.state job_record.state = new_state job_record.related_unit_of_work = uow.db_id self.job_dao.update(job_record) msg = 'Updated Job {0} for {1}@{2}: state transfer {3} -> {4};' \ .format(job_record.db_id, job_record.process_na...
def update_job(self, job_record, uow, new_state)
method updates job record with a new unit_of_work and new state
4.051913
3.573609
1.133843
while threading.active_count() > settings.settings['bash_runnable_count'] + self.initial_thread_count: time.sleep(0.1) t = BashRunnable(self.logger, message, self.consumer, self.performance_tracker) t.daemon = True t.start()
def _mq_callback(self, message)
reads JSON request from the mq message and delivers it for processing
8.043372
8.104815
0.992419
"Loads the state from the state file" try: if os.path.getsize(self.state_file) <= 1: raise IOError("File is empty.") with open(self.state_file) as fh: state = json.load(fh) assert isinstance(state, dict) self.hosts =...
def load(self)
Loads the state from the state file
3.205998
3.140402
1.020888
"Saves the state to the state file" with open(self.state_file, "w") as fh: json.dump({ "hosts": self.hosts, "stats": self.stats, }, fh)
def save(self)
Saves the state to the state file
4.610578
3.923355
1.175162
last_hash = hash(repr(self.hosts)) while self.running: eventlet.sleep(self.save_interval) next_hash = hash(repr(self.hosts)) if next_hash != last_hash: self.save() last_hash = next_hash
def save_loop(self)
Saves the state if it has changed.
3.514653
3.149897
1.115799
try: sock = eventlet.listen(address, family) except socket.error, e: logging.critical("Cannot listen on (%s, %s): %s" % (address, family, e)) return # Sleep to ensure we've dropped privileges by the time we start serving eventlet.sleep(0.5) ...
def management_loop(self, address, family)
Accepts management requests.
4.271728
4.301647
0.993045
try: sock = eventlet.listen(address, family) except socket.error, e: if e.errno == errno.EADDRINUSE: logging.critical("Cannot listen on (%s, %s): already in use" % (address, family)) raise elif e.errno == errno.EACCES and addre...
def listen_loop(self, address, family, internal=False)
Accepts incoming connections.
3.185682
3.250525
0.980051
try: sock = StatsSocket(sock) rfile = sock.makefile('rb', 4096) # Read the first line first = rfile.readline().strip("\r\n") words = first.split() # Ensure it looks kind of like HTTP if not (2 <= len(words) <= 3): ...
def handle(self, sock, address, internal=False)
Handles an incoming HTTP connection.
2.501486
2.463835
1.015281
try: raw_data = RawData.from_json(message.body) try: session = self.ss_dao.find_by_session_id(raw_data.domain_name, raw_data.session_id) # update the click_xxx info session = self.update_session_body(raw_data, session) ...
def _mq_callback(self, message)
wraps call of abstract method with try/except in case exception breaks the abstract method, this method: - catches the exception - logs the exception - marks unit of work as INVALID
4.139418
4.207303
0.983865
trigger_frequency = process_entry.trigger_frequency if isinstance(process_entry, ManagedProcessEntry): handler_key = process_entry.process_name handler = ManagedThreadHandler(self.logger, handler_key, trigger_frequency, call_back, process_entry) self.managed_...
def _register_process_entry(self, process_entry, call_back)
method parses process_entry and creates a timer_handler out of it timer_handler is enlisted to either :self.freerun_handlers or :self.managed_handlers timer_handler is started, unless it is marked as STATE_OFF
2.77989
2.387364
1.164418
for process_name, process_entry in context.process_context.items(): if isinstance(process_entry, ManagedProcessEntry): function = self.fire_managed_worker else: self.logger.warning('Skipping non-managed context entry {0} of type {1}.' ...
def _load_managed_entries(self)
loads scheduler managed entries. no start-up procedures are performed
4.464746
4.226055
1.056481
freerun_entries = self.freerun_process_dao.get_all() for freerun_entry in freerun_entries: try: self._register_process_entry(freerun_entry, self.fire_freerun_worker) except Exception: self.logger.error('Freerun Thread Handler {0} failed to...
def _load_freerun_entries(self)
reads scheduler managed entries and starts their timers to trigger events
4.112122
3.626418
1.133935
self.logger.info('Starting Scheduler...') db_manager.synch_db() self._load_managed_entries() try: self._load_freerun_entries() except LookupError as e: self.logger.warning('DB Lookup: {0}'.format(e)) # Scheduler is initialized and runnin...
def start(self, *_)
reads managed process entries and starts timer instances; starts dependant threads
9.448221
8.544714
1.105739
process_entry = self.managed_handlers[process_name].process_entry return self.timetable.state_machines[process_entry.state_machine_name]
def state_machine_for(self, process_name)
:return: state machine for the given process name
7.698243
6.495417
1.185181
def _fire_worker(process_entry, prev_job_record): assert isinstance(process_entry, ManagedProcessEntry) job_record = self.timetable.get_next_job_record(process_entry.process_name) state_machine = self.timetable.state_machines[process_entry.state_machine_name] ...
def fire_managed_worker(self, thread_handler_header)
requests next valid job for given process and manages its state
2.934745
2.875953
1.020443
try: assert isinstance(thread_handler_header, ThreadHandlerHeader) self.logger.info('{0} {{'.format(thread_handler_header.key)) state_machine = self.timetable.state_machines[STATE_MACHINE_FREERUN] state_machine.manage_schedulable(thread_handler_header.pr...
def fire_freerun_worker(self, thread_handler_header)
fires free-run worker with no dependencies to track
4.117155
4.179742
0.985026
def method_builder(cls): method_doc = .format(cls.__name__) def method(self, **kwargs): resource_id = None if self.is_singleton() else self.id return Timeseries(self._session, cls, resource_id, **kwargs) method.__doc__ = method_doc setattr(cls, 'timeser...
def timeseries()
Create a timeseries builder. Returns: A builder function which, given a class creates a timeseries relationship for that class.
4.449551
4.329159
1.02781
if hasattr(self, '_sensor_id'): return self._sensor_id relationships = self._json_data.get('relationships') sensor_id = relationships.get('sensor').get('data').get('id') self._sensor_id = sensor_id return sensor_id
def sensor_id(self)
The id of the sensor of this data point. Returns: The id of the sensor that generated this datapoint. Will throw an AttributeError if no sensor id was found in the underlyign data.
2.671789
2.994259
0.892304
session = self._session datapoint_class = self._datapoint_class attributes = { 'port': port, 'value': value, } if timestamp is not None: attributes['timestamp'] = to_iso_date(timestamp) attributes = build_request_body('data-poi...
def create(self, port, value, timestamp=None)
Post a new reading to a timeseries. A reading is comprised of a `port`, a `value` and a timestamp. A port is like a tag for the given reading and gives an indication of the meaning of the value. The value of the reading can be any valid json value. The timestamp is considered...
4.631093
5.409863
0.856046
session = self._session url = "{}/live".format(self._base_url) supported_params = frozenset(['filter[port]']) params = {k: v for k, v in iteritems(self._params) if k in supported_params} return session.live(url, self._datapoint_class, { 'is_...
def live(self)
Get a live stream of timeseries readings. This returns an Iterable over a live stream of readings. Note that the result will need to be closed since the system can not tell when you'll be done with it. You can either call ``close`` on the endpoint when you're or use the context...
5.859139
6.477104
0.904592
state_machines = dict() for state_machine in [StateMachineRecomputing(self.logger, self), StateMachineContinuous(self.logger, self), StateMachineDiscrete(self.logger, self), StateMachineFreerun(self.logger...
def _construct_state_machines(self)
:return: dict in format <state_machine_common_name: instance_of_the_state_machine>
4.007648
3.581572
1.118963
for tree_name, context_entry in context.timetable_context.items(): tree = self.trees[tree_name] assert isinstance(tree, MultiLevelTree) for dependent_on in context_entry.dependent_on: dependent_on_tree = self.trees[dependent_on] assert...
def _register_dependencies(self)
register dependencies between trees
3.654981
3.200298
1.142075
dependant_trees = [] for tree_name, tree in self.trees.items(): if tree_obj in tree.dependent_on: dependant_trees.append(tree) return dependant_trees
def _find_dependant_trees(self, tree_obj)
returns list of trees that are dependent_on given tree_obj
2.729402
2.103071
1.297817
if not tx_context: # create transaction context if one was not provided # format: {process_name: {timeperiod: AbstractTreeNode} } tx_context = collections.defaultdict(dict) if tree_node.parent is None: # do not process 'root' - the only node that...
def reprocess_tree_node(self, tree_node, tx_context=None)
method reprocesses the node and all its dependants and parent nodes
3.254364
3.156746
1.030923
if not tx_context: # create transaction context if one was not provided # format: {process_name: {timeperiod: AbstractTreeNode} } tx_context = collections.defaultdict(dict) if tree_node.timeperiod in tx_context[tree_node.process_name]: # the node...
def skip_tree_node(self, tree_node, tx_context=None)
method skips the node and all its dependants and child nodes
3.068588
2.93431
1.045761
try: job_record = self.job_dao.get_one(tree_node.process_name, tree_node.timeperiod) except LookupError: state_machine_name = context.process_context[tree_node.process_name].state_machine_name state_machine = self.state_machines[state_machine_name] ...
def assign_job_record(self, tree_node)
- looks for an existing job record in the DB, and if not found - creates a job record in STATE_EMBRYO and bind it to the given tree node
2.85921
2.799762
1.021233
for tree_name, tree in self.trees.items(): if process_name in tree: return tree
def get_tree(self, process_name)
return tree that is managing time-periods for given process
3.75117
3.169976
1.183343
invalid_tree_records = dict() invalid_tq_records = dict() try: job_records = self.job_dao.get_all(collection_name, since) for job_record in job_records: tree = self.get_tree(job_record.process_name) if tree is None: ...
def _build_tree_by_level(self, time_qualifier, collection_name, since)
method iterated thru all documents in all job collections and builds a tree of known system state
3.007776
3.016258
0.997188
timeperiod = settings.settings['synergy_start_timeperiod'] yearly_timeperiod = time_helper.cast_to_time_qualifier(QUALIFIER_YEARLY, timeperiod) monthly_timeperiod = time_helper.cast_to_time_qualifier(QUALIFIER_MONTHLY, timeperiod) daily_timeperiod = time_helper.cast_to_time_qual...
def load_tree(self)
method iterates thru all objects older than synergy_start_timeperiod parameter in job collections and loads them into this timetable
2.21293
1.891821
1.169736
assert isinstance(job_record, Job) tree = self.get_tree(job_record.process_name) node = tree.get_node(job_record.process_name, job_record.timeperiod) return node.dependent_on_composite_state()
def dependent_on_composite_state(self, job_record)
:return instance of <NodesCompositeState>
3.916589
3.33393
1.174767
tree = self.get_tree(job_record.process_name) node = tree.get_node(job_record.process_name, job_record.timeperiod) if tree.should_skip_tree_node(node): self.skip_tree_node(node)
def skip_if_needed(self, job_record)
method is called from abstract_state_machine.manage_job to notify about job's failed processing if should_skip_node returns True - the node's job_record is transferred to STATE_SKIPPED
4.423565
3.940752
1.122518
tree = self.get_tree(process_name) node = tree.get_next_node(process_name) if node.job_record is None: self.assign_job_record(node) return node.job_record
def get_next_job_record(self, process_name)
:returns: the next job record to work on for the given process
3.717418
3.531927
1.052518
assert isinstance(job_record, Job) tree = self.get_tree(job_record.process_name) node = tree.get_node(job_record.process_name, job_record.timeperiod) return node.is_finalizable()
def is_job_record_finalizable(self, job_record)
:return: True, if the node and all its children are in [STATE_PROCESSED, STATE_SKIPPED, STATE_NOOP]
3.923459
3.550102
1.105168
tree = self.get_tree(process_name) node = tree.get_node(process_name, timeperiod) node.add_log_entry([datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), msg])
def add_log_entry(self, process_name, timeperiod, msg)
adds a non-persistent log entry to the tree node
3.153219
2.811848
1.121405
banks = self.banks_files.load(system_effect) banks_ordered = self.index_file.load(banks) manager = BanksManager() manager.register(self) for bank in banks_ordered: manager.append(bank) bank.manager = manager return manager
def load(self, system_effect)
Return a :class:`.BanksManager` instance contains the banks present in :attr:`~pluginsmanager.observer.autosaver.autosaver.Autosaver.data_path` :param SystemEffect system_effect: SystemEffect used in pedalboards :return BanksManager: :class:`.BanksManager` with banks persisted in ...
5.733255
5.020543
1.141959
self.banks_files.delete_all_banks() self.banks_files.save(banks_manager) self.index_file.save(banks_manager)
def save(self, banks_manager)
Save all data from a banks_manager :param BanksManager banks_manager: BanksManager that your banks data will be persisted
4.153773
4.313745
0.962916
for key in kwargs: if key in [ x.name for x in cls.INPUTS ]: setattr(self, key, kwargs[key]) if key in [ x.name for x in cls.OUTPUTS ]: setattr(self, key, kwargs[key]) if key in [ x.name for x in cls.PARAMETERS ]: setattr(self, key, kwar...
def apply(cls, self, *args, **kwargs)
Applies kwargs arguments to the instance passed as the first argument to the call. For defined INPUTS, OUTPUTS and PARAMETERS the method extracts a corresponding value from kwargs and sets it as an instance attribute. For example, if the processor has a 'foo' parameter declared and ...
2.19536
1.794433
1.223429
pspec = {} pspec['name'] = self.NAME pspec['version'] = self.VERSION pspec['description'] = self.DESCRIPTION #if hasattr(self, 'run') and callable(self.run): components = [sys.argv[0], self.NAME] if self.USE_ARGUMENTS: components.append('$(arguments)') ...
def spec(self)
Generate spec for the processor as a Python dictionary. A spec is a standard way to describe a MountainLab processor in a way that is easy to process, yet still understandable by humans. This method generates a Python dictionary that complies with a spec definition.
3.162575
3.162559
1.000005
if supparser: parser = supparser.add_parser(self.NAME, description=self.DESCRIPTION) else: if noexit: class NoExitArgumentParser(argparse.ArgumentParser): def exit(self, status=0, message=None): raise ParserErro...
def invoke_parser(self, supparser=None, noexit=False)
Return a commandline parser (argparse) for the processor.
2.205177
2.189195
1.007301
if args is None: args=[] for kwargname in kwargs: args.append('--'+kwargname) args.append('{}'.format(kwargs[kwargname])) parser = proc.invoke_parser(noexit=(_instance is not None)) opts = parser.parse_args(args) kwargs0 = {} ...
def invoke(proc, args=None, *, _instance = None, **kwargs)
Executes the processor passing given arguments. :param args: a list of parameters in --key=value format.
3.681655
3.68316
0.999591
if self.bank is None: raise IndexError('Pedalboard not contains a bank') return self.bank.pedalboards.index(self)
def index(self)
Returns the first occurrence of the pedalboard in your bank
11.851067
5.918789
2.002279
ConnectionClass = output_port.connection_class self.connections.append(ConnectionClass(output_port, input_port))
def connect(self, output_port, input_port)
Connect two :class:`.Effect` instances in this pedalboard. For this, is necessary informs the output port origin and the input port destination:: >>> pedalboard.append(driver) >>> pedalboard.append(reverb) >>> driver_output = driver.outputs[0] >>> reverb_input = ...
4.286446
7.557864
0.56715
ConnectionClass = output_port.connection_class self.connections.remove(ConnectionClass(output_port, input_port))
def disconnect(self, output_port, input_port)
Remove a connection between (two ports of) :class:`.Effect` instances. For this, is necessary informs the output port origin and the input port destination:: >>> pedalboard.append(driver) >>> pedalboard.append(reverb) >>> driver_output = driver.outputs[0] >>> rev...
4.568394
7.893586
0.578748
if self._transitions is not None: return self._transitions transitions = self.array.astype(np.float) transitions /= transitions.sum(1)[:, np.newaxis] self._transitions = transitions return transitions
def transitions(self)
Dense [k-1]x4 transition frequency matrix
3.432768
3.326219
1.032033