Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def getCollectionClass(cls, name) :
try :
return cls.collectionClasses[name]
except KeyError :
raise KeyError( "There is no Collection Class of type: '%s'; currently supported values: [%s]" % (name, ', '.join(getCollectionClas... | [
"Return the class object of a collection given its 'name'"
] |
Please provide a description of the function:def isDocumentCollection(cls, name) :
try :
col = cls.getCollectionClass(name)
return issubclass(col, Collection)
except KeyError :
return False | [
"return true or false wether 'name' is the name of a document collection."
] |
Please provide a description of the function:def isEdgeCollection(cls, name) :
try :
col = cls.getCollectionClass(name)
return issubclass(col, Edges)
except KeyError :
return False | [
"return true or false wether 'name' is the name of an edge collection."
] |
Please provide a description of the function:def getIndexes(self) :
url = "%s/index" % self.database.URL
r = self.connection.session.get(url, params = {"collection": self.name})
data = r.json()
for ind in data["indexes"] :
self.indexes[ind["type"]][ind["id"]] = Index... | [
"Fills self.indexes with all the indexes associates with the collection and returns it"
] |
Please provide a description of the function:def delete(self) :
r = self.connection.session.delete(self.URL)
data = r.json()
if not r.status_code == 200 or data["error"] :
raise DeletionError(data["errorMessage"], data) | [
"deletes the collection from the database"
] |
Please provide a description of the function:def createDocument(self, initDict = None) :
if initDict is not None :
return self.createDocument_(initDict)
else :
if self._validation["on_load"] :
self._validation["on_load"] = False
return sel... | [
"create and returns a document populated with the defaults or with the values in initDict"
] |
Please provide a description of the function:def createDocument_(self, initDict = None) :
"create and returns a completely empty document or one populated with initDict"
if initDict is None :
initV = {}
else :
initV = initDict
return self.documentClass(self, init... | [] |
Please provide a description of the function:def ensureHashIndex(self, fields, unique = False, sparse = True, deduplicate = False) :
data = {
"type" : "hash",
"fields" : fields,
"unique" : unique,
"sparse" : sparse,
"deduplicate": deduplicate
... | [
"Creates a hash index if it does not already exist, and returns it"
] |
Please provide a description of the function:def ensureGeoIndex(self, fields) :
data = {
"type" : "geo",
"fields" : fields,
}
ind = Index(self, creationData = data)
self.indexes["geo"][ind.infos["id"]] = ind
return ind | [
"Creates a geo index if it does not already exist, and returns it"
] |
Please provide a description of the function:def ensureFulltextIndex(self, fields, minLength = None) :
data = {
"type" : "fulltext",
"fields" : fields,
}
if minLength is not None :
data["minLength"] = minLength
ind = Index(self, creationData ... | [
"Creates a fulltext index if it does not already exist, and returns it"
] |
Please provide a description of the function:def validatePrivate(self, field, value) :
if field not in self.arangoPrivates :
raise ValueError("%s is not a private field of collection %s" % (field, self))
if field in self._fields :
self._fields[field].validate(value)
... | [
"validate a private field value"
] |
Please provide a description of the function:def hasField(cls, fieldName) :
path = fieldName.split(".")
v = cls._fields
for k in path :
try :
v = v[k]
except KeyError :
return False
return True | [
"returns True/False wether the collection has field K in it's schema. Use the dot notation for the nested fields: address.street"
] |
Please provide a description of the function:def fetchDocument(self, key, rawResults = False, rev = None) :
url = "%s/%s/%s" % (self.documentsURL, self.name, key)
if rev is not None :
r = self.connection.session.get(url, params = {'rev' : rev})
else :
r = self.co... | [
"Fetches a document from the collection given it's key. This function always goes straight to the db and bypasses the cache. If you\n want to take advantage of the cache use the __getitem__ interface: collection[key]"
] |
Please provide a description of the function:def fetchByExample(self, exampleDict, batchSize, rawResults = False, **queryArgs) :
return self.simpleQuery('by-example', rawResults, example = exampleDict, batchSize = batchSize, **queryArgs) | [
"exampleDict should be something like {'age' : 28}"
] |
Please provide a description of the function:def fetchFirstExample(self, exampleDict, rawResults = False) :
return self.simpleQuery('first-example', rawResults = rawResults, example = exampleDict) | [
"exampleDict should be something like {'age' : 28}. returns only a single element but still in a SimpleQuery object.\n returns the first example found that matches the example"
] |
Please provide a description of the function:def fetchAll(self, rawResults = False, **queryArgs) :
return self.simpleQuery('all', rawResults = rawResults, **queryArgs) | [
"Returns all the documents in the collection. You can use the optinal arguments 'skip' and 'limit'::\n\n fetchAlll(limit = 3, shik = 10)"
] |
Please provide a description of the function:def simpleQuery(self, queryType, rawResults = False, **queryArgs) :
return SimpleQuery(self, queryType, rawResults, **queryArgs) | [
"General interface for simple queries. queryType can be something like 'all', 'by-example' etc... everything is in the arango doc.\n If rawResults, the query will return dictionaries instead of Document objetcs.\n "
] |
Please provide a description of the function:def action(self, method, action, **params) :
fct = getattr(self.connection.session, method.lower())
r = fct(self.URL + "/" + action, params = params)
return r.json() | [
"a generic fct for interacting everything that doesn't have an assigned fct"
] |
Please provide a description of the function:def bulkSave(self, docs, onDuplicate="error", **params) :
payload = []
for d in docs :
if type(d) is dict :
payload.append(json.dumps(d, default=str))
else :
try:
payload.ap... | [
"Parameter docs must be either an iterrable of documents or dictionnaries.\n This function will return the number of documents, created and updated, and will raise an UpdateError exception if there's at least one error.\n params are any parameters from arango's documentation"
] |
Please provide a description of the function:def bulkImport_json(self, filename, onDuplicate="error", formatType="auto", **params) :
url = "%s/import" % self.database.URL
params["onDuplicate"] = onDuplicate
params["collection"] = self.name
params["type"] = formatType
wi... | [
"bulk import from a file repecting arango's key/value format"
] |
Please provide a description of the function:def getType(self) :
if self.type == CONST.COLLECTION_DOCUMENT_TYPE :
return "document"
elif self.type == CONST.COLLECTION_EDGE_TYPE :
return "edge"
else :
raise ValueError("The collection is of Unknown type... | [
"returns a word describing the type of the collection (edges or ducments) instead of a number, if you prefer the number it's in self.type"
] |
Please provide a description of the function:def getStatus(self) :
if self.status == CONST.COLLECTION_LOADING_STATUS :
return "loading"
elif self.status == CONST.COLLECTION_LOADED_STATUS :
return "loaded"
elif self.status == CONST.COLLECTION_DELETED_STATUS :
... | [
"returns a word describing the status of the collection (loaded, loading, deleted, unloaded, newborn) instead of a number, if you prefer the number it's in self.status"
] |
Please provide a description of the function:def validateField(cls, fieldName, value) :
try :
valValue = Collection.validateField(fieldName, value)
except SchemaViolation as e:
if fieldName == "_from" or fieldName == "_to" :
return True
else :... | [
"checks if 'value' is valid for field 'fieldName'. If the validation is unsuccessful, raises a SchemaViolation or a ValidationError.\n for nested dicts ex: {address : { street: xxx} }, fieldName can take the form address.street\n "
] |
Please provide a description of the function:def getOutEdges(self, vertex, rawResults = False) :
return self.getEdges(vertex, inEdges = False, outEdges = True, rawResults = rawResults) | [
"An alias for getEdges() that returns only the out Edges"
] |
Please provide a description of the function:def getEdges(self, vertex, inEdges = True, outEdges = True, rawResults = False) :
if isinstance(vertex, Document):
vId = vertex._id
elif (type(vertex) is str) or (type(vertex) is bytes):
vId = vertex
else :
... | [
"returns in, out, or both edges liked to a given document. vertex can be either a Document object or a string for an _id.\n If rawResults a arango results will be return as fetched, if false, will return a liste of Edge objects"
] |
Please provide a description of the function:def reloadCollections(self) :
"reloads the collection list."
r = self.connection.session.get(self.collectionsURL)
data = r.json()
if r.status_code == 200 :
self.collections = {}
for colData in data["result"] :
... | [] |
Please provide a description of the function:def reloadGraphs(self) :
"reloads the graph list"
r = self.connection.session.get(self.graphsURL)
data = r.json()
if r.status_code == 200 :
self.graphs = {}
for graphData in data["graphs"] :
try :
... | [] |
Please provide a description of the function:def createCollection(self, className = 'Collection', **colProperties) :
colClass = COL.getCollectionClass(className)
if len(colProperties) > 0 :
colProperties = dict(colProperties)
else :
try :
colPro... | [
"Creates a collection and returns it.\n ClassName the name of a class inheriting from Collection or Egdes, it can also be set to 'Collection' or 'Edges' in order to create untyped collections of documents or edges.\n Use colProperties to put things such as 'waitForSync = True' (see ArangoDB's doc\n ... |
Please provide a description of the function:def createGraph(self, name, createCollections = True, isSmart = False, numberOfShards = None, smartGraphAttribute = None) :
def _checkCollectionList(lst) :
for colName in lst :
if not COL.isCollection(colName) :
... | [
"Creates a graph and returns it. 'name' must be the name of a class inheriting from Graph.\n Checks will be performed to make sure that every collection mentionned in the edges definition exist. Raises a ValueError in case of\n a non-existing collection."
] |
Please provide a description of the function:def dropAllCollections(self):
for graph_name in self.graphs:
self.graphs[graph_name].delete()
for collection_name in self.collections:
# Collections whose name starts with '_' are system collections
if not collecti... | [
"drops all public collections (graphs included) from the database"
] |
Please provide a description of the function:def AQLQuery(self, query, batchSize = 100, rawResults = False, bindVars = {}, options = {}, count = False, fullCount = False,
json_encoder = None, **moreArgs) :
return AQLQuery(self, query, rawResults = rawResults, batchSize = batchSize, bin... | [
"Set rawResults = True if you want the query to return dictionnaries instead of Document objects.\n You can use **moreArgs to pass more arguments supported by the api, such as ttl=60 (time to live)"
] |
Please provide a description of the function:def explainAQLQuery(self, query, bindVars={}, allPlans = False) :
payload = {'query' : query, 'bindVars' : bindVars, 'allPlans' : allPlans}
request = self.connection.session.post(self.explainURL, data = json.dumps(payload, default=str))
retur... | [
"Returns an explanation of the query. Setting allPlans to True will result in ArangoDB returning all possible plans. False returns only the optimal plan"
] |
Please provide a description of the function:def validateAQLQuery(self, query, bindVars = None, options = None) :
"returns the server answer is the query is valid. Raises an AQLQueryError if not"
if bindVars is None :
bindVars = {}
if options is None :
options = {}
... | [] |
Please provide a description of the function:def transaction(self, collections, action, waitForSync = False, lockTimeout = None, params = None) :
payload = {
"collections": collections,
"action": action,
"waitForSync": waitForSync}
if lockTimeout ... | [
"Execute a server-side transaction"
] |
Please provide a description of the function:def getPatches(self) :
if not self.mustValidate :
return self.getStore()
res = {}
res.update(self.patchStore)
for k, v in self.subStores.items() :
res[k] = v.getPatches()
return res | [
"get patches as a dictionary"
] |
Please provide a description of the function:def getStore(self) :
res = {}
res.update(self.store)
for k, v in self.subStores.items() :
res[k] = v.getStore()
return res | [
"get the inner store as dictionary"
] |
Please provide a description of the function:def validateField(self, field) :
if field not in self.validators and not self.collection._validation['allow_foreign_fields'] :
raise SchemaViolation(self.collection.__class__, field)
if field in self.store:
if isinstance(self... | [
"Validatie a field"
] |
Please provide a description of the function:def validate(self) :
if not self.mustValidate :
return True
res = {}
for field in self.validators.keys() :
try :
if isinstance(self.validators[field], dict) and field not in self.store :
... | [
"Validate the whole document"
] |
Please provide a description of the function:def set(self, dct) :
# if not self.mustValidate :
# self.store = dct
# self.patchStore = dct
# return
for field, value in dct.items() :
if field not in self.collection.arangoPrivates :
... | [
"Set the store using a dictionary"
] |
Please provide a description of the function:def reset(self, collection, jsonFieldInit = None) :
if not jsonFieldInit:
jsonFieldInit = {}
self.collection = collection
self.connection = self.collection.connection
self.documentsURL = self.collection.documentsURL
... | [
"replaces the current values in the document by those in jsonFieldInit"
] |
Please provide a description of the function:def validate(self) :
self._store.validate()
for pField in self.collection.arangoPrivates :
self.collection.validatePrivate(pField, getattr(self, pField)) | [
"validate the document"
] |
Please provide a description of the function:def setPrivates(self, fieldDict) :
for priv in self.privates :
if priv in fieldDict :
setattr(self, priv, fieldDict[priv])
else :
setattr(self, priv, None)
if self._id is not N... | [
"will set self._id, self._rev and self._key field."
] |
Please provide a description of the function:def save(self, waitForSync = False, **docArgs) :
payload = self._store.getStore()
self._save(payload, waitForSync = False, **docArgs) | [
"Saves the document to the database by either performing a POST (for a new document) or a PUT (complete document overwrite).\n If you want to only update the modified fields use the .patch() function.\n Use docArgs to put things such as 'waitForSync = True' (for a full list cf ArangoDB's doc).\n ... |
Please provide a description of the function:def saveCopy(self) :
"saves a copy of the object and become that copy. returns a tuple (old _key, new _key)"
old_key = self._key
self.reset(self.collection)
self.save()
return (old_key, self._key) | [] |
Please provide a description of the function:def patch(self, keepNull = True, **docArgs) :
if self.URL is None :
raise ValueError("Cannot patch a document that was not previously saved")
payload = self._store.getPatches()
if self.collection._validation['on_save'] ... | [
"Saves the document by only updating the modified fields.\n The default behaviour concening the keepNull parameter is the opposite of ArangoDB's default, Null values won't be ignored\n Use docArgs for things such as waitForSync = True"
] |
Please provide a description of the function:def delete(self) :
"deletes the document from the database"
if self.URL is None :
raise DeletionError("Can't delete a document that was not saved")
r = self.connection.session.delete(self.URL)
data = r.json()
if (r.status_... | [] |
Please provide a description of the function:def getEdges(self, edges, inEdges = True, outEdges = True, rawResults = False) :
try :
return edges.getEdges(self, inEdges, outEdges, rawResults)
except AttributeError :
raise AttributeError("%s does not seem to be a valid Edg... | [
"returns in, out, or both edges linked to self belonging the collection 'edges'.\n If rawResults a arango results will be return as fetched, if false, will return a liste of Edge objects"
] |
Please provide a description of the function:def getStore(self) :
store = self._store.getStore()
for priv in self.privates :
v = getattr(self, priv)
if v :
store[priv] = v
return store | [
"return the store in a dict format"
] |
Please provide a description of the function:def links(self, fromVertice, toVertice, **edgeArgs) :
if isinstance(fromVertice, Document) or isinstance(getattr(fromVertice, 'document', None), Document):
if not fromVertice._id :
fromVertice.save()
self._from = fromV... | [
"\n An alias to save that updates the _from and _to attributes.\n fromVertice and toVertice, can be either strings or documents. It they are unsaved documents, they will be automatically saved.\n "
] |
Please provide a description of the function:def save(self, **edgeArgs) :
if not getattr(self, "_from") or not getattr(self, "_to") :
raise AttributeError("You must specify '_from' and '_to' attributes before saving. You can also use the function 'links()'")
payload = self._store.... | [
"Works like Document's except that you must specify '_from' and '_to' vertices before.\n There's also a links() function especially for first saves."
] |
Please provide a description of the function:def _set(self, jsonData) :
self["username"] = jsonData["user"]
self["active"] = jsonData["active"]
self["extra"] = jsonData["extra"]
try:
self["changePassword"] = jsonData["changePassword"]
except Exceptio... | [
"Initialize all fields at once. If no password is specified, it will be set as an empty string"
] |
Please provide a description of the function:def save(self):
import json
payload = {}
payload.update(self._store)
payload["user"] = payload["username"]
payload["passwd"] = payload["password"]
del(payload["username"])
del(payload["password"])
pa... | [
"Save/updates the user"
] |
Please provide a description of the function:def setPermissions(self, dbName, access) :
import json
if not self.URL :
raise CreationError("Please save user first", None, None)
rights = []
if access :
rights.append("rw")
rights = ''.join(rights)... | [
"Grant revoke rights on a database, 'access' is supposed to be boolean. ArangoDB grants/revokes both read and write rights at the same time"
] |
Please provide a description of the function:def delete(self) :
if not self.URL :
raise CreationError("Please save user first", None, None)
r = self.connection.session.delete(self.URL)
if r.status_code < 200 or r.status_code > 202 :
raise DeletionError("Unable t... | [
"Permanently remove the user"
] |
Please provide a description of the function:def fetchAllUsers(self, rawResults = False) :
r = self.connection.session.get(self.URL)
if r.status_code == 200 :
data = r.json()
if rawResults :
return data["result"]
else :
res = [... | [
"Returns all available users. if rawResults, the result will be a list of python dicts instead of User objects"
] |
Please provide a description of the function:def fetchUser(self, username, rawResults = False) :
url = "%s/%s" % (self.URL, username)
r = self.connection.session.get(url)
if r.status_code == 200 :
data = r.json()
if rawResults :
return data["resu... | [
"Returns a single user. if rawResults, the result will be a list of python dicts instead of User objects"
] |
Please provide a description of the function:def resetSession(self, username=None, password=None, verify=True) :
self.disconnectSession()
self.session = AikidoSession(username, password, verify) | [
"resets the session"
] |
Please provide a description of the function:def reload(self) :
r = self.session.get(self.databasesURL)
data = r.json()
if r.status_code == 200 and not data["error"] :
self.databases = {}
for dbName in data["result"] :
if dbName not in self.data... | [
"Reloads the database list.\n Because loading a database triggers the loading of all collections and graphs within,\n only handles are loaded when this function is called. The full databases are loaded on demand when accessed\n "
] |
Please provide a description of the function:def createDatabase(self, name, **dbArgs) :
"use dbArgs for arguments other than name. for a full list of arguments please have a look at arangoDB's doc"
dbArgs['name'] = name
payload = json.dumps(dbArgs, default=str)
url = self.URL + "/databas... | [] |
Please provide a description of the function:def explain(self, bindVars={}, allPlans = False) :
return self.database.explainAQLQuery(self.query, bindVars, allPlans) | [
"Returns an explanation of the query. Setting allPlans to True will result in ArangoDB returning all possible plans. False returns only the optimal plan"
] |
Please provide a description of the function:def output(self, args):
'''
Print the output message.
'''
print("SensuPlugin: {}".format(' '.join(str(a) for a in args))) | [] |
Please provide a description of the function:def __make_dynamic(self, method):
'''
Create a method for each of the exit codes.
'''
def dynamic(*args):
self.plugin_info['status'] = method
if not args:
args = None
self.output(args)
... | [] |
Please provide a description of the function:def __exitfunction(self):
'''
Method called by exit hook, ensures that both an exit code and
output is supplied, also catches errors.
'''
if self._hook.exit_code is None and self._hook.exception is None:
print("Check did no... | [] |
Please provide a description of the function:def run(self):
'''
Set up the event object, global settings and command line
arguments.
'''
# Parse the stdin into a global event object
stdin = self.read_stdin()
self.event = self.read_event(stdin)
# Prepare ... | [] |
Please provide a description of the function:def read_event(self, check_result):
'''
Convert the piped check result (json) into a global 'event' dict
'''
try:
event = json.loads(check_result)
event['occurrences'] = event.get('occurrences', 1)
event['ch... | [] |
Please provide a description of the function:def filter(self):
'''
Filters exit the proccess if the event should not be handled.
Filtering events is deprecated and will be removed in a future release.
'''
if self.deprecated_filtering_enabled():
print('warning: event ... | [] |
Please provide a description of the function:def bail(self, msg):
'''
Gracefully terminate with message
'''
client_name = self.event['client'].get('name', 'error:no-client-name')
check_name = self.event['check'].get('name', 'error:no-check-name')
print('{}: {}/{}'.format(... | [] |
Please provide a description of the function:def get_api_settings(self):
'''
Return a dict of API settings derived first from ENV['SENSU_API_URL']
if set, then Sensu config `api` scope if configured, and finally
falling back to to ipv4 localhost address on default API port.
retu... | [] |
Please provide a description of the function:def api_request(self, method, path):
'''
Query Sensu api for information.
'''
if not hasattr(self, 'api_settings'):
ValueError('api.json settings not found')
if method.lower() == 'get':
_request = requests.get
... | [] |
Please provide a description of the function:def event_exists(self, client, check):
'''
Query Sensu API for event.
'''
return self.api_request(
'get',
'events/{}/{}'.format(client, check)
).status_code == 200 | [] |
Please provide a description of the function:def filter_silenced(self):
'''
Determine whether a check is silenced and shouldn't handle.
'''
stashes = [
('client', '/silence/{}'.format(self.event['client']['name'])),
('check', '/silence/{}/{}'.format(
... | [] |
Please provide a description of the function:def filter_dependencies(self):
'''
Determine whether a check has dependencies.
'''
dependencies = self.event['check'].get('dependencies', None)
if dependencies is None or not isinstance(dependencies, list):
return
f... | [] |
Please provide a description of the function:def filter_repeated(self):
'''
Determine whether a check is repeating.
'''
defaults = {
'occurrences': 1,
'interval': 30,
'refresh': 1800
}
# Override defaults with anything defined in the s... | [] |
Please provide a description of the function:def config_files():
'''
Get list of currently used config files.
'''
sensu_loaded_tempfile = os.environ.get('SENSU_LOADED_TEMPFILE')
sensu_config_files = os.environ.get('SENSU_CONFIG_FILES')
sensu_v1_config = '/etc/sensu/config.json'
sensu_v1_conf... | [] |
Please provide a description of the function:def get_settings():
'''
Get all currently loaded settings.
'''
settings = {}
for config_file in config_files():
config_contents = load_config(config_file)
if config_contents is not None:
settings = deep_merge(settings, config_c... | [] |
Please provide a description of the function:def load_config(filename):
'''
Read contents of config file.
'''
try:
with open(filename, 'r') as config_file:
return json.loads(config_file.read())
except IOError:
pass | [] |
Please provide a description of the function:def deep_merge(dict_one, dict_two):
'''
Deep merge two dicts.
'''
merged = dict_one.copy()
for key, value in dict_two.items():
# value is equivalent to dict_two[key]
if (key in dict_one and
isinstance(dict_one[key], dict) a... | [] |
Please provide a description of the function:def map_v2_event_into_v1(event):
'''
Helper method to convert Sensu 2.x event into Sensu 1.x event.
'''
# return the event if it has already been mapped
if "v2_event_mapped_into_v1" in event:
return event
# Trigger mapping code if enity exis... | [] |
Please provide a description of the function:def check_name(self, name=None):
'''
Checks the plugin name and sets it accordingly.
Uses name if specified, class name if not set.
'''
if name:
self.plugin_info['check_name'] = name
if self.plugin_info['check_name... | [] |
Please provide a description of the function:def create(cls, path_name=None, name=None, project_id=None,
log_modified_at=None, crawlable=True):
result = cls(path_name, name, project_id, log_modified_at, crawlable)
db.session.add(result)
db.session.commit()
crawl... | [
"Initialize an instance and save it to db."
] |
Please provide a description of the function:def sampled_logs(self, logs_limit=-1):
logs_count = len(self.logs)
if logs_limit == -1 or logs_count <= logs_limit:
return self.logs
elif logs_limit == 0:
return []
elif logs_limit == 1:
return [sel... | [
"Return up to `logs_limit` logs.\n\n If `logs_limit` is -1, this function will return all logs that belong\n to the result.\n "
] |
Please provide a description of the function:def serialize_with_sampled_logs(self, logs_limit=-1):
return {
'id': self.id,
'pathName': self.path_name,
'name': self.name,
'isUnregistered': self.is_unregistered,
'logs': [log.serialize for log i... | [
"serialize a result with up to `logs_limit` logs.\n\n If `logs_limit` is -1, this function will return a result with all its\n logs.\n "
] |
Please provide a description of the function:def reporter(prefix=None, out=None, subdir='', timeout=5, **kwargs):
report = _Reporter(prefix, out, subdir, **kwargs)
yield report
report.save(timeout) | [
"Summary media assets to visualize.\n\n ``reporter`` function collects media assets by the ``with`` statement and\n aggregates in same row to visualize. This function returns an object which\n provides the following methods.\n\n * :meth:`~chainerui.summary._Reporter.image`: collect images. almost same \... |
Please provide a description of the function:def image(images, name=None, ch_axis=1, row=0, mode=None, batched=True,
out=None, subdir='', timeout=5, **kwargs):
from chainerui.report.image_report import check_available
if not check_available():
return
from chainerui.report.image_repor... | [
"Summary images to visualize.\n\n Array of images are converted as image format (PNG format on default),\n saved to output directory, and reported to the ChainerUI server.\n The images are saved every called this function. The images will be shown\n on `assets` endpoint vertically. If need to aggregate ... |
Please provide a description of the function:def audio(audio, sample_rate, name=None, out=None, subdir='', timeout=5,
**kwargs):
from chainerui.report.audio_report import check_available
if not check_available():
return
from chainerui.report.audio_report import report as _audio
... | [
"summary audio files to listen on a browser.\n\n An sampled array is converted as WAV audio file, saved to output directory,\n and reported to the ChainerUI server. The audio file is saved every called\n this function. The audio file will be listened on `assets` endpoint\n vertically. If need to aggrega... |
Please provide a description of the function:def image(self, images, name=None, ch_axis=1, row=0, mode=None,
batched=True, subdir=''):
from chainerui.report.image_report import check_available
if not check_available():
return
from chainerui.report.image_report ... | [
"Summary images to visualize.\n\n Args:\n images (:class:`numpy.ndarray` or :class:`cupy.ndarray` or \\\n :class:`chainer.Variable`): batch of images. If Number of\n dimension is 3 (or 2 when set `batched=False`), the pixels\n assume as black and white ... |
Please provide a description of the function:def audio(self, audio, sample_rate, name=None, subdir=''):
from chainerui.report.audio_report import check_available
if not check_available():
return
from chainerui.report.audio_report import report as _audio
col_name = ... | [
"Summary audio to listen on web browser.\n\n Args:\n audio (:class:`numpy.ndarray` or :class:`cupy.ndarray` or \\\n :class:`chainer.Variable`): sampled wave array.\n sample_rate (int): sampling rate.\n name (str): name of image. set as column name. when not set... |
Please provide a description of the function:def create_app():
app = Flask(__name__)
app.logger.disabled = True
for h in app.logger.handlers[:]:
app.logger.removeHandler(h)
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
def dated_url_for(endpoint, **values):
if end... | [
"create_app.",
"dated_url_for.",
"override_url_for.",
"render react app.",
"handle errors caused by db query."
] |
Please provide a description of the function:def serialize(self):
if self.request is None:
request = None
else:
request = json.loads(self.request)
if self.response is None:
response = None
else:
response = json.loads(self.respons... | [
"serialize."
] |
Please provide a description of the function:def post(self, result_id, project_id):
result = db.session.query(Result).filter_by(id=result_id).first()
if result is None:
return jsonify({
'result': None,
'message': 'No interface defined for URL.'
... | [
"POST /api/v1/results/<int:id>/commands."
] |
Please provide a description of the function:def create(cls, result_id=None, summary=None, file_modified_at=None):
asset = cls(result_id, summary, file_modified_at)
db.session.add(asset)
db.session.commit()
return asset | [
"Initialize an instance and save it to db."
] |
Please provide a description of the function:def create(cls, path_name=None, name=None, crawlable=True):
project = cls(path_name, name, crawlable)
db.session.add(project)
db.session.commit()
return collect_results(project, force=True) | [
"initialize an instance and save it to db."
] |
Please provide a description of the function:def serialize(self):
log_items = []
data = msgpack.unpackb(self.data, raw=False)
for item in data.items():
value_to_store = (
None
if not isinstance(item[1], numbers.Number)
or isi... | [
"serialize."
] |
Please provide a description of the function:def run_migrations_online(config):
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
with connectable.connect() as connection:
alembic.context.configur... | [
"Run migrations in 'online' mode.\n\n In this scenario we need to create an Engine and associate a\n connection with the context.\n\n "
] |
Please provide a description of the function:def main():
config = context.config
config.set_main_option("sqlalchemy.url", config.get_main_option('url'))
run_migrations_online(config) | [
"main."
] |
Please provide a description of the function:def load_result_json(result_path, json_file_name):
json_path = os.path.join(result_path, json_file_name)
_list = []
if os.path.isfile(json_path):
with open(json_path) as json_data:
try:
_list = json.load(json_data)
... | [
"load_result_json."
] |
Please provide a description of the function:def crawl_result_path(result_path, include_log):
result = {
'logs': [],
'args': [],
'commands': [],
'snapshots': []
}
if os.path.isdir(result_path):
if include_log:
result['logs'] = load_result_json(result... | [
"crawl_result_path."
] |
Please provide a description of the function:def crawl_result(result, force=False, commit=True):
if not result.crawlable:
return result
now = datetime.datetime.now()
if (not force) and (now - result.updated_at).total_seconds() < 4:
return result
# if log file is not updated, not n... | [
"crawl_results."
] |
Please provide a description of the function:def get(self, id=None):
if id is None:
path = request.args.get('path_name', default=None)
if path is not None:
project = db.session.query(Project).filter_by(
path_name=path).first()
... | [
"get."
] |
Please provide a description of the function:def put(self, id):
project = db.session.query(Project).filter_by(id=id).first()
if project is None:
return jsonify({
'project': None,
'message': 'No interface defined for URL.'
}), 404
... | [
"put."
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.