text
stringlengths
81
112k
Initialize a CompareReturn object from a json dictionary. def _from_dict(cls, _dict): """Initialize a CompareReturn object from a json dictionary.""" args = {} if 'model_id' in _dict: args['model_id'] = _dict.get('model_id') if 'model_version' in _dict: args['mod...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'model_id') and self.model_id is not None: _dict['model_id'] = self.model_id if hasattr(self, 'model_version') and self.m...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name if hasattr(self, 'role') and self.role is not None: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'total') and self.total is not None: _dict['total'] = self.total if hasattr(self, 'pending') and self.pending is not None...
Initialize a DocStructure object from a json dictionary. def _from_dict(cls, _dict): """Initialize a DocStructure object from a json dictionary.""" args = {} if 'section_titles' in _dict: args['section_titles'] = [ SectionTitles._from_dict(x) for x in...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'section_titles') and self.section_titles is not None: _dict['section_titles'] = [ x._to_dict() for x in self.sec...
Initialize a Element object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Element object from a json dictionary.""" args = {} if 'location' in _dict: args['location'] = Location._from_dict(_dict.get('location')) if 'text' in _dict: args['tex...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'begin') and self.begin is not None: _dict['begin'] = self.begin if hasattr(self, 'end') and self.end is not None: ...
Initialize a FeedbackDataInput object from a json dictionary. def _from_dict(cls, _dict): """Initialize a FeedbackDataInput object from a json dictionary.""" args = {} if 'feedback_type' in _dict: args['feedback_type'] = _dict.get('feedback_type') else: raise Val...
Initialize a FeedbackDataOutput object from a json dictionary. def _from_dict(cls, _dict): """Initialize a FeedbackDataOutput object from a json dictionary.""" args = {} if 'feedback_type' in _dict: args['feedback_type'] = _dict.get('feedback_type') if 'document' in _dict: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'feedback_type') and self.feedback_type is not None: _dict['feedback_type'] = self.feedback_type if hasattr(self, 'docume...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'status') and self.status is not None: _dict['status'] = self.status if hasattr(self, 'message') and self.message is not ...
Initialize a FeedbackList object from a json dictionary. def _from_dict(cls, _dict): """Initialize a FeedbackList object from a json dictionary.""" args = {} if 'feedback' in _dict: args['feedback'] = [ GetFeedback._from_dict(x) for x in (_dict.get('feedback')) ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'feedback') and self.feedback is not None: _dict['feedback'] = [x._to_dict() for x in self.feedback] return _dict
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'feedback_id') and self.feedback_id is not None: _dict['feedback_id'] = self.feedback_id if hasattr(self, 'user_id') and ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'num_pages') and self.num_pages is not None: _dict['num_pages'] = self.num_pages if hasattr(self, 'author') and self.auth...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'cell_id') and self.cell_id is not None: _dict['cell_id'] = self.cell_id if hasattr(self, 'location') and self.location i...
Initialize a KeyValuePair object from a json dictionary. def _from_dict(cls, _dict): """Initialize a KeyValuePair object from a json dictionary.""" args = {} if 'key' in _dict: args['key'] = Key._from_dict(_dict.get('key')) if 'value' in _dict: args['value'] = Va...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'key') and self.key is not None: _dict['key'] = self.key._to_dict() if hasattr(self, 'value') and self.value is not None:...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'nature') and self.nature is not None: _dict['nature'] = self.nature if hasattr(self, 'party') and self.party is not None...
Initialize a LeadingSentence object from a json dictionary. def _from_dict(cls, _dict): """Initialize a LeadingSentence object from a json dictionary.""" args = {} if 'text' in _dict: args['text'] = _dict.get('text') if 'location' in _dict: args['location'] = Loc...
Initialize a OriginalLabelsIn object from a json dictionary. def _from_dict(cls, _dict): """Initialize a OriginalLabelsIn object from a json dictionary.""" args = {} if 'types' in _dict: args['types'] = [ TypeLabel._from_dict(x) for x in (_dict.get('types')) ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'types') and self.types is not None: _dict['types'] = [x._to_dict() for x in self.types] if hasattr(self, 'categories') a...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'refresh_cursor') and self.refresh_cursor is not None: _dict['refresh_cursor'] = self.refresh_cursor if hasattr(self, 'ne...
Initialize a Parties object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Parties object from a json dictionary.""" args = {} if 'party' in _dict: args['party'] = _dict.get('party') if 'importance' in _dict: args['importance'] = _dict.get('i...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'party') and self.party is not None: _dict['party'] = self.party if hasattr(self, 'importance') and self.importance is no...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'text') and self.text is not None: _dict['text'] = self.text if hasattr(self, 'location') and self.location is not None: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'title') and self.title is not None: _dict['title'] = self.title if hasattr(self, 'hash') and self.hash is not None: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'cell_id') and self.cell_id is not None: _dict['cell_id'] = self.cell_id if hasattr(self, 'location') and self.location i...
Initialize a TableReturn object from a json dictionary. def _from_dict(cls, _dict): """Initialize a TableReturn object from a json dictionary.""" args = {} if 'document' in _dict: args['document'] = DocInfo._from_dict(_dict.get('document')) if 'model_id' in _dict: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'document') and self.document is not None: _dict['document'] = self.document._to_dict() if hasattr(self, 'model_id') and ...
Initialize a Tables object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Tables object from a json dictionary.""" args = {} if 'location' in _dict: args['location'] = Location._from_dict(_dict.get('location')) if 'text' in _dict: args['text'...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'location') and self.location is not None: _dict['location'] = self.location._to_dict() if hasattr(self, 'text') and self...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'label') and self.label is not None: _dict['label'] = self.label._to_dict() return _dict
Initialize a UnalignedElement object from a json dictionary. def _from_dict(cls, _dict): """Initialize a UnalignedElement object from a json dictionary.""" args = {} if 'document_label' in _dict: args['document_label'] = _dict.get('document_label') if 'location' in _dict: ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'document_label') and self.document_label is not None: _dict['document_label'] = self.document_label if hasattr(self, 'lo...
Sends audio for speech recognition using web sockets. :param AudioSource audio: The audio to transcribe in the format specified by the `Content-Type` header. :param str content_type: The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg...
Sends the text message Note: The service handles one request per connection def send_text(self): """ Sends the text message Note: The service handles one request per connection """ def run(*args): """Background process to send the text""" self.ws_...
Callback executed when message is received from the server. :param ws: Websocket client :param message: utf-8 string which we get from the server. :param message_type: Message type which is either ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY :param fin: continue flag. If 0, the data continues...
Send message to server. data: message to send. If you set opcode to OPCODE_TEXT, data must be utf-8 string or unicode. opcode: operation code of data. default is OPCODE_TEXT. def send(self, data, opcode=websocket.ABNF.OPCODE_TEXT): """ Send message to server. dat...
Stream audio to server :param ws: Websocket client def send_audio(self, ws): """ Stream audio to server :param ws: Websocket client """ def run(*args): """Background process to stream the data""" if not self.audio_source.is_buffer: ...
Callback executed when a connection is opened to the server. Handles streaming of audio to the server. :param ws: Websocket client def on_open(self, ws): """ Callback executed when a connection is opened to the server. Handles streaming of audio to the server. :param w...
Callback executed when message is received from the server. :param ws: Websocket client :param message: utf-8 string which we get from the server. :param message_type: Message type which is either ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY :param fin: continue flag. If 0, the data continues...
Get profile. Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input content, but it requires much less text to produce an accurate profile. The service can analyze text in Arabic, English, Japanese, Korean, or Spanish. It can re...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'trait_id') and self.trait_id is not None: _dict['trait_id'] = self.trait_id if hasattr(self, 'name') and self.name is no...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'consumption_preference_id' ) and self.consumption_preference_id is not None: _dict['consumption_preference_id'...
Initialize a ConsumptionPreferencesCategory object from a json dictionary. def _from_dict(cls, _dict): """Initialize a ConsumptionPreferencesCategory object from a json dictionary.""" args = {} if 'consumption_preference_category_id' in _dict: args['consumption_preference_category_i...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'consumption_preference_category_id' ) and self.consumption_preference_category_id is not None: _dict[ ...
Initialize a Content object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Content object from a json dictionary.""" args = {} if 'contentItems' in _dict: args['content_items'] = [ ContentItem._from_dict(x) for x in (_dict.get('contentItems')) ...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'content_items') and self.content_items is not None: _dict['contentItems'] = [x._to_dict() for x in self.content_items] r...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'content') and self.content is not None: _dict['content'] = self.content if hasattr(self, 'id') and self.id is not None: ...
Initialize a Profile object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Profile object from a json dictionary.""" args = {} if 'processed_language' in _dict: args['processed_language'] = _dict.get('processed_language') else: raise ValueErr...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr( self, 'processed_language') and self.processed_language is not None: _dict['processed_language'] = sel...
Initialize a Trait object from a json dictionary. def _from_dict(cls, _dict): """Initialize a Trait object from a json dictionary.""" args = {} if 'trait_id' in _dict: args['trait_id'] = _dict.get('trait_id') else: raise ValueError( 'Required prop...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'trait_id') and self.trait_id is not None: _dict['trait_id'] = self.trait_id if hasattr(self, 'name') and self.name is no...
Return a json dictionary representing this model. def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'warning_id') and self.warning_id is not None: _dict['warning_id'] = self.warning_id if hasattr(self, 'message') and self...
Delete all chunks for a symbol. Which are, for the moment, fully contained in the passed in date_range. Parameters ---------- symbol : `str` symbol name for the item date_range : `date.DateRange` DateRange to delete ticks in def delete(self, sym...
Return the mongo read preference given an 'allow_secondary' argument def _read_preference(self, allow_secondary): """ Return the mongo read preference given an 'allow_secondary' argument """ allow_secondary = self._allow_secondary if allow_secondary is None else allow_secondary return R...
Read data for the named symbol. Returns a VersionedItem object with a data and metdata element (as passed into write). Parameters ---------- symbol : `str` symbol name for the item date_range : `date.DateRange` Returns ticks in the specified DateRange ...
Writes a list of market data events. Parameters ---------- symbol : `str` symbol name for the item data : list of dicts or a pandas.DataFrame List of ticks to store to the tick-store. if a list of dicts, each dict must contain a 'index' datetime ...
Represent dtypes without byte order, as earlier Java tickstore code doesn't support explicit byte order. def _str_dtype(dtype): """ Represent dtypes without byte order, as earlier Java tickstore code doesn't support explicit byte order. """ assert dtype.byteorder != '>' if dtype...
Return the maximum datetime stored for a particular symbol Parameters ---------- symbol : `str` symbol name for the item def max_date(self, symbol): """ Return the maximum datetime stored for a particular symbol Parameters ---------- symbol ...
Return the minimum datetime stored for a particular symbol Parameters ---------- symbol : `str` symbol name for the item def min_date(self, symbol): """ Return the minimum datetime stored for a particular symbol Parameters ---------- symbol ...
pass thru chunker of the dataframe/series returns ------- ('NA', 'NA', 'NA', dataframe/series) def to_chunks(self, df, **kwargs): """ pass thru chunker of the dataframe/series returns ------- ('NA', 'NA', 'NA', dataframe/series) """ if l...
Return True / False on authentication success. PyMongo 2.6 changed the auth API to raise on Auth failure. def authenticate(db, user, password): """ Return True / False on authentication success. PyMongo 2.6 changed the auth API to raise on Auth failure. """ try: logger.debug("Authenti...
Authentication hook to allow plugging in custom authentication credential providers def get_auth(host, app_name, database_name): """ Authentication hook to allow plugging in custom authentication credential providers """ from .hooks import _get_auth_hook return _get_auth_hook(host, app_name, databa...
Returns a mongo library for the given connection string Parameters --------- connection_string: `str` Format must be one of the following: library@trading for known mongo servers library@hostname:port Returns: -------- Arctic library def get_arctic_lib(connecti...
Attempts to authenticate against the mongo instance. Tries: - Auth'ing against admin as 'admin' ; credentials: <host>/arctic/admin/admin - Auth'ing against db_name (which may be None if auth'ing against admin above) returns True if authentication succeeded. def do_db_auth(host, connection, db_nam...
External exception logging hook. def log_exception(fn_name, exception, retry_count, **kwargs): """ External exception logging hook. """ _log_exception_hook(fn_name, exception, retry_count, **kwargs)
Dataframe group-by operation that supports aggregating by different methods on the index. Parameters ---------- df: ``DataFrame`` Pandas dataframe with a MultiIndex grouping_level: ``int`` or ``str`` or ``list`` of ``str`` Index level to group by. Defaults to 0. aggregate_level: ``i...
Common use case for selecting the latest rows from a bitemporal dataframe as-of a certain date. Parameters ---------- df: ``pd.DataFrame`` Dataframe with a MultiIndex index as_of: ``datetime`` Return a timeseries with values observed <= this as-of date. By default, the latest observed ...
Return a new dataframe with a row inserted for a multi-index dataframe. This will sort the rows according to the ordered multi-index levels. def multi_index_insert_row(df, index_row, values_row): """ Return a new dataframe with a row inserted for a multi-index dataframe. This will sort the rows acc...
Insert some values into a bi-temporal dataframe. This is like what would happen when we get a price correction. def insert_at(df, sample_date, values): """ Insert some values into a bi-temporal dataframe. This is like what would happen when we get a price correction. """ observed_dt = dt(da...
Register a Arctic Library Type handler def register_library_type(name, type_): """ Register a Arctic Library Type handler """ if name in LIBRARY_TYPES: raise ArcticException("Library %s already registered as %s" % (name, LIBRARY_TYPES[name])) LIBRARY_TYPES[name] = type_
Returns ------- List of Arctic library names from a cached collection (global per mongo cluster) in mongo. Long term list_libraries should have a use_cached argument. def _list_libraries_cached(self, newer_than_secs=-1): """ Returns ------- List of Arctic library...
Check whether a given library exists. Parameters ---------- library : `str` The name of the library. e.g. 'library' or 'user.library' Returns ------- `bool` True if the library with the given name already exists, False otherwise def library_exis...
Create an Arctic Library or a particular type. Parameters ---------- library : `str` The name of the library. e.g. 'library' or 'user.library' lib_type : `str` The type of the library. e.g. arctic.VERSION_STORE or arctic.TICK_STORE Or any type regis...
Delete an Arctic Library, and all associated collections in the MongoDB. Parameters ---------- library : `str` The name of the library. e.g. 'library' or 'user.library' def delete_library(self, library): """ Delete an Arctic Library, and all associated collections i...
Return the library instance. Can generally use slicing to return the library: arctic_store[library] Parameters ---------- library : `str` The name of the library. e.g. 'library' or 'user.library' def get_library(self, library): """ Return the library in...
Renames a library Parameters ---------- from_lib: str The name of the library to be renamed to_lib: str The new name of the library def rename_library(self, from_lib, to_lib): """ Renames a library Parameters ---------- f...
Returns the canonical (database_name, library) for the passed in string 'library'. def _parse_db_lib(cls, library): """ Returns the canonical (database_name, library) for the passed in string 'library'. """ database_name = library.split('.', 2) if len(database_na...
Set a quota (in bytes) on this user library. The quota is 'best effort', and should be set conservatively. A quota of 0 is 'unlimited' def set_quota(self, quota_bytes): """ Set a quota (in bytes) on this user library. The quota is 'best effort', and should be set conservative...
Check whether the user is within quota. Should be called before every write. Will raise() if the library has exceeded its allotted quota. def check_quota(self): """ Check whether the user is within quota. Should be called before every write. Will raise() if the library has e...
Checksum the passed in dictionary def _checksum(self, fields, data): """ Checksum the passed in dictionary """ sha = hashlib.sha1() for field in fields: sha.update(field) sha.update(data) return Binary(sha.digest())
Delete all chunks for a symbol, or optionally, chunks within a range Parameters ---------- symbol : str symbol name for the item chunk_range: range object a date range to delete audit: dict dict to store in the audit log def delete(self, symb...
Returns all symbols in the library Parameters ---------- partial: None or str if not none, use this string to do a partial match on symbol names Returns ------- list of str def list_symbols(self, partial_match=None): """ Returns all symbols ...
Rename a symbol Parameters ---------- from_symbol: str the existing symbol that will be renamed to_symbol: str the new symbol name audit: dict audit information def rename(self, from_symbol, to_symbol, audit=None): """ Rename ...
Reads data for a given symbol from the database. Parameters ---------- symbol: str, or list of str the symbol(s) to retrieve chunk_range: object corresponding range object for the specified chunker (for DateChunker it is a DateRange object or a Dateti...
Reads the audit log Parameters ---------- symbol: str optionally only retrieve specific symbol's audit information Returns ------- list of dicts def read_audit_log(self, symbol=None): """ Reads the audit log Parameters -----...
Writes data from item to symbol in the database Parameters ---------- symbol: str the symbol that will be used to reference the written data item: Dataframe or Series the data to write the database metadata: ? optional per symbol metadata ...
helper method used by update and append since they very closely resemble eachother. Really differ only by the combine method. append will combine existing date with new data (within a chunk), whereas update will replace existing data with new data (within a chunk). def __update(self, sy...
Appends data from item to symbol's data in the database. Is not idempotent Parameters ---------- symbol: str the symbol for the given item in the DB item: DataFrame or Series the data to append upsert: write data if symbol does not ex...
Overwrites data in DB with data in item for the given symbol. Is idempotent Parameters ---------- symbol: str the symbol for the given item in the DB item: DataFrame or Series the data to update metadata: ? optional per symbol metadat...
Returns information about the symbol, in a dictionary Parameters ---------- symbol: str the symbol for the given item in the DB Returns ------- dictionary def get_info(self, symbol): """ Returns information about the symbol, in a dictionary ...
Reads user defined metadata out for the given symbol Parameters ---------- symbol: str symbol for the given item in the DB Returns ------- ? def read_metadata(self, symbol): ''' Reads user defined metadata out for the given symbol P...
writes user defined metadata for the given symbol Parameters ---------- symbol: str symbol for the given item in the DB metadata: ? metadata to write def write_metadata(self, symbol, metadata): ''' writes user defined metadata for the given symbo...
Returns a generator of (Start, End) tuples for each chunk in the symbol Parameters ---------- symbol: str the symbol for the given item in the DB chunk_range: None, or a range object allows you to subset the chunks by range reverse: boolean re...
Returns a generator that accesses each chunk in ascending order Parameters ---------- symbol: str the symbol for the given item in the DB chunk_range: None, or a range object allows you to subset the chunks by range Returns ------- genera...
Returns a generator that accesses each chunk in descending order Parameters ---------- symbol: str the symbol for the given item in the DB chunk_range: None, or a range object allows you to subset the chunks by range Returns ------- gener...
Catch-all decorator that handles AutoReconnect and OperationFailure errors from PyMongo def mongo_retry(f): """ Catch-all decorator that handles AutoReconnect and OperationFailure errors from PyMongo """ log_all_exceptions = 'arctic' in f.__module__ if f.__module__ else False @wraps(f) ...