sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def elasticsearch(line): ''' >>> import pprint >>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]' >>> output_line = elasticsearch(input_line) >>> pprint.pprint(output_line) {'data': {'garba...
>>> import pprint >>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]' >>> output_line = elasticsearch(input_line) >>> pprint.pprint(output_line) {'data': {'garbage_collector': 'gc', 'g...
entailment
def elasticsearch_ispartial_log(line): ''' >>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacit...
>>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacity [1000]' >>> line2 = ' org.elasticsearch.Reso...
entailment
def get(self, attr, default=None): """Get an attribute defined by this session""" attrs = self.body.get('attributes') or {} return attrs.get(attr, default)
Get an attribute defined by this session
entailment
def get_all(self, cat): """ if data can't found in cache then it will be fetched from db, parsed and stored to cache for each lang_code. :param cat: cat of catalog data :return: """ return self._get_from_local_cache(cat) or self._get_from_cache(cat) or self._get...
if data can't found in cache then it will be fetched from db, parsed and stored to cache for each lang_code. :param cat: cat of catalog data :return:
entailment
def _fill_get_item_cache(self, catalog, key): """ get from redis, cache locally then return :param catalog: catalog name :param key: :return: """ lang = self._get_lang() keylist = self.get_all(catalog) self.ITEM_CACHE[lang][catalog] = dict([(i['va...
get from redis, cache locally then return :param catalog: catalog name :param key: :return:
entailment
def run(self, host, port, debug=True, validate_requests=True): """Utility method to quickly get a server up and running. :param debug: turns on Werkzeug debugger, code reloading, and full logging. :param validate_requests: whether or not to ensure that requests are sent ...
Utility method to quickly get a server up and running. :param debug: turns on Werkzeug debugger, code reloading, and full logging. :param validate_requests: whether or not to ensure that requests are sent by Amazon. This can be usefulfor manually testing the server.
entailment
def dispatch_request(self, body): """Given a parsed JSON request object, call the correct Intent, Launch, or SessionEnded function. This function is called after request parsing and validaion and will raise a `ValueError` if an unknown request type comes in. :param body: JSON o...
Given a parsed JSON request object, call the correct Intent, Launch, or SessionEnded function. This function is called after request parsing and validaion and will raise a `ValueError` if an unknown request type comes in. :param body: JSON object loaded from incoming request's POST dat...
entailment
def intent(self, intent_name): """Decorator to register a handler for the given intent. The decorated function can either take 0 or 2 arguments. If two are specified, it will be provided a dictionary of `{slot_name: value}` and a :py:class:`alexandra.session.Session` instance. ...
Decorator to register a handler for the given intent. The decorated function can either take 0 or 2 arguments. If two are specified, it will be provided a dictionary of `{slot_name: value}` and a :py:class:`alexandra.session.Session` instance. If no session was provided in the request,...
entailment
def set_password(self, raw_password): """ Kullanıcı şifresini encrypt ederek set eder. Args: raw_password (str) """ self.password = pbkdf2_sha512.encrypt(raw_password, rounds=10000, salt_size=10)
Kullanıcı şifresini encrypt ederek set eder. Args: raw_password (str)
entailment
def encrypt_password(self): """ encrypt password if not already encrypted """ if self.password and not self.password.startswith('$pbkdf2'): self.set_password(self.password)
encrypt password if not already encrypted
entailment
def send_notification(self, title, message, typ=1, url=None, sender=None): """ sends message to users private mq exchange Args: title: message: sender: url: typ: """ self.created_channels.channel.add_message( ...
sends message to users private mq exchange Args: title: message: sender: url: typ:
entailment
def send_client_cmd(self, data, cmd=None, via_queue=None): """ Send arbitrary cmd and data to client if queue name passed by "via_queue" parameter, that queue will be used instead of users private exchange. Args: data: dict cmd: string via_que...
Send arbitrary cmd and data to client if queue name passed by "via_queue" parameter, that queue will be used instead of users private exchange. Args: data: dict cmd: string via_queue: queue name,
entailment
def seek(self, offset): """ shifts on a given number of record in the original file :param offset: number of record """ if self._shifts: if 0 <= offset < len(self._shifts): current_pos = self._file.tell() new_pos = self._shifts[offset] ...
shifts on a given number of record in the original file :param offset: number of record
entailment
def tell(self): """ :return: number of records processed from the original file """ if self._shifts: t = self._file.tell() if t == self._shifts[0]: return 0 elif t == self._shifts[-1]: return len(self._shifts) - 1 ...
:return: number of records processed from the original file
entailment
def assign_yourself(self): """ Assigning the workflow to itself. The selected job is checked to see if there is an assigned role. If it does not have a role assigned to it, it takes the job to itself and displays a message that the process is successful. ...
Assigning the workflow to itself. The selected job is checked to see if there is an assigned role. If it does not have a role assigned to it, it takes the job to itself and displays a message that the process is successful. If there is a role assigned to it, it does not d...
entailment
def select_role(self): """ The workflow method to be assigned to the person with the same role and unit as the user. .. code-block:: python # request: { 'task_inv_key': string, } """ roles = [(m.key,...
The workflow method to be assigned to the person with the same role and unit as the user. .. code-block:: python # request: { 'task_inv_key': string, }
entailment
def send_workflow(self): """ With the workflow instance and the task invitation is assigned a role. """ task_invitation = TaskInvitation.objects.get(self.task_invitation_key) wfi = task_invitation.instance select_role = self.input['form']['select_role'] if wfi.cur...
With the workflow instance and the task invitation is assigned a role.
entailment
def select_postponed_date(self): """ The time intervals at which the workflow is to be extended are determined. .. code-block:: python # request: { 'task_inv_key': string, } """ _form = forms.Jso...
The time intervals at which the workflow is to be extended are determined. .. code-block:: python # request: { 'task_inv_key': string, }
entailment
def save_date(self): """ Invitations with the same workflow status are deleted. Workflow instance and invitation roles change. """ task_invitation = TaskInvitation.objects.get(self.task_invitation_key) wfi = task_invitation.instance if wfi.current_actor.e...
Invitations with the same workflow status are deleted. Workflow instance and invitation roles change.
entailment
def suspend(self): """ If there is a role assigned to the workflow and it is the same as the user, it can drop the workflow. If it does not exist, it can not do anything. .. code-block:: python # request: { 'task_inv_ke...
If there is a role assigned to the workflow and it is the same as the user, it can drop the workflow. If it does not exist, it can not do anything. .. code-block:: python # request: { 'task_inv_key': string, }
entailment
def on_home_row(self, location=None): """ Finds out if the piece is on the home row. :return: bool for whether piece is on home row or not """ location = location or self.location return (self.color == color.white and location.rank == 1) or \ (self.color =...
Finds out if the piece is on the home row. :return: bool for whether piece is on home row or not
entailment
def would_move_be_promotion(self, location=None): """ Finds if move from current get_location would result in promotion :type: location: Location :rtype: bool """ location = location or self.location return (location.rank == 1 and self.color == color.black) or \ ...
Finds if move from current get_location would result in promotion :type: location: Location :rtype: bool
entailment
def square_in_front(self, location=None): """ Finds square directly in front of Pawn :type: location: Location :rtype: Location """ location = location or self.location return location.shift_up() if self.color == color.white else location.shift_down()
Finds square directly in front of Pawn :type: location: Location :rtype: Location
entailment
def forward_moves(self, position): """ Finds possible moves one step and two steps in front of Pawn. :type: position: Board :rtype: list """ if position.is_square_empty(self.square_in_front(self.location)): """ If square in front is empty ...
Finds possible moves one step and two steps in front of Pawn. :type: position: Board :rtype: list
entailment
def _one_diagonal_capture_square(self, capture_square, position): """ Adds specified diagonal as a capture move if it is one """ if self.contains_opposite_color_piece(capture_square, position): if self.would_move_be_promotion(): for move in self.create_promot...
Adds specified diagonal as a capture move if it is one
entailment
def capture_moves(self, position): """ Finds out all possible capture moves :rtype: list """ try: right_diagonal = self.square_in_front(self.location.shift_right()) for move in self._one_diagonal_capture_square(right_diagonal, position): y...
Finds out all possible capture moves :rtype: list
entailment
def on_en_passant_valid_location(self): """ Finds out if pawn is on enemy center rank. :rtype: bool """ return (self.color == color.white and self.location.rank == 4) or \ (self.color == color.black and self.location.rank == 3)
Finds out if pawn is on enemy center rank. :rtype: bool
entailment
def _is_en_passant_valid(self, opponent_pawn_location, position): """ Finds if their opponent's pawn is next to this pawn :rtype: bool """ try: pawn = position.piece_at_square(opponent_pawn_location) return pawn is not None and \ isinstanc...
Finds if their opponent's pawn is next to this pawn :rtype: bool
entailment
def add_one_en_passant_move(self, direction, position): """ Yields en_passant moves in given direction if it is legal. :type: direction: function :type: position: Board :rtype: gen """ try: if self._is_en_passant_valid(direction(self.location), positi...
Yields en_passant moves in given direction if it is legal. :type: direction: function :type: position: Board :rtype: gen
entailment
def en_passant_moves(self, position): """ Finds possible en passant moves. :rtype: list """ # if pawn is not on a valid en passant get_location then return None if self.on_en_passant_valid_location(): for move in itertools.chain(self.add_one_en_passant_move(...
Finds possible en passant moves. :rtype: list
entailment
def possible_moves(self, position): """ Finds out the locations of possible moves given board.Board position. :pre get_location is on board and piece at specified get_location on position :type: position: Board :rtype: list """ for move in itertools.chain(self.fo...
Finds out the locations of possible moves given board.Board position. :pre get_location is on board and piece at specified get_location on position :type: position: Board :rtype: list
entailment
def main(): """ Main method """ print("Creating a new game...") new_game = Game(Human(color.white), Human(color.black)) result = new_game.play() print("Result is ", result)
Main method
entailment
def respond(text=None, ssml=None, attributes=None, reprompt_text=None, reprompt_ssml=None, end_session=True): """ Build a dict containing a valid response to an Alexa request. If speech output is desired, either of `text` or `ssml` should be specified. :param text: Plain text speech output...
Build a dict containing a valid response to an Alexa request. If speech output is desired, either of `text` or `ssml` should be specified. :param text: Plain text speech output to be said by Alexa device. :param ssml: Speech output in SSML form. :param attributes: Dictionary of attributes to store...
entailment
def reprompt(text=None, ssml=None, attributes=None): """Convenience method to save a little bit of typing for the common case of reprompting the user. Simply calls :py:func:`alexandra.util.respond` with the given arguments and holds the session open. One of either the `text` or `ssml` should be provide...
Convenience method to save a little bit of typing for the common case of reprompting the user. Simply calls :py:func:`alexandra.util.respond` with the given arguments and holds the session open. One of either the `text` or `ssml` should be provided if any speech output is desired. :param text: Pla...
entailment
def validate_request_timestamp(req_body, max_diff=150): """Ensure the request's timestamp doesn't fall outside of the app's specified tolerance. Returns True if this request is valid, False otherwise. :param req_body: JSON object parsed out of the raw POST data of a request. :param max_diff: Maxim...
Ensure the request's timestamp doesn't fall outside of the app's specified tolerance. Returns True if this request is valid, False otherwise. :param req_body: JSON object parsed out of the raw POST data of a request. :param max_diff: Maximum allowable difference in seconds between request time...
entailment
def validate_request_certificate(headers, data): """Ensure that the certificate and signature specified in the request headers are truely from Amazon and correctly verify. Returns True if certificate verification succeeds, False otherwise. :param headers: Dictionary (or sufficiently dictionary-like) m...
Ensure that the certificate and signature specified in the request headers are truely from Amazon and correctly verify. Returns True if certificate verification succeeds, False otherwise. :param headers: Dictionary (or sufficiently dictionary-like) map of request headers. :param data: Raw POST...
entailment
def _get_certificate(cert_url): """Download and validate a specified Amazon PEM file.""" global _cache if cert_url in _cache: cert = _cache[cert_url] if cert.has_expired(): _cache = {} else: return cert url = urlparse(cert_url) host = url.netloc.lowe...
Download and validate a specified Amazon PEM file.
entailment
def is_processed(self, db_versions): """Check if version is already applied in the database. :param db_versions: """ return self.number in (v.number for v in db_versions if v.date_done)
Check if version is already applied in the database. :param db_versions:
entailment
def is_noop(self): """Check if version is a no operation version. """ has_operations = [mode.pre_operations or mode.post_operations for mode in self._version_modes.values()] has_upgrade_addons = [mode.upgrade_addons or mode.remove_addons ...
Check if version is a no operation version.
entailment
def _get_version_mode(self, mode=None): """Return a VersionMode for a mode name. When the mode is None, we are working with the 'base' mode. """ version_mode = self._version_modes.get(mode) if not version_mode: version_mode = self._version_modes[mode] = VersionMode(n...
Return a VersionMode for a mode name. When the mode is None, we are working with the 'base' mode.
entailment
def add_operation(self, operation_type, operation, mode=None): """Add an operation to the version :param mode: Name of the mode in which the operation is executed :type mode: str :param operation_type: one of 'pre', 'post' :type operation_type: str :param operation: the ...
Add an operation to the version :param mode: Name of the mode in which the operation is executed :type mode: str :param operation_type: one of 'pre', 'post' :type operation_type: str :param operation: the operation to add :type operation: :class:`marabunta.model.Operatio...
entailment
def add_backup_operation(self, backup, mode=None): """Add a backup operation to the version. :param backup: To either add or skip the backup :type backup: Boolean :param mode: Name of the mode in which the operation is executed For now, backups are mode-independent ...
Add a backup operation to the version. :param backup: To either add or skip the backup :type backup: Boolean :param mode: Name of the mode in which the operation is executed For now, backups are mode-independent :type mode: String
entailment
def pre_operations(self, mode=None): """ Return pre-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.pre_operations
Return pre-operations only for the mode asked
entailment
def post_operations(self, mode=None): """ Return post-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.post_operations
Return post-operations only for the mode asked
entailment
def upgrade_addons_operation(self, addons_state, mode=None): """ Return merged set of main addons and mode's addons """ installed = set(a.name for a in addons_state if a.state in ('installed', 'to upgrade')) base_mode = self._get_version_mode() addons_list = base...
Return merged set of main addons and mode's addons
entailment
def copy(self): """ get copy of object :return: ReactionContainer """ return type(self)(reagents=[x.copy() for x in self.__reagents], meta=self.__meta.copy(), products=[x.copy() for x in self.__products], reactants=[x.copy() fo...
get copy of object :return: ReactionContainer
entailment
def implicify_hydrogens(self): """ remove explicit hydrogens if possible :return: number of removed hydrogens """ total = 0 for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'implicify_hydrogens'): ...
remove explicit hydrogens if possible :return: number of removed hydrogens
entailment
def reset_query_marks(self): """ set or reset hyb and neighbors marks to atoms. """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'reset_query_marks'): m.reset_query_marks() self.flush_ca...
set or reset hyb and neighbors marks to atoms.
entailment
def compose(self): """ get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer """ rr = self.__reagents + self.__reactants if rr: if not all(isinstance(x, (MoleculeContainer, CGRContainer)) for x in rr): ...
get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer
entailment
def calculate2d(self, force=True): """ recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: m.calculate...
recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms
entailment
def fix_positions(self): """ fix coordinates of molecules in reaction """ shift_x = 0 for m in self.__reactants: max_x = self.__fix_positions(m, shift_x, 0) shift_x = max_x + 1 arrow_min = shift_x if self.__reagents: for m in s...
fix coordinates of molecules in reaction
entailment
def get_role_keys(cls, unit_key): """ :param unit_key: Parent unit key :return: role keys of subunits """ stack = Role.objects.filter(unit_id=unit_key).values_list('key', flatten=True) for unit_key in cls.objects.filter(parent_id=unit_key).values_list('key', flatten=True)...
:param unit_key: Parent unit key :return: role keys of subunits
entailment
def get_permissions(self): """ Permissions of the user. Returns: List of Permission objects. """ user_role = self.last_login_role() if self.last_login_role_key else self.role_set[0].role return user_role.get_permissions()
Permissions of the user. Returns: List of Permission objects.
entailment
def get_permissions(self): """ Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri """ return [p.permission.code for p in self.Permissions if p.permission.code]
Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri
entailment
def add_permission(self, perm): """ Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object): """ self.Permissions(permission=perm) PermissionCache.flush() self.save()
Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object):
entailment
def add_permission_by_name(self, code, save=False): """ Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing. """ if not save: return ["%s | %s" % (p.name, p.code) for p in ...
Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing.
entailment
def send_notification(self, title, message, typ=1, url=None, sender=None): """ sends a message to user of this role's private mq exchange """ self.user.send_notification(title=title, message=message, typ=typ, url=url, sender=sender)
sends a message to user of this role's private mq exchange
entailment
def would_move_be_promotion(self): """ Finds if move from current location would be a promotion """ return (self._end_loc.rank == 0 and not self.color) or \ (self._end_loc.rank == 7 and self.color)
Finds if move from current location would be a promotion
entailment
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. ...
Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. If weak is True, then receiver must be weak referenceable. Receivers must b...
entailment
def disconnect(self, receiver=None, sender=None, dispatch_uid=None): """ Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver ...
Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver The registered receiver to disconnect. May be none if dispatch_uid i...
entailment
def migrate(config): """Perform a migration according to config. :param config: The configuration to be applied :type config: Config """ webapp = WebApp(config.web_host, config.web_port, custom_maintenance_file=config.web_custom_html) webserver = WebServer(webapp) webse...
Perform a migration according to config. :param config: The configuration to be applied :type config: Config
entailment
def main(): """Parse the command line and run :func:`migrate`.""" parser = get_args_parser() args = parser.parse_args() config = Config.from_parse_args(args) migrate(config)
Parse the command line and run :func:`migrate`.
entailment
def get_permissions(cls): """ Generates permissions for all CrudView based class methods. Returns: List of Permission objects. """ perms = [] for kls_name, kls in cls.registry.items(): for method_name in cls.__dict__.keys(): if met...
Generates permissions for all CrudView based class methods. Returns: List of Permission objects.
entailment
def _get_object_menu_models(): """ we need to create basic permissions for only CRUD enabled models """ from pyoko.conf import settings enabled_models = [] for entry in settings.OBJECT_MENU.values(): for mdl in entry: if 'wf' not in mdl: enabled_models.app...
we need to create basic permissions for only CRUD enabled models
entailment
def add(cls, code_name, name='', description=''): """ create a custom permission """ if code_name not in cls.registry: cls.registry[code_name] = (code_name, name or code_name, description) return code_name
create a custom permission
entailment
def get_mapping(self, other): """ get self to other mapping """ m = next(self._matcher(other).isomorphisms_iter(), None) if m: return {v: k for k, v in m.items()}
get self to other mapping
entailment
def get_substructure_mapping(self, other, limit=1): """ get self to other substructure mapping :param limit: number of matches. if 0 return iterator for all possible; if 1 return dict or None; if > 1 return list of dicts """ i = self._matcher(other).subgraph_isomorph...
get self to other substructure mapping :param limit: number of matches. if 0 return iterator for all possible; if 1 return dict or None; if > 1 return list of dicts
entailment
def from_string(cls, alg_str): """ Creates a location from a two character string consisting of the file then rank written in algebraic notation. Examples: e4, b5, a7 :type: alg_str: str :rtype: Location """ try: return cls(int(alg_s...
Creates a location from a two character string consisting of the file then rank written in algebraic notation. Examples: e4, b5, a7 :type: alg_str: str :rtype: Location
entailment
def shift(self, direction): """ Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location """ try: if direction == Direction.UP: return self.shift_up() elif direction == Direction.DOWN: ...
Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location
entailment
def shift_up(self, times=1): """ Finds Location shifted up by 1 :rtype: Location """ try: return Location(self._rank + times, self._file) except IndexError as e: raise IndexError(e)
Finds Location shifted up by 1 :rtype: Location
entailment
def shift_down(self, times=1): """ Finds Location shifted down by 1 :rtype: Location """ try: return Location(self._rank - times, self._file) except IndexError as e: raise IndexError(e)
Finds Location shifted down by 1 :rtype: Location
entailment
def shift_right(self, times=1): """ Finds Location shifted right by 1 :rtype: Location """ try: return Location(self._rank, self._file + times) except IndexError as e: raise IndexError(e)
Finds Location shifted right by 1 :rtype: Location
entailment
def shift_left(self, times=1): """ Finds Location shifted left by 1 :rtype: Location """ try: return Location(self._rank, self._file - times) except IndexError as e: raise IndexError(e)
Finds Location shifted left by 1 :rtype: Location
entailment
def shift_up_right(self, times=1): """ Finds Location shifted up right by 1 :rtype: Location """ try: return Location(self._rank + times, self._file + times) except IndexError as e: raise IndexError(e)
Finds Location shifted up right by 1 :rtype: Location
entailment
def shift_up_left(self, times=1): """ Finds Location shifted up left by 1 :rtype: Location """ try: return Location(self._rank + times, self._file - times) except IndexError as e: raise IndexError(e)
Finds Location shifted up left by 1 :rtype: Location
entailment
def shift_down_right(self, times=1): """ Finds Location shifted down right by 1 :rtype: Location """ try: return Location(self._rank - times, self._file + times) except IndexError as e: raise IndexError(e)
Finds Location shifted down right by 1 :rtype: Location
entailment
def shift_down_left(self, times=1): """ Finds Location shifted down left by 1 :rtype: Location """ try: return Location(self._rank - times, self._file - times) except IndexError as e: raise IndexError(e)
Finds Location shifted down left by 1 :rtype: Location
entailment
def standardize(self): """ standardize functional groups :return: number of found groups """ self.reset_query_marks() seen = set() total = 0 for n, atom in self.atoms(): if n in seen: continue for k, center in centr...
standardize functional groups :return: number of found groups
entailment
def get_staged_files(): """Get all files staged for the current commit. """ proc = subprocess.Popen(('git', 'status', '--porcelain'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = proc.communicate() staged_files = modified_re.findall...
Get all files staged for the current commit.
entailment
def runserver(host=None, port=None): """ Run Tornado server """ host = host or os.getenv('HTTP_HOST', '0.0.0.0') port = port or os.getenv('HTTP_PORT', '9001') zioloop = ioloop.IOLoop.instance() # setup pika client: pc = QueueManager(zioloop) app.pc = pc pc.connect() app.list...
Run Tornado server
entailment
def open(self): """ Called on new websocket connection. """ sess_id = self._get_sess_id() if sess_id: self.application.pc.websockets[self._get_sess_id()] = self self.write_message(json.dumps({"cmd": "status", "status": "open"})) else: s...
Called on new websocket connection.
entailment
def on_message(self, message): """ called on new websocket message, """ log.debug("WS MSG for %s: %s" % (self._get_sess_id(), message)) self.application.pc.redirect_incoming_message(self._get_sess_id(), message, self.request)
called on new websocket message,
entailment
def _handle_headers(self): """ Do response processing """ origin = self.request.headers.get('Origin') if not settings.DEBUG: if origin in settings.ALLOWED_ORIGINS or not origin: self.set_header('Access-Control-Allow-Origin', origin) else: ...
Do response processing
entailment
def post(self, view_name): """ login handler """ sess_id = None input_data = {} # try: self._handle_headers() # handle input input_data = json_decode(self.request.body) if self.request.body else {} input_data['path'] = view_name #...
login handler
entailment
def load_formatter_fn(formatter): ''' >>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...> ''' obj = util.load_object(formatter) if not hasattr(obj, 'ispartial'): obj.ispartial = util.ispartial return obj
>>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...>
entailment
def _remove_redundancy(self, log): """Removes duplicate data from 'data' inside log dict and brings it out. >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> log = {'id' : 46846876, 'type' : 'log', ... 'data' : {'a' : 1, ...
Removes duplicate data from 'data' inside log dict and brings it out. >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> log = {'id' : 46846876, 'type' : 'log', ... 'data' : {'a' : 1, 'b' : 2, 'type' : 'metric'}} >>> lc._r...
entailment
def validate_log_format(self, log): ''' >>> lc = LogCollector('file=/path/to/file.log:formatter=logagg.formatters.basescript', 30) >>> incomplete_log = {'data' : {'x' : 1, 'y' : 2}, ... 'raw' : 'Not all keys present'} >>> lc.validate_log_format(incomplete_log...
>>> lc = LogCollector('file=/path/to/file.log:formatter=logagg.formatters.basescript', 30) >>> incomplete_log = {'data' : {'x' : 1, 'y' : 2}, ... 'raw' : 'Not all keys present'} >>> lc.validate_log_format(incomplete_log) 'failed' >>> redundant_log = {'one_in...
entailment
def assign_default_log_values(self, fpath, line, formatter): ''' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> from pprint import pprint >>> formatter = 'logagg.formatters.mongodb' >>> fpath = '/var/log/mongodb/mongodb.log' ...
>>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> from pprint import pprint >>> formatter = 'logagg.formatters.mongodb' >>> fpath = '/var/log/mongodb/mongodb.log' >>> line = 'some log line here' >>> default_log = lc.assign_defaul...
entailment
def _scan_fpatterns(self, state): ''' For a list of given fpatterns, this starts a thread collecting log lines from file >>> os.path.isfile = lambda path: path == '/path/to/log_file.log' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 3...
For a list of given fpatterns, this starts a thread collecting log lines from file >>> os.path.isfile = lambda path: path == '/path/to/log_file.log' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> print(lc.fpaths) file=/path/to...
entailment
def get_links(self, **kw): """ Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts """ links = [a for a in dir(self) if isinstance(getattr(self, a), Model) and not a.startswith('_mode...
Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts
entailment
def set_data(self, data): """ Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object. """ for name in self._fields: setattr(self, name, data.get(name)) return self
Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object.
entailment
def serialize(self): """ Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { ...
Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { "code": null, ...
entailment
def _cache_form_details(self, form): """ Caches some form details to lates process and validate incoming (response) form data Args: form: form dict """ cache = FormCache() form['model']['form_key'] = cache.form_id form['model']['form_name'] = self.__c...
Caches some form details to lates process and validate incoming (response) form data Args: form: form dict
entailment
def _parse_msg_for_mongodb(self, msgs): ''' >>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
>>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... u'ln': 8, ... u'name...
entailment
def _tag_and_field_maker(self, event): ''' >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
>>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... u'ln': 8, ... ...
entailment
def _parse_msg_for_influxdb(self, msgs): ''' >>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': ...
>>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': 'CXNS CNS nbkbsd', ... u'a': 1, ....
entailment
def get_input(source, files, threads=4, readtype="1D", combine="simple", names=None, barcoded=False): """Get input and process accordingly. Data can be: - a uncompressed, bgzip, bzip2 or gzip compressed fastq file - a uncompressed, bgzip, bzip2 or gzip compressed fasta file - a rich f...
Get input and process accordingly. Data can be: - a uncompressed, bgzip, bzip2 or gzip compressed fastq file - a uncompressed, bgzip, bzip2 or gzip compressed fasta file - a rich fastq containing additional key=value information in the description, as produced by MinKNOW and albacore with the sam...
entailment
def combine_dfs(dfs, names, method): """Combine dataframes. Combination is either done simple by just concatenating the DataFrames or performs tracking by adding the name of the dataset as a column.""" if method == "track": res = list() for df, identifier in zip(dfs, names): ...
Combine dataframes. Combination is either done simple by just concatenating the DataFrames or performs tracking by adding the name of the dataset as a column.
entailment
def calculate_start_time(df): """Calculate the star_time per read. Time data is either a "time" (in seconds, derived from summary files) or a "timestamp" (in UTC, derived from fastq_rich format) and has to be converted appropriately in a datetime format time_arr For both the time_zero is the m...
Calculate the star_time per read. Time data is either a "time" (in seconds, derived from summary files) or a "timestamp" (in UTC, derived from fastq_rich format) and has to be converted appropriately in a datetime format time_arr For both the time_zero is the minimal value of the time_arr, whi...
entailment
def parser_from_buffer(cls, fp): """Construct YamlParser from a file pointer.""" yaml = YAML(typ="safe") return cls(yaml.load(fp))
Construct YamlParser from a file pointer.
entailment