INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Find rule_id for incoming action_id and return AuthConstraint instance | def get_auth_constraint(self, action_id: str) -> AbstractAuthConstraint:
"""
Find rule_id for incoming action_id and return AuthConstraint instance
"""
if self.anyone_can_write_map:
return self._find_auth_constraint(action_id, self.anyone_can_write_map, from_local=True)
... |
Appends event to log Be careful it opens file every time! | def _append(self, ev_type: Enum, data: ActionLogData) -> None:
"""
Appends event to log
Be careful it opens file every time!
"""
event = ActionLogEvent(None, ev_type, data, types=self._event_types)
with open(self._file_path, mode='a+', newline='') as f:
f.writ... |
The state trie stores the hash of the whole attribute data at: the did + attribute name if the data is plaintext ( RAW ) the did + hash ( attribute ) if the data is encrypted ( ENC ) If the attribute is HASH then nothing is stored in attribute store the trie stores a blank value for the key did + hash | def update_state(self, txn, prev_result, is_committed=True) -> None:
"""
The state trie stores the hash of the whole attribute data at:
the did+attribute name if the data is plaintext (RAW)
the did+hash(attribute) if the data is encrypted (ENC)
If the attribute is HASH, t... |
depends on config | def create_auth_strategy(self):
"""depends on config"""
if self.config.authPolicy == LOCAL_AUTH_POLICY:
return LocalAuthStrategy(auth_map=self.auth_map,
anyone_can_write_map=self.anyone_can_write_map if self.anyone_can_write else None)
elif self.c... |
Return path to state as str type or None | def gen_txn_path(self, txn):
"""Return path to state as 'str' type or None"""
txn_type = get_type(txn)
if txn_type not in self.state_update_handlers:
logger.error('Cannot generate id for txn of type {}'.format(txn_type))
return None
if txn_type == NYM:
... |
For getting reply we need: 1. Get REVOC_REG_ENTRY by TO timestamp from state 2. If FROM is given in request then Get REVOC_REG_ENTRY by FROM timestamp from state 3. Get ISSUANCE_TYPE for REVOC_REG_DEF ( revoked/ issued strategy ) 4. Compute issued and revoked indices by corresponding strategy 5. Make result 5. 1 Now if... | def handleGetRevocRegDelta(self, request: Request):
"""
For getting reply we need:
1. Get REVOC_REG_ENTRY by "TO" timestamp from state
2. If FROM is given in request, then Get REVOC_REG_ENTRY by "FROM" timestamp from state
3. Get ISSUANCE_TYPE for REVOC_REG_DEF (revoked/issued st... |
Queries state for data on specified path | def lookup(self, path, isCommitted=True, with_proof=False) -> (str, int):
"""
Queries state for data on specified path
:param path: path to data
:param isCommitted: queries the committed state root if True else the uncommitted root
:param with_proof: creates proof if True
... |
The state trie stores the hash of the whole attribute data at: the did + attribute name if the data is plaintext ( RAW ) the did + hash ( attribute ) if the data is encrypted ( ENC ) If the attribute is HASH then nothing is stored in attribute store the trie stores a blank value for the key did + hash | def _addAttr(self, txn, isCommitted=False) -> None:
"""
The state trie stores the hash of the whole attribute data at:
the did+attribute name if the data is plaintext (RAW)
the did+hash(attribute) if the data is encrypted (ENC)
If the attribute is HASH, then nothing is st... |
Some transactions need to be transformed before they can be stored in the ledger eg. storing certain payload in another data store and only its hash in the ledger | def transform_txn_for_ledger(txn):
"""
Some transactions need to be transformed before they can be stored in the
ledger, eg. storing certain payload in another data store and only its
hash in the ledger
"""
if get_type(txn) == ATTRIB:
txn = DomainReqHandler.tr... |
Creating copy of result so that RAW ENC or HASH can be replaced by their hashes. We do not insert actual attribute data in the ledger but only the hash of it. | def transform_attrib_for_ledger(txn):
"""
Creating copy of result so that `RAW`, `ENC` or `HASH` can be
replaced by their hashes. We do not insert actual attribute data
in the ledger but only the hash of it.
"""
txn = deepcopy(txn)
txn_data = get_payload_data(txn)... |
Encrypt the provided value with symmetric encryption | def getSymmetricallyEncryptedVal(val, secretKey: Union[str, bytes] = None) -> \
Tuple[str, str]:
"""
Encrypt the provided value with symmetric encryption
:param val: the value to encrypt
:param secretKey: Optional key, if provided should be either in hex or bytes
:return: Tuple of the encry... |
Finds the index of an item in list which satisfies predicate: param predicateFn: predicate function to run on items of list: param items: list of tuples: return: first index for which predicate function returns True | def getIndex(predicateFn: Callable[[T], bool], items: List[T]) -> int:
"""
Finds the index of an item in list, which satisfies predicate
:param predicateFn: predicate function to run on items of list
:param items: list of tuples
:return: first index for which predicate function returns True
"""
... |
Create base transactions | def setupTxns(self, key, force: bool = False):
"""
Create base transactions
:param key: ledger
:param force: replace existing transaction files
"""
import data
dataDir = os.path.dirname(data.__file__)
# TODO: Need to get "test" and "live" from ENVS prope... |
Check if an image with a given tag exists. No side - effects. Idempotent. Handles ImageNotFound and APIError exceptions but only reraises APIError. | def getImageByTag(tag):
'''Check if an image with a given tag exists. No side-effects. Idempotent.
Handles ImageNotFound and APIError exceptions, but only reraises APIError.
'''
require_str("tag", tag)
image = None
try:
image = client.images.get(tag)
print("Found image", tag, ".... |
Check if an image with a given tag exists. If not build an image from using a given dockerfile in a given path tagging it with a given tag. No extra side effects. Handles and reraises BuildError TypeError and APIError exceptions. | def getImage(path, dockerfile, tag):
'''Check if an image with a given tag exists. If not, build an image from
using a given dockerfile in a given path, tagging it with a given tag.
No extra side effects. Handles and reraises BuildError, TypeError, and
APIError exceptions.
'''
image = getImageBy... |
Run a docker container using a given image ; passing keyword arguments documented to be accepted by docker s client. containers. run function No extra side effects. Handles and reraises ContainerError ImageNotFound and APIError exceptions. | def runContainer(image, **kwargs):
'''Run a docker container using a given image; passing keyword arguments
documented to be accepted by docker's client.containers.run function
No extra side effects. Handles and reraises ContainerError, ImageNotFound,
and APIError exceptions.
'''
container = Non... |
Get the container with the given name or ID ( str ). No side effects. Idempotent. Returns None if the container does not exist. Otherwise the continer is returned | def getContainer(name_or_id):
'''Get the container with the given name or ID (str). No side effects.
Idempotent. Returns None if the container does not exist. Otherwise, the
continer is returned'''
require_str("name_or_id", name_or_id)
container = None
try:
container = client.containers... |
Check if container with the given name or ID ( str ) is running. No side effects. Idempotent. Returns True if running False if not. | def containerIsRunning(name_or_id):
'''Check if container with the given name or ID (str) is running. No side
effects. Idempotent. Returns True if running, False if not.'''
require_str("name_or_id", name_or_id)
try:
container = getContainer(name_or_id)
# Refer to the latest status list ... |
Check if a container with a given tag exists. No side - effects. Idempotent. Handles NotFound and APIError exceptions but only reraises APIError. Returns None if the container is not found. Otherwise returns the container. | def getContainerByTag(tag):
'''Check if a container with a given tag exists. No side-effects.
Idempotent. Handles NotFound and APIError exceptions, but only reraises
APIError. Returns None if the container is not found. Otherwise, returns the
container.'''
require_str("tag", tag)
container = No... |
Check if a container with a given tag exists. Kill it if it exists. No extra side effects. Handles and reraises TypeError and APIError exceptions. | def removeContainer(tag):
'''Check if a container with a given tag exists. Kill it if it exists.
No extra side effects. Handles and reraises TypeError, and
APIError exceptions.
'''
container = getContainerByTag(tag)
if container:
# Build an Image using the dockerfile in the path
... |
Start the indy_pool docker container iff it is not already running. See <indy - sdk >/ ci/ indy - pool. dockerfile for details. Idempotent. Simply ensures that the indy_pool container is up and running. | def startIndyPool(**kwargs):
'''Start the indy_pool docker container iff it is not already running. See
<indy-sdk>/ci/indy-pool.dockerfile for details. Idempotent. Simply ensures
that the indy_pool container is up and running.'''
# TODO: Decide if we need a separate docker container for testing and one... |
Restart the indy_pool docker container. Idempotent. Ensures that the indy_pool container is a new running instance. | def restartIndyPool(**kwargs):
'''Restart the indy_pool docker container. Idempotent. Ensures that the
indy_pool container is a new running instance.'''
print("Restarting...")
try:
stopIndyPool()
startIndyPool()
print("...restarted")
except Exception as exc:
eprint("...failed... |
Special signing state where the the data for an attribute is hashed before signing: return: state to be used when signing | def signingPayloadState(self, identifier=None):
"""
Special signing state where the the data for an attribute is hashed
before signing
:return: state to be used when signing
"""
if self.operation.get(TXN_TYPE) == ATTRIB:
d = deepcopy(super().signingPayloadStat... |
Test for the directory open old and new ledger migrate data rename directories | def _migrate_ledger(data_directory,
old_ledger_file, new_ledger_file,
serializer: MappingSerializer = None):
"""
Test for the directory, open old and new ledger, migrate data, rename directories
"""
# we should have ChunkedFileStorage implementation of the Ledger... |
None roles are stored as empty strings so the role returned as None by this function means that corresponding DID is not stored in a ledger. | def get_role(self, request: Request):
"""
None roles are stored as empty strings, so the role returned as None
by this function means that corresponding DID is not stored in a ledger.
"""
idr = request.identifier
return self._get_role(idr) |
Handles transaction of type POOL_CONFIG | def handleConfigTxn(self, txn) -> None:
"""
Handles transaction of type POOL_CONFIG
:param txn:
"""
if get_type(txn) == POOL_CONFIG:
self.writes = get_payload_data(txn)[WRITES] |
Checks ledger config txns and perfomes recent one | def processLedger(self) -> None:
"""
Checks ledger config txns and perfomes recent one
:return:
"""
logger.debug('{} processing config ledger for any POOL_CONFIGs'.format(
self), extra={"tags": ["pool-config"]})
for _, txn in self.ledger.getAllTxn():
... |
Handles transaction of type POOL_RESTART Can schedule or cancel restart to a newer version at specified time | def handleRestartRequest(self, req: Request) -> None:
"""
Handles transaction of type POOL_RESTART
Can schedule or cancel restart to a newer
version at specified time
:param req:
"""
txn = req.operation
if txn[TXN_TYPE] != POOL_RESTART:
return... |
Schedules node restart to a newer version | def _scheduleRestart(self,
when: Union[datetime, str],
failTimeout) -> None:
"""
Schedules node restart to a newer version
:param version: version to restart to
:param when: restart time
"""
logger.info("{}'s restarter pr... |
Cancels scheduled restart | def _cancelScheduledRestart(self, justification=None) -> None:
"""
Cancels scheduled restart
:param when: time restart was scheduled to
:param version: version restart scheduled for
"""
if self.scheduledAction:
why_prefix = ": "
why = justificati... |
Callback which is called when restart time come. Writes restart record to restart log and asks node control service to perform restart | def _callRestartAgent(self, ev_data: RestartLogData, failTimeout) -> None:
"""
Callback which is called when restart time come.
Writes restart record to restart log and asks
node control service to perform restart
:param ev_data: restart event data
:param version: versio... |
This function is called when time for restart is up | def _declareTimeoutExceeded(self, ev_data: RestartLogData):
"""
This function is called when time for restart is up
"""
logger.info("Timeout exceeded for {}".format(ev_data.when))
last = self._actionLog.last_event
if (last and last.ev_type == RestartLog.Events.failed and
... |
Checks ledger for planned but not yet performed upgrades and schedules upgrade for the most recent one | def processLedger(self) -> None:
"""
Checks ledger for planned but not yet performed upgrades
and schedules upgrade for the most recent one
Assumption: Only version is enough to identify a release, no hash
checking is done
:return:
"""
logger.debug(
... |
Checks last record in upgrade log to find out whether it is about scheduling upgrade. If so - checks whether current version is equals to the one in that record | def didLastExecutedUpgradeSucceeded(self) -> bool:
"""
Checks last record in upgrade log to find out whether it
is about scheduling upgrade. If so - checks whether current version
is equals to the one in that record
:returns: upgrade execution result
"""
lastEven... |
Handles transaction of type POOL_UPGRADE Can schedule or cancel upgrade to a newer version at specified time | def handleUpgradeTxn(self, txn) -> None:
"""
Handles transaction of type POOL_UPGRADE
Can schedule or cancel upgrade to a newer
version at specified time
:param txn:
"""
FINALIZING_EVENT_TYPES = [UpgradeLog.Events.succeeded, UpgradeLog.Events.failed]
if ... |
Schedules node upgrade to a newer version | def _scheduleUpgrade(self,
ev_data: UpgradeLogData,
failTimeout) -> None:
"""
Schedules node upgrade to a newer version
:param ev_data: upgrade event parameters
"""
logger.info(
"{}'s upgrader processing upgrade for v... |
Cancels scheduled upgrade | def _cancelScheduledUpgrade(self, justification=None) -> None:
"""
Cancels scheduled upgrade
:param when: time upgrade was scheduled to
:param version: version upgrade scheduled for
"""
if self.scheduledAction:
why_prefix = ": "
why = justificati... |
Callback which is called when upgrade time come. Writes upgrade record to upgrade log and asks node control service to perform upgrade | def _callUpgradeAgent(self, ev_data, failTimeout) -> None:
"""
Callback which is called when upgrade time come.
Writes upgrade record to upgrade log and asks
node control service to perform upgrade
:param when: upgrade time
:param version: version to upgrade to
"... |
This function is called when time for upgrade is up | def _declareTimeoutExceeded(self, ev_data: UpgradeLogData):
"""
This function is called when time for upgrade is up
"""
logger.info("Timeout exceeded for {}:{}"
.format(ev_data.when, ev_data.version))
last = self._actionLog.last_event
# TODO test this
... |
Validates schedule of planned node upgrades | def isScheduleValid(self, schedule, node_srvs, force) -> (bool, str):
"""
Validates schedule of planned node upgrades
:param schedule: dictionary of node ids and upgrade times
:param node_srvs: dictionary of node ids and services
:return: a 2-tuple of whether schedule valid or n... |
Retrieves a temporary access token | def get_token(self, url):
"""
Retrieves a temporary access token
"""
# A hack to avoid url-encoding the url, since the authorization service
# doesn't work with correctly encoded urls
parsed_url = urlparse.urlsplit(url)
parsed_url = parsed_url._replace(path='/aut... |
Synthesizes text to spoken audio using web sockets. It supports the use of the SSML <mark > element to identify the location of user - specified markers in the audio. It can also return timing information for all strings of the input text. Note: The service processes one request per connection. | def synthesize_using_websocket(self,
text,
synthesize_callback,
accept=None,
voice=None,
timings=None,
customi... |
Classify images. | def classify(self,
images_file=None,
images_filename=None,
images_file_content_type=None,
url=None,
threshold=None,
owners=None,
classifier_ids=None,
accept_language=None,
... |
Create a classifier. | def create_classifier(self,
name,
positive_examples,
negative_examples=None,
negative_examples_filename=None,
**kwargs):
"""
Create a classifier.
Train a new multi-f... |
Delete a classifier. | def delete_classifier(self, classifier_id, **kwargs):
"""
Delete a classifier.
:param str classifier_id: The ID of the classifier.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'class_name') and self.class_name is not None:
_dict['class'] = self.class_name
return _dict |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'class_name') and self.class_name is not None:
_dict['class'] = self.class_name
if hasattr(self, 'score') and self.score is not None:
_dict['score'] = self.scor... |
Initialize a ClassifiedImage object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a ClassifiedImage object from a json dictionary."""
args = {}
if 'source_url' in _dict:
args['source_url'] = _dict.get('source_url')
if 'resolved_url' in _dict:
args['resolved_url'] = _dict.get('resolved_url')
if '... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'source_url') and self.source_url is not None:
_dict['source_url'] = self.source_url
if hasattr(self, 'resolved_url') and self.resolved_url is not None:
_dict['... |
Initialize a Classifier object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a Classifier object from a json dictionary."""
args = {}
if 'classifier_id' in _dict:
args['classifier_id'] = _dict.get('classifier_id')
else:
raise ValueError(
'Required property \'classifier_id\' not pres... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'classifier_id') and self.classifier_id is not None:
_dict['classifier_id'] = self.classifier_id
if hasattr(self, 'name') and self.name is not None:
_dict['name... |
Initialize a ClassifierResult object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a ClassifierResult object from a json dictionary."""
args = {}
if 'name' in _dict:
args['name'] = _dict.get('name')
else:
raise ValueError(
'Required property \'name\' not present in ClassifierResult JSON'
... |
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, 'classifier_id') and self.classifier_id is not None:
_dict['classifier_id'] = self... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'classifiers') and self.classifiers is not None:
_dict['classifiers'] = [x._to_dict() for x in self.classifiers]
return _dict |
Initialize a DetectedFaces object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a DetectedFaces object from a json dictionary."""
args = {}
if 'images_processed' in _dict:
args['images_processed'] = _dict.get('images_processed')
else:
raise ValueError(
'Required property \'images_proce... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self,
'images_processed') and self.images_processed is not None:
_dict['images_processed'] = self.images_processed
if hasattr(self, 'images') and self.images i... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'code') and self.code is not None:
_dict['code'] = self.code
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.descr... |
Initialize a Face object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a Face object from a json dictionary."""
args = {}
if 'age' in _dict:
args['age'] = FaceAge._from_dict(_dict.get('age'))
if 'gender' in _dict:
args['gender'] = FaceGender._from_dict(_dict.get('gender'))
if 'face_lo... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'age') and self.age is not None:
_dict['age'] = self.age._to_dict()
if hasattr(self, 'gender') and self.gender is not None:
_dict['gender'] = self.gender._to_di... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'min') and self.min is not None:
_dict['min'] = self.min
if hasattr(self, 'max') and self.max is not None:
_dict['max'] = self.max
if hasattr(self, 'sco... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'gender') and self.gender is not None:
_dict['gender'] = self.gender
if hasattr(self, 'gender_label') and self.gender_label is not None:
_dict['gender_label'] =... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'width') and self.width is not None:
_dict['width'] = self.width
if hasattr(self, 'height') and self.height is not None:
_dict['height'] = self.height
i... |
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, 'description') and self.description is not None:
_dict['de... |
Send user input to assistant. | def message(self,
assistant_id,
session_id,
input=None,
context=None,
**kwargs):
"""
Send user input to assistant.
Send user input to an assistant and receive a response.
There is no rate limit for this oper... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'group') and self.group is not None:
_dict['group'] = self.group
if hasattr(self, 'location') and self.location is not None:
_dict['location'] = self.location
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'level') and self.level is not None:
_dict['level'] = self.level
if hasattr(self, 'message') and self.message is not None:
_dict['message'] = self.message
... |
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, 'action_type') and self.action_type is not None:
_dict['type'] = self.action_type
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'input') and self.input is not None:
_dict['input'] = self.input._to_dict()
return _dict |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'dialog_node') and self.dialog_node is not None:
_dict['dialog_node'] = self.dialog_node
if hasattr(self, 'title') and self.title is not None:
_dict['title'] = ... |
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
if hasattr(self, 'value') and self.value is not None:
_dict['value'] = self.value._to_dict()
... |
Initialize a MessageContext object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a MessageContext object from a json dictionary."""
args = {}
if 'global' in _dict:
args['global_'] = MessageContextGlobal._from_dict(
_dict.get('global'))
if 'skills' in _dict:
args['skills'] = MessageConte... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'global_') and self.global_ is not None:
_dict['global'] = self.global_._to_dict()
if hasattr(self, 'skills') and self.skills is not None:
_dict['skills'] = sel... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'system') and self.system is not None:
_dict['system'] = self.system._to_dict()
return _dict |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'timezone') and self.timezone is not None:
_dict['timezone'] = self.timezone
if hasattr(self, 'user_id') and self.user_id is not None:
_dict['user_id'] = self.u... |
Initialize a MessageInput object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a MessageInput object from a json dictionary."""
args = {}
if 'message_type' in _dict:
args['message_type'] = _dict.get('message_type')
if 'text' in _dict:
args['text'] = _dict.get('text')
if 'options' in _dict:
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'message_type') and self.message_type is not None:
_dict['message_type'] = self.message_type
if hasattr(self, 'text') and self.text is not None:
_dict['text'] =... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'debug') and self.debug is not None:
_dict['debug'] = self.debug
if hasattr(self, 'restart') and self.restart is not None:
_dict['restart'] = self.restart
... |
Initialize a MessageOutput object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a MessageOutput object from a json dictionary."""
args = {}
if 'generic' in _dict:
args['generic'] = [
DialogRuntimeResponseGeneric._from_dict(x)
for x in (_dict.get('generic'))
]
if 'intent... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'generic') and self.generic is not None:
_dict['generic'] = [x._to_dict() for x in self.generic]
if hasattr(self, 'intents') and self.intents is not None:
_dict... |
Initialize a MessageOutputDebug object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a MessageOutputDebug object from a json dictionary."""
args = {}
if 'nodes_visited' in _dict:
args['nodes_visited'] = [
DialogNodesVisited._from_dict(x)
for x in (_dict.get('nodes_visited'))
]
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'nodes_visited') and self.nodes_visited is not None:
_dict['nodes_visited'] = [x._to_dict() for x in self.nodes_visited]
if hasattr(self, 'log_messages') and self.log_messa... |
Initialize a MessageResponse object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a MessageResponse object from a json dictionary."""
args = {}
if 'output' in _dict:
args['output'] = MessageOutput._from_dict(_dict.get('output'))
else:
raise ValueError(
'Required property \'output\' not p... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'output') and self.output is not None:
_dict['output'] = self.output._to_dict()
if hasattr(self, 'context') and self.context is not None:
_dict['context'] = sel... |
Initialize a RuntimeEntity object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a RuntimeEntity object from a json dictionary."""
args = {}
if 'entity' in _dict:
args['entity'] = _dict.get('entity')
else:
raise ValueError(
'Required property \'entity\' not present in RuntimeEntity JSON... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'entity') and self.entity is not None:
_dict['entity'] = self.entity
if hasattr(self, 'location') and self.location is not None:
_dict['location'] = self.locati... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'intent') and self.intent is not None:
_dict['intent'] = self.intent
if hasattr(self, 'confidence') and self.confidence is not None:
_dict['confidence'] = self.... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'session_id') and self.session_id is not None:
_dict['session_id'] = self.session_id
return _dict |
Analyze text. | def analyze(self,
features,
text=None,
html=None,
url=None,
clean=None,
xpath=None,
fallback_to_raw=None,
return_analyzed_text=None,
language=None,
limit_text_c... |
List models. | def list_models(self, **kwargs):
"""
List models.
Lists Watson Knowledge Studio [custom
models](https://cloud.ibm.com/docs/services/natural-language-understanding/customizing.html)
that are deployed to your Natural Language Understanding service.
:param dict headers: A ... |
Initialize a AnalysisResults object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a AnalysisResults object from a json dictionary."""
args = {}
if 'language' in _dict:
args['language'] = _dict.get('language')
if 'analyzed_text' in _dict:
args['analyzed_text'] = _dict.get('analyzed_text')
if 'ret... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'language') and self.language is not None:
_dict['language'] = self.language
if hasattr(self, 'analyzed_text') and self.analyzed_text is not None:
_dict['analyz... |
Initialize a AnalysisResultsMetadata object from a json dictionary. | def _from_dict(cls, _dict):
"""Initialize a AnalysisResultsMetadata object from a json dictionary."""
args = {}
if 'authors' in _dict:
args['authors'] = [
Author._from_dict(x) for x in (_dict.get('authors'))
]
if 'publication_date' in _dict:
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'authors') and self.authors is not None:
_dict['authors'] = [x._to_dict() for x in self.authors]
if hasattr(self,
'publication_date') and self.publicatio... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'features') and self.features is not None:
_dict['features'] = self.features
if hasattr(self,
'text_characters') and self.text_characters 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, 'name') and self.name is not None:
_dict['name'] = self.name
return _dict |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'limit') and self.limit is not None:
_dict['limit'] = self.limit
if hasattr(self, 'model') and self.model is not None:
_dict['model'] = self.model
retur... |
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
if hasattr(self, 'score') and self.score is not None:
_dict['score'] = self.score
retur... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'limit') and self.limit is not None:
_dict['limit'] = self.limit
return _dict |
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, 'relevance') and self.relevance is not None:
_dict['relevance'] = self.relevance
... |
Return a json dictionary representing this model. | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'deleted') and self.deleted is not None:
_dict['deleted'] = self.deleted
return _dict |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.