repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
aetros/aetros-cli
aetros/starter.py
start
def start(logger, full_id, fetch=True, env=None, volumes=None, cpus=None, memory=None, gpu_devices=None, offline=False): """ Starts the job with all logging of a job_id """ owner, name, id = unpack_full_job_id(full_id) if isinstance(sys.stdout, GeneralLogger): # we don't want to have stuff...
python
def start(logger, full_id, fetch=True, env=None, volumes=None, cpus=None, memory=None, gpu_devices=None, offline=False): """ Starts the job with all logging of a job_id """ owner, name, id = unpack_full_job_id(full_id) if isinstance(sys.stdout, GeneralLogger): # we don't want to have stuff...
[ "def", "start", "(", "logger", ",", "full_id", ",", "fetch", "=", "True", ",", "env", "=", "None", ",", "volumes", "=", "None", ",", "cpus", "=", "None", ",", "memory", "=", "None", ",", "gpu_devices", "=", "None", ",", "offline", "=", "False", ")"...
Starts the job with all logging of a job_id
[ "Starts", "the", "job", "with", "all", "logging", "of", "a", "job_id" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/starter.py#L27-L61
aetros/aetros-cli
aetros/utils/pilutil.py
fromimage
def fromimage(im, flatten=False, mode=None): """ Return a copy of a PIL image as a numpy array. Parameters ---------- im : PIL image Input image. flatten : bool If true, convert the output to grey-scale. mode : str, optional Mode to convert image to, e.g. ``'RGB'``. ...
python
def fromimage(im, flatten=False, mode=None): """ Return a copy of a PIL image as a numpy array. Parameters ---------- im : PIL image Input image. flatten : bool If true, convert the output to grey-scale. mode : str, optional Mode to convert image to, e.g. ``'RGB'``. ...
[ "def", "fromimage", "(", "im", ",", "flatten", "=", "False", ",", "mode", "=", "None", ")", ":", "if", "not", "Image", ".", "isImageType", "(", "im", ")", ":", "raise", "TypeError", "(", "\"Input is not a PIL image.\"", ")", "if", "mode", "is", "not", ...
Return a copy of a PIL image as a numpy array. Parameters ---------- im : PIL image Input image. flatten : bool If true, convert the output to grey-scale. mode : str, optional Mode to convert image to, e.g. ``'RGB'``. See the Notes of the `imread` docstring for more...
[ "Return", "a", "copy", "of", "a", "PIL", "image", "as", "a", "numpy", "array", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/pilutil.py#L32-L82
aetros/aetros-cli
aetros/utils/pilutil.py
bytescale
def bytescale(data, cmin=None, cmax=None, high=255, low=0): """ Byte scales an array (image). Byte scaling means converting the input image to uint8 dtype and scaling the range to ``(low, high)`` (default 0-255). If the input image already has dtype uint8, no scaling is done. Parameters --...
python
def bytescale(data, cmin=None, cmax=None, high=255, low=0): """ Byte scales an array (image). Byte scaling means converting the input image to uint8 dtype and scaling the range to ``(low, high)`` (default 0-255). If the input image already has dtype uint8, no scaling is done. Parameters --...
[ "def", "bytescale", "(", "data", ",", "cmin", "=", "None", ",", "cmax", "=", "None", ",", "high", "=", "255", ",", "low", "=", "0", ")", ":", "if", "data", ".", "dtype", "==", "uint8", ":", "return", "data", "if", "high", ">", "255", ":", "rais...
Byte scales an array (image). Byte scaling means converting the input image to uint8 dtype and scaling the range to ``(low, high)`` (default 0-255). If the input image already has dtype uint8, no scaling is done. Parameters ---------- data : ndarray PIL image data array. cmin : sca...
[ "Byte", "scales", "an", "array", "(", "image", ")", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/pilutil.py#L88-L157
aetros/aetros-cli
aetros/utils/pilutil.py
toimage
def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None, mode=None, channel_axis=None): """Takes a numpy array and returns a PIL image. The mode of the PIL image depends on the array shape and the `pal` and `mode` keywords. For 2-D arrays, if `pal` is a valid (N,3) byte-array givi...
python
def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None, mode=None, channel_axis=None): """Takes a numpy array and returns a PIL image. The mode of the PIL image depends on the array shape and the `pal` and `mode` keywords. For 2-D arrays, if `pal` is a valid (N,3) byte-array givi...
[ "def", "toimage", "(", "arr", ",", "high", "=", "255", ",", "low", "=", "0", ",", "cmin", "=", "None", ",", "cmax", "=", "None", ",", "pal", "=", "None", ",", "mode", "=", "None", ",", "channel_axis", "=", "None", ")", ":", "data", "=", "asarra...
Takes a numpy array and returns a PIL image. The mode of the PIL image depends on the array shape and the `pal` and `mode` keywords. For 2-D arrays, if `pal` is a valid (N,3) byte-array giving the RGB values (from 0 to 255) then ``mode='P'``, otherwise ``mode='L'``, unless mode is given as 'F' or ...
[ "Takes", "a", "numpy", "array", "and", "returns", "a", "PIL", "image", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/pilutil.py#L160-L271
aetros/aetros-cli
aetros/utils/pilutil.py
imresize
def imresize(arr, size, interp='bilinear', mode=None): """ Resize an image. Parameters ---------- arr : ndarray The array of image to be resized. size : int, float or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size ...
python
def imresize(arr, size, interp='bilinear', mode=None): """ Resize an image. Parameters ---------- arr : ndarray The array of image to be resized. size : int, float or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size ...
[ "def", "imresize", "(", "arr", ",", "size", ",", "interp", "=", "'bilinear'", ",", "mode", "=", "None", ")", ":", "im", "=", "toimage", "(", "arr", ",", "mode", "=", "mode", ")", "ts", "=", "type", "(", "size", ")", "if", "issubdtype", "(", "ts",...
Resize an image. Parameters ---------- arr : ndarray The array of image to be resized. size : int, float or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : str, optional Interpolat...
[ "Resize", "an", "image", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/pilutil.py#L275-L318
aetros/aetros-cli
aetros/client.py
BackendClient.connect
def connect(self, channel): """ In the write-thread we detect that no connection is living anymore and try always again. Up to the 3 connection try, we report to user. We keep trying but in silence. Also, when more than 10 connection tries are detected, we delay extra 15 seconds. ...
python
def connect(self, channel): """ In the write-thread we detect that no connection is living anymore and try always again. Up to the 3 connection try, we report to user. We keep trying but in silence. Also, when more than 10 connection tries are detected, we delay extra 15 seconds. ...
[ "def", "connect", "(", "self", ",", "channel", ")", ":", "if", "self", ".", "connection_tries", ">", "10", ":", "time", ".", "sleep", "(", "10", ")", "if", "self", ".", "in_connecting", "[", "channel", "]", ":", "return", "False", "self", ".", "in_co...
In the write-thread we detect that no connection is living anymore and try always again. Up to the 3 connection try, we report to user. We keep trying but in silence. Also, when more than 10 connection tries are detected, we delay extra 15 seconds.
[ "In", "the", "write", "-", "thread", "we", "detect", "that", "no", "connection", "is", "living", "anymore", "and", "try", "always", "again", ".", "Up", "to", "the", "3", "connection", "try", "we", "report", "to", "user", ".", "We", "keep", "trying", "b...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L196-L310
aetros/aetros-cli
aetros/client.py
BackendClient._end_channel
def _end_channel(self, channel): """ Soft end of ssh channel. End the writing thread as soon as the message queue is empty. """ self.stop_on_empty_queue[channel] = True # by joining the we wait until its loop finishes. # it won't loop forever since we've set self.stop_on...
python
def _end_channel(self, channel): """ Soft end of ssh channel. End the writing thread as soon as the message queue is empty. """ self.stop_on_empty_queue[channel] = True # by joining the we wait until its loop finishes. # it won't loop forever since we've set self.stop_on...
[ "def", "_end_channel", "(", "self", ",", "channel", ")", ":", "self", ".", "stop_on_empty_queue", "[", "channel", "]", "=", "True", "# by joining the we wait until its loop finishes.", "# it won't loop forever since we've set self.stop_on_empty_queue=True", "write_thread", "=",...
Soft end of ssh channel. End the writing thread as soon as the message queue is empty.
[ "Soft", "end", "of", "ssh", "channel", ".", "End", "the", "writing", "thread", "as", "soon", "as", "the", "message", "queue", "is", "empty", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L458-L468
aetros/aetros-cli
aetros/client.py
BackendClient.wait_sending_last_messages
def wait_sending_last_messages(self): """ Requests all channels to close and waits for it. """ if self.active and self.online is not False: self.logger.debug("client sends last %s messages ..." % ([str(i) + ':' + str(len(x)) for i, x in six.iteri...
python
def wait_sending_last_messages(self): """ Requests all channels to close and waits for it. """ if self.active and self.online is not False: self.logger.debug("client sends last %s messages ..." % ([str(i) + ':' + str(len(x)) for i, x in six.iteri...
[ "def", "wait_sending_last_messages", "(", "self", ")", ":", "if", "self", ".", "active", "and", "self", ".", "online", "is", "not", "False", ":", "self", ".", "logger", ".", "debug", "(", "\"client sends last %s messages ...\"", "%", "(", "[", "str", "(", ...
Requests all channels to close and waits for it.
[ "Requests", "all", "channels", "to", "close", "and", "waits", "for", "it", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L470-L491
aetros/aetros-cli
aetros/client.py
BackendClient.wait_until_queue_empty
def wait_until_queue_empty(self, channels, report=True, clear_end=True): """ Waits until all queues of channels are empty. """ state = {'message': ''} self.logger.debug("wait_until_queue_empty: report=%s %s" % (str(report), str([channel+':'+str(len(self...
python
def wait_until_queue_empty(self, channels, report=True, clear_end=True): """ Waits until all queues of channels are empty. """ state = {'message': ''} self.logger.debug("wait_until_queue_empty: report=%s %s" % (str(report), str([channel+':'+str(len(self...
[ "def", "wait_until_queue_empty", "(", "self", ",", "channels", ",", "report", "=", "True", ",", "clear_end", "=", "True", ")", ":", "state", "=", "{", "'message'", ":", "''", "}", "self", ".", "logger", ".", "debug", "(", "\"wait_until_queue_empty: report=%s...
Waits until all queues of channels are empty.
[ "Waits", "until", "all", "queues", "of", "channels", "are", "empty", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L496-L537
aetros/aetros-cli
aetros/client.py
BackendClient.send_message
def send_message(self, message, channel): """ Internal. Sends the actual message from a queue entry. """ if not self.is_connected(channel): return False message['_sending'] = True if '_data' in message: data = message['_data'] else: ...
python
def send_message(self, message, channel): """ Internal. Sends the actual message from a queue entry. """ if not self.is_connected(channel): return False message['_sending'] = True if '_data' in message: data = message['_data'] else: ...
[ "def", "send_message", "(", "self", ",", "message", ",", "channel", ")", ":", "if", "not", "self", ".", "is_connected", "(", "channel", ")", ":", "return", "False", "message", "[", "'_sending'", "]", "=", "True", "if", "'_data'", "in", "message", ":", ...
Internal. Sends the actual message from a queue entry.
[ "Internal", ".", "Sends", "the", "actual", "message", "from", "a", "queue", "entry", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L647-L696
aetros/aetros-cli
aetros/client.py
BackendClient.wait_for_at_least_one_message
def wait_for_at_least_one_message(self, channel): """ Reads until we receive at least one message we can unpack. Return all found messages. """ unpacker = msgpack.Unpacker(encoding='utf-8') while True: try: start = time.time() chunk =...
python
def wait_for_at_least_one_message(self, channel): """ Reads until we receive at least one message we can unpack. Return all found messages. """ unpacker = msgpack.Unpacker(encoding='utf-8') while True: try: start = time.time() chunk =...
[ "def", "wait_for_at_least_one_message", "(", "self", ",", "channel", ")", ":", "unpacker", "=", "msgpack", ".", "Unpacker", "(", "encoding", "=", "'utf-8'", ")", "while", "True", ":", "try", ":", "start", "=", "time", ".", "time", "(", ")", "chunk", "=",...
Reads until we receive at least one message we can unpack. Return all found messages.
[ "Reads", "until", "we", "receive", "at", "least", "one", "message", "we", "can", "unpack", ".", "Return", "all", "found", "messages", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L712-L740
aetros/aetros-cli
aetros/client.py
BackendClient.read
def read(self, channel): """ Reads from the socket and tries to unpack the message. If successful (because msgpack was able to unpack) then we return that message. Else None. Keep calling .read() when new data is available so we try it again. """ if not self.ssh_channel[...
python
def read(self, channel): """ Reads from the socket and tries to unpack the message. If successful (because msgpack was able to unpack) then we return that message. Else None. Keep calling .read() when new data is available so we try it again. """ if not self.ssh_channel[...
[ "def", "read", "(", "self", ",", "channel", ")", ":", "if", "not", "self", ".", "ssh_channel", "[", "channel", "]", ".", "recv_ready", "(", ")", ":", "return", "try", ":", "start", "=", "time", ".", "time", "(", ")", "chunk", "=", "self", ".", "s...
Reads from the socket and tries to unpack the message. If successful (because msgpack was able to unpack) then we return that message. Else None. Keep calling .read() when new data is available so we try it again.
[ "Reads", "from", "the", "socket", "and", "tries", "to", "unpack", "the", "message", ".", "If", "successful", "(", "because", "msgpack", "was", "able", "to", "unpack", ")", "then", "we", "return", "that", "message", ".", "Else", "None", ".", "Keep", "call...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L742-L776
aetros/aetros-cli
aetros/utils/__init__.py
raise_sigint
def raise_sigint(): """ Raising the SIGINT signal in the current process and all sub-processes. os.kill() only issues a signal in the current process (without subprocesses). CTRL+C on the console sends the signal to the process group (which we need). """ if hasattr(signal, 'CTRL_C_EVENT'): ...
python
def raise_sigint(): """ Raising the SIGINT signal in the current process and all sub-processes. os.kill() only issues a signal in the current process (without subprocesses). CTRL+C on the console sends the signal to the process group (which we need). """ if hasattr(signal, 'CTRL_C_EVENT'): ...
[ "def", "raise_sigint", "(", ")", ":", "if", "hasattr", "(", "signal", ",", "'CTRL_C_EVENT'", ")", ":", "# windows. Need CTRL_C_EVENT to raise the signal in the whole process group", "os", ".", "kill", "(", "os", ".", "getpid", "(", ")", ",", "signal", ".", "CTRL_C...
Raising the SIGINT signal in the current process and all sub-processes. os.kill() only issues a signal in the current process (without subprocesses). CTRL+C on the console sends the signal to the process group (which we need).
[ "Raising", "the", "SIGINT", "signal", "in", "the", "current", "process", "and", "all", "sub", "-", "processes", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/__init__.py#L813-L829
aetros/aetros-cli
aetros/utils/__init__.py
human_size
def human_size(size_bytes, precision=0): """ Format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB Note that bytes/KB will be reported in whole numbers but MB and above will have greater precision e.g. 1 byte, 43 bytes, 443 KB, 4.3 MB, 4.43 GB, etc """ if size_bytes == ...
python
def human_size(size_bytes, precision=0): """ Format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB Note that bytes/KB will be reported in whole numbers but MB and above will have greater precision e.g. 1 byte, 43 bytes, 443 KB, 4.3 MB, 4.43 GB, etc """ if size_bytes == ...
[ "def", "human_size", "(", "size_bytes", ",", "precision", "=", "0", ")", ":", "if", "size_bytes", "==", "1", ":", "# because I really hate unnecessary plurals", "return", "\"1 byte\"", "suffixes_table", "=", "[", "(", "'bytes'", ",", "0", ")", ",", "(", "'KB'"...
Format a size in bytes into a 'human' file size, e.g. bytes, KB, MB, GB, TB, PB Note that bytes/KB will be reported in whole numbers but MB and above will have greater precision e.g. 1 byte, 43 bytes, 443 KB, 4.3 MB, 4.43 GB, etc
[ "Format", "a", "size", "in", "bytes", "into", "a", "human", "file", "size", "e", ".", "g", ".", "bytes", "KB", "MB", "GB", "TB", "PB", "Note", "that", "bytes", "/", "KB", "will", "be", "reported", "in", "whole", "numbers", "but", "MB", "and", "abov...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/__init__.py#L877-L900
aetros/aetros-cli
aetros/utils/__init__.py
array_to_img
def array_to_img(x, scale=True): """ x should be shape (channels, width, height) """ from PIL import Image if x.ndim != 3: raise Exception('Unsupported shape : ', str(x.shape), '. Need (channels, width, height)') if scale: x += max(-np.min(x), 0) x /= np.max(x) x ...
python
def array_to_img(x, scale=True): """ x should be shape (channels, width, height) """ from PIL import Image if x.ndim != 3: raise Exception('Unsupported shape : ', str(x.shape), '. Need (channels, width, height)') if scale: x += max(-np.min(x), 0) x /= np.max(x) x ...
[ "def", "array_to_img", "(", "x", ",", "scale", "=", "True", ")", ":", "from", "PIL", "import", "Image", "if", "x", ".", "ndim", "!=", "3", ":", "raise", "Exception", "(", "'Unsupported shape : '", ",", "str", "(", "x", ".", "shape", ")", ",", "'. Nee...
x should be shape (channels, width, height)
[ "x", "should", "be", "shape", "(", "channels", "width", "height", ")" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/__init__.py#L903-L925
aetros/aetros-cli
aetros/Trainer.py
Trainer.set_generator_validation_nb
def set_generator_validation_nb(self, number): """ sets self.nb_val_samples which is used in model.fit if input is a generator :param number: :return: """ self.nb_val_samples = number diff_to_batch = number % self.get_batch_size() if diff_to_batch > 0: ...
python
def set_generator_validation_nb(self, number): """ sets self.nb_val_samples which is used in model.fit if input is a generator :param number: :return: """ self.nb_val_samples = number diff_to_batch = number % self.get_batch_size() if diff_to_batch > 0: ...
[ "def", "set_generator_validation_nb", "(", "self", ",", "number", ")", ":", "self", ".", "nb_val_samples", "=", "number", "diff_to_batch", "=", "number", "%", "self", ".", "get_batch_size", "(", ")", "if", "diff_to_batch", ">", "0", ":", "self", ".", "nb_val...
sets self.nb_val_samples which is used in model.fit if input is a generator :param number: :return:
[ "sets", "self", ".", "nb_val_samples", "which", "is", "used", "in", "model", ".", "fit", "if", "input", "is", "a", "generator", ":", "param", "number", ":", ":", "return", ":" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/Trainer.py#L64-L78
aetros/aetros-cli
aetros/Trainer.py
Trainer.set_generator_training_nb
def set_generator_training_nb(self, number): """ sets self.samples_per_epoch which is used in model.fit if input is a generator :param number: :return: """ self.samples_per_epoch = number diff_to_batch = number % self.get_batch_size() if diff_to_batch > 0...
python
def set_generator_training_nb(self, number): """ sets self.samples_per_epoch which is used in model.fit if input is a generator :param number: :return: """ self.samples_per_epoch = number diff_to_batch = number % self.get_batch_size() if diff_to_batch > 0...
[ "def", "set_generator_training_nb", "(", "self", ",", "number", ")", ":", "self", ".", "samples_per_epoch", "=", "number", "diff_to_batch", "=", "number", "%", "self", ".", "get_batch_size", "(", ")", "if", "diff_to_batch", ">", "0", ":", "self", ".", "sampl...
sets self.samples_per_epoch which is used in model.fit if input is a generator :param number: :return:
[ "sets", "self", ".", "samples_per_epoch", "which", "is", "used", "in", "model", ".", "fit", "if", "input", "is", "a", "generator", ":", "param", "number", ":", ":", "return", ":" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/Trainer.py#L80-L90
aetros/aetros-cli
aetros/logger.py
GeneralLogger.attach
def attach(self, buffer, read_line=None): """ Read buffer until end (read() returns '') and sends it to self.logger and self.job_backend. :param buffer: a buffer instance with block read() or readline() method :param read_line: callable or True to read line per line. If callable is give...
python
def attach(self, buffer, read_line=None): """ Read buffer until end (read() returns '') and sends it to self.logger and self.job_backend. :param buffer: a buffer instance with block read() or readline() method :param read_line: callable or True to read line per line. If callable is give...
[ "def", "attach", "(", "self", ",", "buffer", ",", "read_line", "=", "None", ")", ":", "bid", "=", "id", "(", "buffer", ")", "self", ".", "attach_last_messages", "[", "bid", "]", "=", "b''", "def", "reader", "(", ")", ":", "current_line", "=", "b''", ...
Read buffer until end (read() returns '') and sends it to self.logger and self.job_backend. :param buffer: a buffer instance with block read() or readline() method :param read_line: callable or True to read line per line. If callable is given, it will be executed per line and ...
[ "Read", "buffer", "until", "end", "(", "read", "()", "returns", ")", "and", "sends", "it", "to", "self", ".", "logger", "and", "self", ".", "job_backend", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/logger.py#L69-L143
aetros/aetros-cli
aetros/utils/image.py
upscale
def upscale(image, ratio): """ return upscaled image array Arguments: image -- a (H,W,C) numpy.ndarray ratio -- scaling factor (>1) """ if not isinstance(image, np.ndarray): raise ValueError('Expected ndarray') if ratio < 1: raise ValueError('Ratio must be greater than 1 ...
python
def upscale(image, ratio): """ return upscaled image array Arguments: image -- a (H,W,C) numpy.ndarray ratio -- scaling factor (>1) """ if not isinstance(image, np.ndarray): raise ValueError('Expected ndarray') if ratio < 1: raise ValueError('Ratio must be greater than 1 ...
[ "def", "upscale", "(", "image", ",", "ratio", ")", ":", "if", "not", "isinstance", "(", "image", ",", "np", ".", "ndarray", ")", ":", "raise", "ValueError", "(", "'Expected ndarray'", ")", "if", "ratio", "<", "1", ":", "raise", "ValueError", "(", "'Rat...
return upscaled image array Arguments: image -- a (H,W,C) numpy.ndarray ratio -- scaling factor (>1)
[ "return", "upscaled", "image", "array", "Arguments", ":", "image", "--", "a", "(", "H", "W", "C", ")", "numpy", ".", "ndarray", "ratio", "--", "scaling", "factor", "(", ">", "1", ")" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L40-L57
aetros/aetros-cli
aetros/utils/image.py
resize_image
def resize_image(image, height, width, channels=None, resize_mode=None ): """ Resizes an image and returns it as a np.array Arguments: image -- a PIL.Image or numpy.ndarray height -- height of new image width -- width of new image Keyword Ar...
python
def resize_image(image, height, width, channels=None, resize_mode=None ): """ Resizes an image and returns it as a np.array Arguments: image -- a PIL.Image or numpy.ndarray height -- height of new image width -- width of new image Keyword Ar...
[ "def", "resize_image", "(", "image", ",", "height", ",", "width", ",", "channels", "=", "None", ",", "resize_mode", "=", "None", ")", ":", "if", "resize_mode", "is", "None", ":", "resize_mode", "=", "'squash'", "if", "resize_mode", "not", "in", "[", "'cr...
Resizes an image and returns it as a np.array Arguments: image -- a PIL.Image or numpy.ndarray height -- height of new image width -- width of new image Keyword Arguments: channels -- channels of new image (stays unchanged if not specified) resize_mode -- can be crop, squash, fill or half_cr...
[ "Resizes", "an", "image", "and", "returns", "it", "as", "a", "np", ".", "array", "Arguments", ":", "image", "--", "a", "PIL", ".", "Image", "or", "numpy", ".", "ndarray", "height", "--", "height", "of", "new", "image", "width", "--", "width", "of", "...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L60-L207
aetros/aetros-cli
aetros/utils/image.py
embed_image_html
def embed_image_html(image): """ Returns an image embedded in HTML base64 format (Based on Caffe's web_demo) Arguments: image -- a PIL.Image or np.ndarray """ if image is None: return None elif isinstance(image, PIL.Image.Image): pass elif isinstance(image, np.ndarray...
python
def embed_image_html(image): """ Returns an image embedded in HTML base64 format (Based on Caffe's web_demo) Arguments: image -- a PIL.Image or np.ndarray """ if image is None: return None elif isinstance(image, PIL.Image.Image): pass elif isinstance(image, np.ndarray...
[ "def", "embed_image_html", "(", "image", ")", ":", "if", "image", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "image", ",", "PIL", ".", "Image", ".", "Image", ")", ":", "pass", "elif", "isinstance", "(", "image", ",", "np", ".", "...
Returns an image embedded in HTML base64 format (Based on Caffe's web_demo) Arguments: image -- a PIL.Image or np.ndarray
[ "Returns", "an", "image", "embedded", "in", "HTML", "base64", "format", "(", "Based", "on", "Caffe", "s", "web_demo", ")", "Arguments", ":", "image", "--", "a", "PIL", ".", "Image", "or", "np", ".", "ndarray" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L210-L237
aetros/aetros-cli
aetros/utils/image.py
add_bboxes_to_image
def add_bboxes_to_image(image, bboxes, color='red', width=1): """ Draw rectangles on the image for the bounding boxes Returns a PIL.Image Arguments: image -- input image bboxes -- bounding boxes in the [((l, t), (r, b)), ...] format Keyword arguments: color -- color to draw the rectangle...
python
def add_bboxes_to_image(image, bboxes, color='red', width=1): """ Draw rectangles on the image for the bounding boxes Returns a PIL.Image Arguments: image -- input image bboxes -- bounding boxes in the [((l, t), (r, b)), ...] format Keyword arguments: color -- color to draw the rectangle...
[ "def", "add_bboxes_to_image", "(", "image", ",", "bboxes", ",", "color", "=", "'red'", ",", "width", "=", "1", ")", ":", "def", "expanded_bbox", "(", "bbox", ",", "n", ")", ":", "\"\"\"\n Grow the bounding box by n pixels\n \"\"\"", "l", "=", "min"...
Draw rectangles on the image for the bounding boxes Returns a PIL.Image Arguments: image -- input image bboxes -- bounding boxes in the [((l, t), (r, b)), ...] format Keyword arguments: color -- color to draw the rectangles width -- line width of the rectangles Example: image = Image...
[ "Draw", "rectangles", "on", "the", "image", "for", "the", "bounding", "boxes", "Returns", "a", "PIL", ".", "Image", "Arguments", ":", "image", "--", "input", "image", "bboxes", "--", "bounding", "boxes", "in", "the", "[", "((", "l", "t", ")", "(", "r",...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L240-L271
aetros/aetros-cli
aetros/utils/image.py
get_layer_vis_square
def get_layer_vis_square(data, allow_heatmap=True, normalize=True, min_img_dim=100, max_width=1200, channel_order='RGB', colormap='jet', ): "...
python
def get_layer_vis_square(data, allow_heatmap=True, normalize=True, min_img_dim=100, max_width=1200, channel_order='RGB', colormap='jet', ): "...
[ "def", "get_layer_vis_square", "(", "data", ",", "allow_heatmap", "=", "True", ",", "normalize", "=", "True", ",", "min_img_dim", "=", "100", ",", "max_width", "=", "1200", ",", "channel_order", "=", "'RGB'", ",", "colormap", "=", "'jet'", ",", ")", ":", ...
Returns a vis_square for the given layer data Arguments: data -- a np.ndarray Keyword arguments: allow_heatmap -- if True, convert single channel images to heatmaps normalize -- whether to normalize the data when visualizing max_width -- maximum width for the vis_square
[ "Returns", "a", "vis_square", "for", "the", "given", "layer", "data", "Arguments", ":", "data", "--", "a", "np", ".", "ndarray", "Keyword", "arguments", ":", "allow_heatmap", "--", "if", "True", "convert", "single", "channel", "images", "to", "heatmaps", "no...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L274-L339
aetros/aetros-cli
aetros/utils/image.py
get_color_map
def get_color_map(name): """ Return a colormap as (redmap, greenmap, bluemap) Arguments: name -- the name of the colormap. If unrecognized, will default to 'jet'. """ redmap = [0] greenmap = [0] bluemap = [0] if name == 'white': # essentially a noop redmap = [0, 1] ...
python
def get_color_map(name): """ Return a colormap as (redmap, greenmap, bluemap) Arguments: name -- the name of the colormap. If unrecognized, will default to 'jet'. """ redmap = [0] greenmap = [0] bluemap = [0] if name == 'white': # essentially a noop redmap = [0, 1] ...
[ "def", "get_color_map", "(", "name", ")", ":", "redmap", "=", "[", "0", "]", "greenmap", "=", "[", "0", "]", "bluemap", "=", "[", "0", "]", "if", "name", "==", "'white'", ":", "# essentially a noop", "redmap", "=", "[", "0", ",", "1", "]", "greenma...
Return a colormap as (redmap, greenmap, bluemap) Arguments: name -- the name of the colormap. If unrecognized, will default to 'jet'.
[ "Return", "a", "colormap", "as", "(", "redmap", "greenmap", "bluemap", ")", "Arguments", ":", "name", "--", "the", "name", "of", "the", "colormap", ".", "If", "unrecognized", "will", "default", "to", "jet", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L493-L534
aetros/aetros-cli
aetros/git.py
Git.prepare_index_file
def prepare_index_file(self): """ Makes sure that GIT index file we use per job (by modifying environment variable GIT_INDEX_FILE) is not locked and empty. Git.fetch_job uses `git read-tree` to updates this index. For new jobs, we start with an empty index - that's why we delete it every...
python
def prepare_index_file(self): """ Makes sure that GIT index file we use per job (by modifying environment variable GIT_INDEX_FILE) is not locked and empty. Git.fetch_job uses `git read-tree` to updates this index. For new jobs, we start with an empty index - that's why we delete it every...
[ "def", "prepare_index_file", "(", "self", ")", ":", "if", "os", ".", "getenv", "(", "'AETROS_GIT_INDEX_FILE'", ")", ":", "self", ".", "index_path", "=", "os", ".", "getenv", "(", "'AETROS_GIT_INDEX_FILE'", ")", "return", "import", "tempfile", "h", ",", "path...
Makes sure that GIT index file we use per job (by modifying environment variable GIT_INDEX_FILE) is not locked and empty. Git.fetch_job uses `git read-tree` to updates this index. For new jobs, we start with an empty index - that's why we delete it every time.
[ "Makes", "sure", "that", "GIT", "index", "file", "we", "use", "per", "job", "(", "by", "modifying", "environment", "variable", "GIT_INDEX_FILE", ")", "is", "not", "locked", "and", "empty", ".", "Git", ".", "fetch_job", "uses", "git", "read", "-", "tree", ...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L266-L286
aetros/aetros-cli
aetros/git.py
Git.fetch_job
def fetch_job(self, job_id, checkout=False): """ Fetch the current job reference (refs/aetros/job/<id>) from origin and (when checkout=True)read its tree to the current git index and checkout into working director. """ self.job_id = job_id self.logger.debug("Git fetch jo...
python
def fetch_job(self, job_id, checkout=False): """ Fetch the current job reference (refs/aetros/job/<id>) from origin and (when checkout=True)read its tree to the current git index and checkout into working director. """ self.job_id = job_id self.logger.debug("Git fetch jo...
[ "def", "fetch_job", "(", "self", ",", "job_id", ",", "checkout", "=", "False", ")", ":", "self", ".", "job_id", "=", "job_id", "self", ".", "logger", ".", "debug", "(", "\"Git fetch job reference %s\"", "%", "(", "self", ".", "ref_head", ",", ")", ")", ...
Fetch the current job reference (refs/aetros/job/<id>) from origin and (when checkout=True)read its tree to the current git index and checkout into working director.
[ "Fetch", "the", "current", "job", "reference", "(", "refs", "/", "aetros", "/", "job", "/", "<id", ">", ")", "from", "origin", "and", "(", "when", "checkout", "=", "True", ")", "read", "its", "tree", "to", "the", "current", "git", "index", "and", "ch...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L288-L308
aetros/aetros-cli
aetros/git.py
Git.read_job
def read_job(self, job_id, checkout=False): """ Reads head and reads the tree into index, and checkout the work-tree when checkout=True. This does not fetch the job from the actual server. It needs to be in the local git already. """ self.job_id = job_id commit ...
python
def read_job(self, job_id, checkout=False): """ Reads head and reads the tree into index, and checkout the work-tree when checkout=True. This does not fetch the job from the actual server. It needs to be in the local git already. """ self.job_id = job_id commit ...
[ "def", "read_job", "(", "self", ",", "job_id", ",", "checkout", "=", "False", ")", ":", "self", ".", "job_id", "=", "job_id", "commit", "=", "self", ".", "get_head_commit", "(", ")", "self", ".", "logger", ".", "debug", "(", "'Job ref points to '", "+", ...
Reads head and reads the tree into index, and checkout the work-tree when checkout=True. This does not fetch the job from the actual server. It needs to be in the local git already.
[ "Reads", "head", "and", "reads", "the", "tree", "into", "index", "and", "checkout", "the", "work", "-", "tree", "when", "checkout", "=", "True", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L317-L343
aetros/aetros-cli
aetros/git.py
Git.create_job_id
def create_job_id(self, data): """ Create a new job id and reference (refs/aetros/job/<id>) by creating a new commit with empty tree. That root commit is the actual job id. A reference is then created to the newest (head) commit of this commit history. The reference will always be update...
python
def create_job_id(self, data): """ Create a new job id and reference (refs/aetros/job/<id>) by creating a new commit with empty tree. That root commit is the actual job id. A reference is then created to the newest (head) commit of this commit history. The reference will always be update...
[ "def", "create_job_id", "(", "self", ",", "data", ")", ":", "self", ".", "add_file", "(", "'aetros/job.json'", ",", "simplejson", ".", "dumps", "(", "data", ",", "indent", "=", "4", ")", ")", "tree_id", "=", "self", ".", "write_tree", "(", ")", "self",...
Create a new job id and reference (refs/aetros/job/<id>) by creating a new commit with empty tree. That root commit is the actual job id. A reference is then created to the newest (head) commit of this commit history. The reference will always be updated once a new commit is added.
[ "Create", "a", "new", "job", "id", "and", "reference", "(", "refs", "/", "aetros", "/", "job", "/", "<id", ">", ")", "by", "creating", "a", "new", "commit", "with", "empty", "tree", ".", "That", "root", "commit", "is", "the", "actual", "job", "id", ...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L388-L415
aetros/aetros-cli
aetros/git.py
Git.start_push_sync
def start_push_sync(self): """ Starts the detection of unsynced Git data. """ self.active_thread = True self.active_push = True self.thread_push_instance = Thread(target=self.thread_push) self.thread_push_instance.daemon = True self.thread_push_instance.s...
python
def start_push_sync(self): """ Starts the detection of unsynced Git data. """ self.active_thread = True self.active_push = True self.thread_push_instance = Thread(target=self.thread_push) self.thread_push_instance.daemon = True self.thread_push_instance.s...
[ "def", "start_push_sync", "(", "self", ")", ":", "self", ".", "active_thread", "=", "True", "self", ".", "active_push", "=", "True", "self", ".", "thread_push_instance", "=", "Thread", "(", "target", "=", "self", ".", "thread_push", ")", "self", ".", "thre...
Starts the detection of unsynced Git data.
[ "Starts", "the", "detection", "of", "unsynced", "Git", "data", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L417-L426
aetros/aetros-cli
aetros/git.py
Git.stop
def stop(self): """ Stops the `git push` thread and commits all streamed files (Git.store_file and Git.stream_file), followed by a final git push. You can not start the process again. """ self.active_thread = False if self.thread_push_instance and self.t...
python
def stop(self): """ Stops the `git push` thread and commits all streamed files (Git.store_file and Git.stream_file), followed by a final git push. You can not start the process again. """ self.active_thread = False if self.thread_push_instance and self.t...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "active_thread", "=", "False", "if", "self", ".", "thread_push_instance", "and", "self", ".", "thread_push_instance", ".", "isAlive", "(", ")", ":", "self", ".", "thread_push_instance", ".", "join", "(", "...
Stops the `git push` thread and commits all streamed files (Git.store_file and Git.stream_file), followed by a final git push. You can not start the process again.
[ "Stops", "the", "git", "push", "thread", "and", "commits", "all", "streamed", "files", "(", "Git", ".", "store_file", "and", "Git", ".", "stream_file", ")", "followed", "by", "a", "final", "git", "push", ".", "You", "can", "not", "start", "the", "process...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L428-L477
aetros/aetros-cli
aetros/git.py
Git.batch_commit
def batch_commit(self, message): """ Instead of committing a lot of small commits you can batch it together using this controller. Example: with git.batch_commit('BATCHED'): git.commit_file('my commit 1', 'path/to/file', 'content from file') git.commit_json_file...
python
def batch_commit(self, message): """ Instead of committing a lot of small commits you can batch it together using this controller. Example: with git.batch_commit('BATCHED'): git.commit_file('my commit 1', 'path/to/file', 'content from file') git.commit_json_file...
[ "def", "batch_commit", "(", "self", ",", "message", ")", ":", "class", "controlled_execution", ":", "def", "__init__", "(", "self", ",", "git", ",", "message", ")", ":", "self", ".", "git", "=", "git", "self", ".", "message", "=", "message", "def", "__...
Instead of committing a lot of small commits you can batch it together using this controller. Example: with git.batch_commit('BATCHED'): git.commit_file('my commit 1', 'path/to/file', 'content from file') git.commit_json_file('[1, 2, 3]', 'path/to/file2', 'json array') ...
[ "Instead", "of", "committing", "a", "lot", "of", "small", "commits", "you", "can", "batch", "it", "together", "using", "this", "controller", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L489-L530
aetros/aetros-cli
aetros/git.py
Git.store_file
def store_file(self, path, data, fast_lane=True): """ Store the file in temp folder and stream it to server if online. This makes sure that we have all newest data of this file on the server directly. This method always overwrites the content of path. If you want to a...
python
def store_file(self, path, data, fast_lane=True): """ Store the file in temp folder and stream it to server if online. This makes sure that we have all newest data of this file on the server directly. This method always overwrites the content of path. If you want to a...
[ "def", "store_file", "(", "self", ",", "path", ",", "data", ",", "fast_lane", "=", "True", ")", ":", "self", ".", "stream_files_lock", ".", "acquire", "(", ")", "try", ":", "full_path", "=", "os", ".", "path", ".", "normpath", "(", "self", ".", "temp...
Store the file in temp folder and stream it to server if online. This makes sure that we have all newest data of this file on the server directly. This method always overwrites the content of path. If you want to append always the content, use Git.stream_file() instead. ...
[ "Store", "the", "file", "in", "temp", "folder", "and", "stream", "it", "to", "server", "if", "online", ".", "This", "makes", "sure", "that", "we", "have", "all", "newest", "data", "of", "this", "file", "on", "the", "server", "directly", ".", "This", "m...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L541-L580
aetros/aetros-cli
aetros/git.py
Git.stream_file
def stream_file(self, path, fast_lane=True): """ Create a temp file, stream it to the server if online and append its content using the write() method. This makes sure that we have all newest data of this file on the server directly. At the end of the job, the content the serve...
python
def stream_file(self, path, fast_lane=True): """ Create a temp file, stream it to the server if online and append its content using the write() method. This makes sure that we have all newest data of this file on the server directly. At the end of the job, the content the serve...
[ "def", "stream_file", "(", "self", ",", "path", ",", "fast_lane", "=", "True", ")", ":", "# create temp file", "# open temp file", "# register stream file and write locally", "# on end() git_commit that file locally", "# create socket connection to server", "# stream file to server...
Create a temp file, stream it to the server if online and append its content using the write() method. This makes sure that we have all newest data of this file on the server directly. At the end of the job, the content the server received is stored as git blob on the server. It is then commit...
[ "Create", "a", "temp", "file", "stream", "it", "to", "the", "server", "if", "online", "and", "append", "its", "content", "using", "the", "write", "()", "method", ".", "This", "makes", "sure", "that", "we", "have", "all", "newest", "data", "of", "this", ...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L582-L651
aetros/aetros-cli
aetros/git.py
Git.add_index
def add_index(self, mode, blob_id, path): """ Add new entry to the current index :param tree: :return: """ self.command_exec(['update-index', '--add', '--cacheinfo', mode, blob_id, path])
python
def add_index(self, mode, blob_id, path): """ Add new entry to the current index :param tree: :return: """ self.command_exec(['update-index', '--add', '--cacheinfo', mode, blob_id, path])
[ "def", "add_index", "(", "self", ",", "mode", ",", "blob_id", ",", "path", ")", ":", "self", ".", "command_exec", "(", "[", "'update-index'", ",", "'--add'", ",", "'--cacheinfo'", ",", "mode", ",", "blob_id", ",", "path", "]", ")" ]
Add new entry to the current index :param tree: :return:
[ "Add", "new", "entry", "to", "the", "current", "index", ":", "param", "tree", ":", ":", "return", ":" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L656-L662
aetros/aetros-cli
aetros/git.py
Git.add_file
def add_file(self, git_path, content): """ Add a new file as blob in the storage and add its tree entry into the index. :param git_path: str :param content: str """ blob_id = self.write_blob(content) self.add_index('100644', blob_id, git_path)
python
def add_file(self, git_path, content): """ Add a new file as blob in the storage and add its tree entry into the index. :param git_path: str :param content: str """ blob_id = self.write_blob(content) self.add_index('100644', blob_id, git_path)
[ "def", "add_file", "(", "self", ",", "git_path", ",", "content", ")", ":", "blob_id", "=", "self", ".", "write_blob", "(", "content", ")", "self", ".", "add_index", "(", "'100644'", ",", "blob_id", ",", "git_path", ")" ]
Add a new file as blob in the storage and add its tree entry into the index. :param git_path: str :param content: str
[ "Add", "a", "new", "file", "as", "blob", "in", "the", "storage", "and", "add", "its", "tree", "entry", "into", "the", "index", ".", ":", "param", "git_path", ":", "str", ":", "param", "content", ":", "str" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L691-L699
aetros/aetros-cli
aetros/git.py
Git.add_file_path_in_work_tree
def add_file_path_in_work_tree(self, path, work_tree, verbose=True): """ Add a new file as blob in the storage and add its tree entry into the index. """ args = ['--work-tree', work_tree, 'add', '-f'] if verbose: args.append('--verbose') args.append(path) ...
python
def add_file_path_in_work_tree(self, path, work_tree, verbose=True): """ Add a new file as blob in the storage and add its tree entry into the index. """ args = ['--work-tree', work_tree, 'add', '-f'] if verbose: args.append('--verbose') args.append(path) ...
[ "def", "add_file_path_in_work_tree", "(", "self", ",", "path", ",", "work_tree", ",", "verbose", "=", "True", ")", ":", "args", "=", "[", "'--work-tree'", ",", "work_tree", ",", "'add'", ",", "'-f'", "]", "if", "verbose", ":", "args", ".", "append", "(",...
Add a new file as blob in the storage and add its tree entry into the index.
[ "Add", "a", "new", "file", "as", "blob", "in", "the", "storage", "and", "add", "its", "tree", "entry", "into", "the", "index", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L705-L713
aetros/aetros-cli
aetros/git.py
Git.commit_file
def commit_file(self, message, path, content): """ Add a new file as blob in the storage, add its tree entry into the index and commit the index. :param message: str :param path: str :param content: str :return: """ if self.git_batch_commit: ...
python
def commit_file(self, message, path, content): """ Add a new file as blob in the storage, add its tree entry into the index and commit the index. :param message: str :param path: str :param content: str :return: """ if self.git_batch_commit: ...
[ "def", "commit_file", "(", "self", ",", "message", ",", "path", ",", "content", ")", ":", "if", "self", ".", "git_batch_commit", ":", "self", ".", "add_file", "(", "path", ",", "content", ")", "self", ".", "git_batch_commit_messages", ".", "append", "(", ...
Add a new file as blob in the storage, add its tree entry into the index and commit the index. :param message: str :param path: str :param content: str :return:
[ "Add", "a", "new", "file", "as", "blob", "in", "the", "storage", "add", "its", "tree", "entry", "into", "the", "index", "and", "commit", "the", "index", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L719-L738
aetros/aetros-cli
aetros/git.py
Git.diff_objects
def diff_objects(self, latest_commit_sha): """ Push all changes to origin, based on objects, not on commits. Important: Call this push after every new commit, or we lose commits. """ base = ['git', '--bare', '--git-dir', self.git_path] object_shas...
python
def diff_objects(self, latest_commit_sha): """ Push all changes to origin, based on objects, not on commits. Important: Call this push after every new commit, or we lose commits. """ base = ['git', '--bare', '--git-dir', self.git_path] object_shas...
[ "def", "diff_objects", "(", "self", ",", "latest_commit_sha", ")", ":", "base", "=", "[", "'git'", ",", "'--bare'", ",", "'--git-dir'", ",", "self", ".", "git_path", "]", "object_shas", "=", "[", "]", "summary", "=", "{", "'commits'", ":", "[", "]", ",...
Push all changes to origin, based on objects, not on commits. Important: Call this push after every new commit, or we lose commits.
[ "Push", "all", "changes", "to", "origin", "based", "on", "objects", "not", "on", "commits", ".", "Important", ":", "Call", "this", "push", "after", "every", "new", "commit", "or", "we", "lose", "commits", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L740-L863
aetros/aetros-cli
aetros/git.py
Git.commit_index
def commit_index(self, message): """ Commit the current index. :param message: str :return: str the generated commit sha """ tree_id = self.write_tree() args = ['commit-tree', tree_id, '-p', self.ref_head] # todo, this can end in a race-condition with ot...
python
def commit_index(self, message): """ Commit the current index. :param message: str :return: str the generated commit sha """ tree_id = self.write_tree() args = ['commit-tree', tree_id, '-p', self.ref_head] # todo, this can end in a race-condition with ot...
[ "def", "commit_index", "(", "self", ",", "message", ")", ":", "tree_id", "=", "self", ".", "write_tree", "(", ")", "args", "=", "[", "'commit-tree'", ",", "tree_id", ",", "'-p'", ",", "self", ".", "ref_head", "]", "# todo, this can end in a race-condition with...
Commit the current index. :param message: str :return: str the generated commit sha
[ "Commit", "the", "current", "index", ".", ":", "param", "message", ":", "str", ":", "return", ":", "str", "the", "generated", "commit", "sha" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L941-L955
aetros/aetros-cli
aetros/git.py
Git.contents
def contents(self, path): """ Reads the given path of current ref_head and returns its content as utf-8 """ try: out, code, err = self.command_exec(['cat-file', '-p', self.ref_head+':'+path]) if not code: return out.decode('utf-8') except E...
python
def contents(self, path): """ Reads the given path of current ref_head and returns its content as utf-8 """ try: out, code, err = self.command_exec(['cat-file', '-p', self.ref_head+':'+path]) if not code: return out.decode('utf-8') except E...
[ "def", "contents", "(", "self", ",", "path", ")", ":", "try", ":", "out", ",", "code", ",", "err", "=", "self", ".", "command_exec", "(", "[", "'cat-file'", ",", "'-p'", ",", "self", ".", "ref_head", "+", "':'", "+", "path", "]", ")", "if", "not"...
Reads the given path of current ref_head and returns its content as utf-8
[ "Reads", "the", "given", "path", "of", "current", "ref_head", "and", "returns", "its", "content", "as", "utf", "-", "8" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L965-L976
aetros/aetros-cli
aetros/keras_model_utils.py
job_start
def job_start(job_backend, trainer, keras_callback): """ Starts the training of a job. Needs job_prepare() first. :type job_backend: JobBackend :type trainer: Trainer :return: """ job_backend.set_status('STARTING') job_model = job_backend.get_job_model() model_provider = job_model...
python
def job_start(job_backend, trainer, keras_callback): """ Starts the training of a job. Needs job_prepare() first. :type job_backend: JobBackend :type trainer: Trainer :return: """ job_backend.set_status('STARTING') job_model = job_backend.get_job_model() model_provider = job_model...
[ "def", "job_start", "(", "job_backend", ",", "trainer", ",", "keras_callback", ")", ":", "job_backend", ".", "set_status", "(", "'STARTING'", ")", "job_model", "=", "job_backend", ".", "get_job_model", "(", ")", "model_provider", "=", "job_model", ".", "get_mode...
Starts the training of a job. Needs job_prepare() first. :type job_backend: JobBackend :type trainer: Trainer :return:
[ "Starts", "the", "training", "of", "a", "job", ".", "Needs", "job_prepare", "()", "first", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/keras_model_utils.py#L34-L93
aetros/aetros-cli
aetros/auto_dataset.py
read_images_in_memory
def read_images_in_memory(job_model, dataset, node, trainer): """ Reads all images into memory and applies augmentation if enabled """ concurrent = psutil.cpu_count() dataset_config = dataset['config'] controller = {'running': True} q = Queue(concurrent) result = { 'X_train': [...
python
def read_images_in_memory(job_model, dataset, node, trainer): """ Reads all images into memory and applies augmentation if enabled """ concurrent = psutil.cpu_count() dataset_config = dataset['config'] controller = {'running': True} q = Queue(concurrent) result = { 'X_train': [...
[ "def", "read_images_in_memory", "(", "job_model", ",", "dataset", ",", "node", ",", "trainer", ")", ":", "concurrent", "=", "psutil", ".", "cpu_count", "(", ")", "dataset_config", "=", "dataset", "[", "'config'", "]", "controller", "=", "{", "'running'", ":"...
Reads all images into memory and applies augmentation if enabled
[ "Reads", "all", "images", "into", "memory", "and", "applies", "augmentation", "if", "enabled" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/auto_dataset.py#L205-L310
aetros/aetros-cli
aetros/cuda_gpu.py
get_ordered_devices
def get_ordered_devices(): """ Default CUDA_DEVICE_ORDER is not compatible with nvidia-docker. Nvidia-Docker is using CUDA_DEVICE_ORDER=PCI_BUS_ID. https://github.com/NVIDIA/nvidia-docker/wiki/nvidia-docker#gpu-isolation """ libcudart = get_libcudart() devices = {} for i in range(0, g...
python
def get_ordered_devices(): """ Default CUDA_DEVICE_ORDER is not compatible with nvidia-docker. Nvidia-Docker is using CUDA_DEVICE_ORDER=PCI_BUS_ID. https://github.com/NVIDIA/nvidia-docker/wiki/nvidia-docker#gpu-isolation """ libcudart = get_libcudart() devices = {} for i in range(0, g...
[ "def", "get_ordered_devices", "(", ")", ":", "libcudart", "=", "get_libcudart", "(", ")", "devices", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "get_installed_devices", "(", ")", ")", ":", "gpu", "=", "get_device_properties", "(", "i", ")",...
Default CUDA_DEVICE_ORDER is not compatible with nvidia-docker. Nvidia-Docker is using CUDA_DEVICE_ORDER=PCI_BUS_ID. https://github.com/NVIDIA/nvidia-docker/wiki/nvidia-docker#gpu-isolation
[ "Default", "CUDA_DEVICE_ORDER", "is", "not", "compatible", "with", "nvidia", "-", "docker", ".", "Nvidia", "-", "Docker", "is", "using", "CUDA_DEVICE_ORDER", "=", "PCI_BUS_ID", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/cuda_gpu.py#L113-L143
23andMe/seqseek
seqseek/lib.py
sorted_nicely
def sorted_nicely(l): """ Sort the given iterable in the way that humans expect. http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/ """ convert = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] r...
python
def sorted_nicely(l): """ Sort the given iterable in the way that humans expect. http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/ """ convert = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] r...
[ "def", "sorted_nicely", "(", "l", ")", ":", "convert", "=", "lambda", "text", ":", "int", "(", "text", ")", "if", "text", ".", "isdigit", "(", ")", "else", "text", "alphanum_key", "=", "lambda", "key", ":", "[", "convert", "(", "c", ")", "for", "c"...
Sort the given iterable in the way that humans expect. http://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
[ "Sort", "the", "given", "iterable", "in", "the", "way", "that", "humans", "expect", ".", "http", ":", "//", "blog", ".", "codinghorror", ".", "com", "/", "sorting", "-", "for", "-", "humans", "-", "natural", "-", "sort", "-", "order", "/" ]
train
https://github.com/23andMe/seqseek/blob/773659ed280144d4fd62f313f783fc102e85458f/seqseek/lib.py#L168-L175
slightlynybbled/engineering_notation
engineering_notation/engineering_notation.py
EngNumber.to_pn
def to_pn(self, sub_letter=None): """ Returns the part number equivalent. For instance, a '1k' would still be '1k', but a '1.2k' would, instead, be a '1k2' :return: """ string = str(self) if '.' not in string: return string # take car...
python
def to_pn(self, sub_letter=None): """ Returns the part number equivalent. For instance, a '1k' would still be '1k', but a '1.2k' would, instead, be a '1k2' :return: """ string = str(self) if '.' not in string: return string # take car...
[ "def", "to_pn", "(", "self", ",", "sub_letter", "=", "None", ")", ":", "string", "=", "str", "(", "self", ")", "if", "'.'", "not", "in", "string", ":", "return", "string", "# take care of the case of when there is no scaling unit", "if", "not", "string", "[", ...
Returns the part number equivalent. For instance, a '1k' would still be '1k', but a '1.2k' would, instead, be a '1k2' :return:
[ "Returns", "the", "part", "number", "equivalent", ".", "For", "instance", "a", "1k", "would", "still", "be", "1k", "but", "a", "1", ".", "2k", "would", "instead", "be", "a", "1k2", ":", "return", ":" ]
train
https://github.com/slightlynybbled/engineering_notation/blob/fcd930b777d506b6385d84cf3af491bf5c29a42e/engineering_notation/engineering_notation.py#L298-L317
praekelt/django-ultracache
ultracache/utils.py
reduce_list_size
def reduce_list_size(li): """Return two lists - the last N items of li whose total size is less than MAX_SIZE - the rest of the original list li """ # sys.getsizeof is nearly useless. All our data is stringable so rather # use that as a measure of size. size = len(repr(li)) keep ...
python
def reduce_list_size(li): """Return two lists - the last N items of li whose total size is less than MAX_SIZE - the rest of the original list li """ # sys.getsizeof is nearly useless. All our data is stringable so rather # use that as a measure of size. size = len(repr(li)) keep ...
[ "def", "reduce_list_size", "(", "li", ")", ":", "# sys.getsizeof is nearly useless. All our data is stringable so rather", "# use that as a measure of size.", "size", "=", "len", "(", "repr", "(", "li", ")", ")", "keep", "=", "li", "toss", "=", "[", "]", "n", "=", ...
Return two lists - the last N items of li whose total size is less than MAX_SIZE - the rest of the original list li
[ "Return", "two", "lists", "-", "the", "last", "N", "items", "of", "li", "whose", "total", "size", "is", "less", "than", "MAX_SIZE", "-", "the", "rest", "of", "the", "original", "list", "li" ]
train
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/utils.py#L43-L60
praekelt/django-ultracache
ultracache/utils.py
cache_meta
def cache_meta(request, cache_key, start_index=0): """Inspect request for objects in _ultracache and set appropriate entries in Django's cache.""" path = request.get_full_path() # todo: cache headers on the request since they never change during the # request. # Reduce headers to the subset as...
python
def cache_meta(request, cache_key, start_index=0): """Inspect request for objects in _ultracache and set appropriate entries in Django's cache.""" path = request.get_full_path() # todo: cache headers on the request since they never change during the # request. # Reduce headers to the subset as...
[ "def", "cache_meta", "(", "request", ",", "cache_key", ",", "start_index", "=", "0", ")", ":", "path", "=", "request", ".", "get_full_path", "(", ")", "# todo: cache headers on the request since they never change during the", "# request.", "# Reduce headers to the subset as...
Inspect request for objects in _ultracache and set appropriate entries in Django's cache.
[ "Inspect", "request", "for", "objects", "in", "_ultracache", "and", "set", "appropriate", "entries", "in", "Django", "s", "cache", "." ]
train
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/utils.py#L63-L223
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/smith.py
AnchorSmith.least_role
def least_role() -> Role: """ Return the TRUSTEE indy-sdk role for an anchor acting in an AnchorSmith capacity. :return: TRUSTEE role """ LOGGER.debug('AnchorSmith.least_role >>>') rv = Role.TRUSTEE.token() LOGGER.debug('AnchorSmith.least_role <<< %s', rv) ...
python
def least_role() -> Role: """ Return the TRUSTEE indy-sdk role for an anchor acting in an AnchorSmith capacity. :return: TRUSTEE role """ LOGGER.debug('AnchorSmith.least_role >>>') rv = Role.TRUSTEE.token() LOGGER.debug('AnchorSmith.least_role <<< %s', rv) ...
[ "def", "least_role", "(", ")", "->", "Role", ":", "LOGGER", ".", "debug", "(", "'AnchorSmith.least_role >>>'", ")", "rv", "=", "Role", ".", "TRUSTEE", ".", "token", "(", ")", "LOGGER", ".", "debug", "(", "'AnchorSmith.least_role <<< %s'", ",", "rv", ")", "...
Return the TRUSTEE indy-sdk role for an anchor acting in an AnchorSmith capacity. :return: TRUSTEE role
[ "Return", "the", "TRUSTEE", "indy", "-", "sdk", "role", "for", "an", "anchor", "acting", "in", "an", "AnchorSmith", "capacity", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/smith.py#L37-L49
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/smith.py
AnchorSmith.send_nym
async def send_nym(self, did: str, verkey: str = None, alias: str = None, role: Role = None) -> None: """ Send input anchor's cryptonym (including DID, verification key, plus optional alias and role) to the distributed ledger. Raise BadLedgerTxn on failure, BadIdentifier for bad DID, or...
python
async def send_nym(self, did: str, verkey: str = None, alias: str = None, role: Role = None) -> None: """ Send input anchor's cryptonym (including DID, verification key, plus optional alias and role) to the distributed ledger. Raise BadLedgerTxn on failure, BadIdentifier for bad DID, or...
[ "async", "def", "send_nym", "(", "self", ",", "did", ":", "str", ",", "verkey", ":", "str", "=", "None", ",", "alias", ":", "str", "=", "None", ",", "role", ":", "Role", "=", "None", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'AnchorSm...
Send input anchor's cryptonym (including DID, verification key, plus optional alias and role) to the distributed ledger. Raise BadLedgerTxn on failure, BadIdentifier for bad DID, or BadRole for bad role. :param did: anchor DID to send to ledger :param verkey: optional anchor verificati...
[ "Send", "input", "anchor", "s", "cryptonym", "(", "including", "DID", "verification", "key", "plus", "optional", "alias", "and", "role", ")", "to", "the", "distributed", "ledger", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/smith.py#L51-L74
PSPC-SPAC-buyandsell/von_anchor
von_anchor/op/setnym.py
usage
def usage() -> None: """ Print usage advice. """ print() print('Usage: setnym.py <config-ini>') print() print('where <config-ini> represents the path to the configuration file.') print() print('The operation submits a nym to a trustee anchor to send to the ledger,') print('if th...
python
def usage() -> None: """ Print usage advice. """ print() print('Usage: setnym.py <config-ini>') print() print('where <config-ini> represents the path to the configuration file.') print() print('The operation submits a nym to a trustee anchor to send to the ledger,') print('if th...
[ "def", "usage", "(", ")", "->", "None", ":", "print", "(", ")", "print", "(", "'Usage: setnym.py <config-ini>'", ")", "print", "(", ")", "print", "(", "'where <config-ini> represents the path to the configuration file.'", ")", "print", "(", ")", "print", "(", "'Th...
Print usage advice.
[ "Print", "usage", "advice", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/op/setnym.py#L43-L79
PSPC-SPAC-buyandsell/von_anchor
von_anchor/op/setnym.py
_set_wallets
async def _set_wallets(an_data: dict) -> dict: """ Set wallets as configured for setnym operation. :param an_data: dict mapping profiles to anchor data :return: dict mapping anchor names to wallet objects """ w_mgr = WalletManager() rv = {} for profile in an_data: w_cfg = {'id'...
python
async def _set_wallets(an_data: dict) -> dict: """ Set wallets as configured for setnym operation. :param an_data: dict mapping profiles to anchor data :return: dict mapping anchor names to wallet objects """ w_mgr = WalletManager() rv = {} for profile in an_data: w_cfg = {'id'...
[ "async", "def", "_set_wallets", "(", "an_data", ":", "dict", ")", "->", "dict", ":", "w_mgr", "=", "WalletManager", "(", ")", "rv", "=", "{", "}", "for", "profile", "in", "an_data", ":", "w_cfg", "=", "{", "'id'", ":", "an_data", "[", "profile", "]",...
Set wallets as configured for setnym operation. :param an_data: dict mapping profiles to anchor data :return: dict mapping anchor names to wallet objects
[ "Set", "wallets", "as", "configured", "for", "setnym", "operation", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/op/setnym.py#L82-L107
PSPC-SPAC-buyandsell/von_anchor
von_anchor/op/setnym.py
setnym
async def setnym(ini_path: str) -> int: """ Set configuration. Open pool, trustee anchor, and wallet of anchor whose nym to send. Register exit hooks to close pool and trustee anchor. Engage trustee anchor to send nym for VON anchor, if it differs on the ledger from configuration. :param ini_path:...
python
async def setnym(ini_path: str) -> int: """ Set configuration. Open pool, trustee anchor, and wallet of anchor whose nym to send. Register exit hooks to close pool and trustee anchor. Engage trustee anchor to send nym for VON anchor, if it differs on the ledger from configuration. :param ini_path:...
[ "async", "def", "setnym", "(", "ini_path", ":", "str", ")", "->", "int", ":", "config", "=", "inis2dict", "(", "ini_path", ")", "if", "config", "[", "'Trustee Anchor'", "]", "[", "'name'", "]", "==", "config", "[", "'VON Anchor'", "]", "[", "'name'", "...
Set configuration. Open pool, trustee anchor, and wallet of anchor whose nym to send. Register exit hooks to close pool and trustee anchor. Engage trustee anchor to send nym for VON anchor, if it differs on the ledger from configuration. :param ini_path: path to configuration file :return: 0 for OK, 1...
[ "Set", "configuration", ".", "Open", "pool", "trustee", "anchor", "and", "wallet", "of", "anchor", "whose", "nym", "to", "send", ".", "Register", "exit", "hooks", "to", "close", "pool", "and", "trustee", "anchor", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/op/setnym.py#L110-L182
PSPC-SPAC-buyandsell/von_anchor
von_anchor/op/setnym.py
main
def main(args: Sequence[str] = None) -> int: """ Main line for script: check arguments and dispatch operation to set nym. :param args: command-line arguments :return: 0 for OK, 1 for failure """ logging.basicConfig( level=logging.INFO, format='%(asctime)-15s | %(levelname)-8s |...
python
def main(args: Sequence[str] = None) -> int: """ Main line for script: check arguments and dispatch operation to set nym. :param args: command-line arguments :return: 0 for OK, 1 for failure """ logging.basicConfig( level=logging.INFO, format='%(asctime)-15s | %(levelname)-8s |...
[ "def", "main", "(", "args", ":", "Sequence", "[", "str", "]", "=", "None", ")", "->", "int", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "'%(asctime)-15s | %(levelname)-8s | %(message)s'", ",", "datefmt"...
Main line for script: check arguments and dispatch operation to set nym. :param args: command-line arguments :return: 0 for OK, 1 for failure
[ "Main", "line", "for", "script", ":", "check", "arguments", "and", "dispatch", "operation", "to", "set", "nym", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/op/setnym.py#L185-L211
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
schema_id
def schema_id(origin_did: str, name: str, version: str) -> str: """ Return schema identifier for input origin DID, schema name, and schema version. :param origin_did: DID of schema originator :param name: schema name :param version: schema version :return: schema identifier """ return ...
python
def schema_id(origin_did: str, name: str, version: str) -> str: """ Return schema identifier for input origin DID, schema name, and schema version. :param origin_did: DID of schema originator :param name: schema name :param version: schema version :return: schema identifier """ return ...
[ "def", "schema_id", "(", "origin_did", ":", "str", ",", "name", ":", "str", ",", "version", ":", "str", ")", "->", "str", ":", "return", "'{}:2:{}:{}'", ".", "format", "(", "origin_did", ",", "name", ",", "version", ")" ]
Return schema identifier for input origin DID, schema name, and schema version. :param origin_did: DID of schema originator :param name: schema name :param version: schema version :return: schema identifier
[ "Return", "schema", "identifier", "for", "input", "origin", "DID", "schema", "name", "and", "schema", "version", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L34-L44
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
ok_did
def ok_did(token: str) -> bool: """ Whether input token looks like a valid distributed identifier. :param token: candidate string :return: whether input token looks like a valid schema identifier """ return bool(re.match('[{}]{{21,22}}$'.format(B58), token or ''))
python
def ok_did(token: str) -> bool: """ Whether input token looks like a valid distributed identifier. :param token: candidate string :return: whether input token looks like a valid schema identifier """ return bool(re.match('[{}]{{21,22}}$'.format(B58), token or ''))
[ "def", "ok_did", "(", "token", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "re", ".", "match", "(", "'[{}]{{21,22}}$'", ".", "format", "(", "B58", ")", ",", "token", "or", "''", ")", ")" ]
Whether input token looks like a valid distributed identifier. :param token: candidate string :return: whether input token looks like a valid schema identifier
[ "Whether", "input", "token", "looks", "like", "a", "valid", "distributed", "identifier", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L83-L91
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
ok_schema_id
def ok_schema_id(token: str) -> bool: """ Whether input token looks like a valid schema identifier; i.e., <issuer-did>:2:<name>:<version>. :param token: candidate string :return: whether input token looks like a valid schema identifier """ return bool(re.match('[{}]{{21,22}}:2:.+:[0-9.]+$'...
python
def ok_schema_id(token: str) -> bool: """ Whether input token looks like a valid schema identifier; i.e., <issuer-did>:2:<name>:<version>. :param token: candidate string :return: whether input token looks like a valid schema identifier """ return bool(re.match('[{}]{{21,22}}:2:.+:[0-9.]+$'...
[ "def", "ok_schema_id", "(", "token", ":", "str", ")", "->", "bool", ":", "return", "bool", "(", "re", ".", "match", "(", "'[{}]{{21,22}}:2:.+:[0-9.]+$'", ".", "format", "(", "B58", ")", ",", "token", "or", "''", ")", ")" ]
Whether input token looks like a valid schema identifier; i.e., <issuer-did>:2:<name>:<version>. :param token: candidate string :return: whether input token looks like a valid schema identifier
[ "Whether", "input", "token", "looks", "like", "a", "valid", "schema", "identifier", ";", "i", ".", "e", ".", "<issuer", "-", "did", ">", ":", "2", ":", "<name", ">", ":", "<version", ">", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L94-L103
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
schema_key
def schema_key(s_id: str) -> SchemaKey: """ Return schema key (namedtuple) convenience for schema identifier components. :param s_id: schema identifier :return: schema key (namedtuple) object """ s_key = s_id.split(':') s_key.pop(1) # take out indy-sdk schema marker: 2 marks indy-sdk sche...
python
def schema_key(s_id: str) -> SchemaKey: """ Return schema key (namedtuple) convenience for schema identifier components. :param s_id: schema identifier :return: schema key (namedtuple) object """ s_key = s_id.split(':') s_key.pop(1) # take out indy-sdk schema marker: 2 marks indy-sdk sche...
[ "def", "schema_key", "(", "s_id", ":", "str", ")", "->", "SchemaKey", ":", "s_key", "=", "s_id", ".", "split", "(", "':'", ")", "s_key", ".", "pop", "(", "1", ")", "# take out indy-sdk schema marker: 2 marks indy-sdk schema id", "return", "SchemaKey", "(", "*"...
Return schema key (namedtuple) convenience for schema identifier components. :param s_id: schema identifier :return: schema key (namedtuple) object
[ "Return", "schema", "key", "(", "namedtuple", ")", "convenience", "for", "schema", "identifier", "components", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L106-L117
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
cred_def_id
def cred_def_id(issuer_did: str, schema_seq_no: int, protocol: Protocol = None) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_...
python
def cred_def_id(issuer_did: str, schema_seq_no: int, protocol: Protocol = None) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_...
[ "def", "cred_def_id", "(", "issuer_did", ":", "str", ",", "schema_seq_no", ":", "int", ",", "protocol", ":", "Protocol", "=", "None", ")", "->", "str", ":", "return", "(", "protocol", "or", "Protocol", ".", "DEFAULT", ")", ".", "cred_def_id", "(", "issue...
Return credential definition identifier for input issuer DID and schema sequence number. Implementation passes to NodePool Protocol. :param issuer_did: DID of credential definition issuer :param schema_seq_no: schema sequence number :param protocol: indy protocol version :return: credential defini...
[ "Return", "credential", "definition", "identifier", "for", "input", "issuer", "DID", "and", "schema", "sequence", "number", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L120-L132
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
ok_cred_def_id
def ok_cred_def_id(token: str, issuer_did: str = None) -> bool: """ Whether input token looks like a valid credential definition identifier from input issuer DID (default any); i.e., <issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag> for protocol >= 1.4, or <issuer-did>:3:CL:<schema-seq-no> for protoco...
python
def ok_cred_def_id(token: str, issuer_did: str = None) -> bool: """ Whether input token looks like a valid credential definition identifier from input issuer DID (default any); i.e., <issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag> for protocol >= 1.4, or <issuer-did>:3:CL:<schema-seq-no> for protoco...
[ "def", "ok_cred_def_id", "(", "token", ":", "str", ",", "issuer_did", ":", "str", "=", "None", ")", "->", "bool", ":", "cd_id_m", "=", "re", ".", "match", "(", "'([{}]{{21,22}}):3:CL:[1-9][0-9]*(:.+)?$'", ".", "format", "(", "B58", ")", ",", "token", "or",...
Whether input token looks like a valid credential definition identifier from input issuer DID (default any); i.e., <issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag> for protocol >= 1.4, or <issuer-did>:3:CL:<schema-seq-no> for protocol == 1.3. :param token: candidate string :param issuer_did: issuer ...
[ "Whether", "input", "token", "looks", "like", "a", "valid", "credential", "definition", "identifier", "from", "input", "issuer", "DID", "(", "default", "any", ")", ";", "i", ".", "e", ".", "<issuer", "-", "did", ">", ":", "3", ":", "CL", ":", "<schema"...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L135-L147
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
cred_def_id2seq_no
def cred_def_id2seq_no(cd_id: str) -> int: """ Given a credential definition identifier, return its schema sequence number. Raise BadIdentifier on input that is not a credential definition identifier. :param cd_id: credential definition identifier :return: sequence number """ if ok_cred_de...
python
def cred_def_id2seq_no(cd_id: str) -> int: """ Given a credential definition identifier, return its schema sequence number. Raise BadIdentifier on input that is not a credential definition identifier. :param cd_id: credential definition identifier :return: sequence number """ if ok_cred_de...
[ "def", "cred_def_id2seq_no", "(", "cd_id", ":", "str", ")", "->", "int", ":", "if", "ok_cred_def_id", "(", "cd_id", ")", ":", "return", "int", "(", "cd_id", ".", "split", "(", "':'", ")", "[", "3", "]", ")", "# sequence number is token at 0-based position 3"...
Given a credential definition identifier, return its schema sequence number. Raise BadIdentifier on input that is not a credential definition identifier. :param cd_id: credential definition identifier :return: sequence number
[ "Given", "a", "credential", "definition", "identifier", "return", "its", "schema", "sequence", "number", ".", "Raise", "BadIdentifier", "on", "input", "that", "is", "not", "a", "credential", "definition", "identifier", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L150-L161
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
rev_reg_id
def rev_reg_id(cd_id: str, tag: Union[str, int]) -> str: """ Given a credential definition identifier and a tag, return the corresponding revocation registry identifier, repeating the issuer DID from the input identifier. :param cd_id: credential definition identifier :param tag: tag to use ...
python
def rev_reg_id(cd_id: str, tag: Union[str, int]) -> str: """ Given a credential definition identifier and a tag, return the corresponding revocation registry identifier, repeating the issuer DID from the input identifier. :param cd_id: credential definition identifier :param tag: tag to use ...
[ "def", "rev_reg_id", "(", "cd_id", ":", "str", ",", "tag", ":", "Union", "[", "str", ",", "int", "]", ")", "->", "str", ":", "return", "'{}:4:{}:CL_ACCUM:{}'", ".", "format", "(", "cd_id", ".", "split", "(", "\":\"", ",", "1", ")", "[", "0", "]", ...
Given a credential definition identifier and a tag, return the corresponding revocation registry identifier, repeating the issuer DID from the input identifier. :param cd_id: credential definition identifier :param tag: tag to use :return: revocation registry identifier
[ "Given", "a", "credential", "definition", "identifier", "and", "a", "tag", "return", "the", "corresponding", "revocation", "registry", "identifier", "repeating", "the", "issuer", "DID", "from", "the", "input", "identifier", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L164-L175
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
ok_rev_reg_id
def ok_rev_reg_id(token: str, issuer_did: str = None) -> bool: """ Whether input token looks like a valid revocation registry identifier from input issuer DID (default any); i.e., <issuer-did>:4:<issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag>:CL_ACCUM:<rev-reg-id-tag> for protocol >= 1.4, or <issuer...
python
def ok_rev_reg_id(token: str, issuer_did: str = None) -> bool: """ Whether input token looks like a valid revocation registry identifier from input issuer DID (default any); i.e., <issuer-did>:4:<issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag>:CL_ACCUM:<rev-reg-id-tag> for protocol >= 1.4, or <issuer...
[ "def", "ok_rev_reg_id", "(", "token", ":", "str", ",", "issuer_did", ":", "str", "=", "None", ")", "->", "bool", ":", "rr_id_m", "=", "re", ".", "match", "(", "'([{0}]{{21,22}}):4:([{0}]{{21,22}}):3:CL:[1-9][0-9]*(:.+)?:CL_ACCUM:.+$'", ".", "format", "(", "B58", ...
Whether input token looks like a valid revocation registry identifier from input issuer DID (default any); i.e., <issuer-did>:4:<issuer-did>:3:CL:<schema-seq-no>:<cred-def-id-tag>:CL_ACCUM:<rev-reg-id-tag> for protocol >= 1.4, or <issuer-did>:4:<issuer-did>:3:CL:<schema-seq-no>:CL_ACCUM:<rev-reg-id-tag> for pro...
[ "Whether", "input", "token", "looks", "like", "a", "valid", "revocation", "registry", "identifier", "from", "input", "issuer", "DID", "(", "default", "any", ")", ";", "i", ".", "e", ".", "<issuer", "-", "did", ">", ":", "4", ":", "<issuer", "-", "did",...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L178-L192
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
rev_reg_id2cred_def_id
def rev_reg_id2cred_def_id(rr_id: str) -> str: """ Given a revocation registry identifier, return its corresponding credential definition identifier. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier :return: credential definition ide...
python
def rev_reg_id2cred_def_id(rr_id: str) -> str: """ Given a revocation registry identifier, return its corresponding credential definition identifier. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier :return: credential definition ide...
[ "def", "rev_reg_id2cred_def_id", "(", "rr_id", ":", "str", ")", "->", "str", ":", "if", "ok_rev_reg_id", "(", "rr_id", ")", ":", "return", "':'", ".", "join", "(", "rr_id", ".", "split", "(", "':'", ")", "[", "2", ":", "-", "2", "]", ")", "# rev re...
Given a revocation registry identifier, return its corresponding credential definition identifier. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier :return: credential definition identifier
[ "Given", "a", "revocation", "registry", "identifier", "return", "its", "corresponding", "credential", "definition", "identifier", ".", "Raise", "BadIdentifier", "if", "input", "is", "not", "a", "revocation", "registry", "identifier", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L195-L206
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
rev_reg_id2cred_def_id_tag
def rev_reg_id2cred_def_id_tag(rr_id: str) -> (str, str): """ Given a revocation registry identifier, return its corresponding credential definition identifier and (stringified int) tag. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier ...
python
def rev_reg_id2cred_def_id_tag(rr_id: str) -> (str, str): """ Given a revocation registry identifier, return its corresponding credential definition identifier and (stringified int) tag. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier ...
[ "def", "rev_reg_id2cred_def_id_tag", "(", "rr_id", ":", "str", ")", "->", "(", "str", ",", "str", ")", ":", "if", "ok_rev_reg_id", "(", "rr_id", ")", ":", "return", "(", "':'", ".", "join", "(", "rr_id", ".", "split", "(", "':'", ")", "[", "2", ":"...
Given a revocation registry identifier, return its corresponding credential definition identifier and (stringified int) tag. Raise BadIdentifier if input is not a revocation registry identifier. :param rr_id: revocation registry identifier :return: credential definition identifier and tag
[ "Given", "a", "revocation", "registry", "identifier", "return", "its", "corresponding", "credential", "definition", "identifier", "and", "(", "stringified", "int", ")", "tag", ".", "Raise", "BadIdentifier", "if", "input", "is", "not", "a", "revocation", "registry"...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L220-L234
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
iter_briefs
def iter_briefs(briefs: Union[dict, Sequence[dict]]) -> tuple: """ Given a cred-brief/cred-info, an sequence thereof, or cred-brief-dict (as HolderProver.get_cred_briefs_by_proof_req_q() returns), return tuple with all contained cred-briefs. :param briefs: cred-brief/cred-info, sequence thereof, or...
python
def iter_briefs(briefs: Union[dict, Sequence[dict]]) -> tuple: """ Given a cred-brief/cred-info, an sequence thereof, or cred-brief-dict (as HolderProver.get_cred_briefs_by_proof_req_q() returns), return tuple with all contained cred-briefs. :param briefs: cred-brief/cred-info, sequence thereof, or...
[ "def", "iter_briefs", "(", "briefs", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ")", "->", "tuple", ":", "if", "isinstance", "(", "briefs", ",", "dict", ")", ":", "if", "all", "(", "ok_wallet_reft", "(", "k", ")", "for", "k"...
Given a cred-brief/cred-info, an sequence thereof, or cred-brief-dict (as HolderProver.get_cred_briefs_by_proof_req_q() returns), return tuple with all contained cred-briefs. :param briefs: cred-brief/cred-info, sequence thereof, or cred-brief-dict :return: tuple of cred-briefs
[ "Given", "a", "cred", "-", "brief", "/", "cred", "-", "info", "an", "sequence", "thereof", "or", "cred", "-", "brief", "-", "dict", "(", "as", "HolderProver", ".", "get_cred_briefs_by_proof_req_q", "()", "returns", ")", "return", "tuple", "with", "all", "c...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L237-L251
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
box_ids
def box_ids(briefs: Union[dict, Sequence[dict]], cred_ids: Union[Sequence[str], str] = None) -> dict: """ Given one or more cred-briefs/cred-infos, and an optional sequence of credential identifiers (aka wallet cred ids, referents; specify None to include all), return dict mapping each credential identi...
python
def box_ids(briefs: Union[dict, Sequence[dict]], cred_ids: Union[Sequence[str], str] = None) -> dict: """ Given one or more cred-briefs/cred-infos, and an optional sequence of credential identifiers (aka wallet cred ids, referents; specify None to include all), return dict mapping each credential identi...
[ "def", "box_ids", "(", "briefs", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ",", "cred_ids", ":", "Union", "[", "Sequence", "[", "str", "]", ",", "str", "]", "=", "None", ")", "->", "dict", ":", "rv", "=", "{", "}", "for...
Given one or more cred-briefs/cred-infos, and an optional sequence of credential identifiers (aka wallet cred ids, referents; specify None to include all), return dict mapping each credential identifier to a box ids structure (i.e., a dict specifying its corresponding schema identifier, credential definitio...
[ "Given", "one", "or", "more", "cred", "-", "briefs", "/", "cred", "-", "infos", "and", "an", "optional", "sequence", "of", "credential", "identifiers", "(", "aka", "wallet", "cred", "ids", "referents", ";", "specify", "None", "to", "include", "all", ")", ...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L254-L280
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
prune_creds_json
def prune_creds_json(creds: dict, cred_ids: set) -> str: """ Strip all creds out of the input json structure that do not match any of the input credential identifiers. :param creds: indy-sdk creds structure :param cred_ids: the set of credential identifiers of interest :return: the reduced creds js...
python
def prune_creds_json(creds: dict, cred_ids: set) -> str: """ Strip all creds out of the input json structure that do not match any of the input credential identifiers. :param creds: indy-sdk creds structure :param cred_ids: the set of credential identifiers of interest :return: the reduced creds js...
[ "def", "prune_creds_json", "(", "creds", ":", "dict", ",", "cred_ids", ":", "set", ")", "->", "str", ":", "rv", "=", "deepcopy", "(", "creds", ")", "for", "key", "in", "(", "'attrs'", ",", "'predicates'", ")", ":", "for", "attr_uuid", ",", "creds_by_uu...
Strip all creds out of the input json structure that do not match any of the input credential identifiers. :param creds: indy-sdk creds structure :param cred_ids: the set of credential identifiers of interest :return: the reduced creds json
[ "Strip", "all", "creds", "out", "of", "the", "input", "json", "structure", "that", "do", "not", "match", "any", "of", "the", "input", "credential", "identifiers", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L283-L301
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
proof_req_infos2briefs
def proof_req_infos2briefs(proof_req: dict, infos: Union[dict, Sequence[dict]]) -> list: """ Given a proof request and corresponding cred-info(s), return a list of cred-briefs (i.e., cred-info plus interval). The proof request must have cred def id restrictions on all requested attribute specifications...
python
def proof_req_infos2briefs(proof_req: dict, infos: Union[dict, Sequence[dict]]) -> list: """ Given a proof request and corresponding cred-info(s), return a list of cred-briefs (i.e., cred-info plus interval). The proof request must have cred def id restrictions on all requested attribute specifications...
[ "def", "proof_req_infos2briefs", "(", "proof_req", ":", "dict", ",", "infos", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ")", "->", "list", ":", "rv", "=", "[", "]", "refts", "=", "proof_req_attr_referents", "(", "proof_req", ")",...
Given a proof request and corresponding cred-info(s), return a list of cred-briefs (i.e., cred-info plus interval). The proof request must have cred def id restrictions on all requested attribute specifications. :param proof_req: proof request :param infos: cred-info or sequence thereof; e.g., ::...
[ "Given", "a", "proof", "request", "and", "corresponding", "cred", "-", "info", "(", "s", ")", "return", "a", "list", "of", "cred", "-", "briefs", "(", "i", ".", "e", ".", "cred", "-", "info", "plus", "interval", ")", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L304-L362
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
proof_req_briefs2req_creds
def proof_req_briefs2req_creds(proof_req: dict, briefs: Union[dict, Sequence[dict]]) -> dict: """ Given a proof request and cred-brief(s), return a requested-creds structure. The proof request must have cred def id restrictions on all requested attribute specifications. :param proof_req: proof request...
python
def proof_req_briefs2req_creds(proof_req: dict, briefs: Union[dict, Sequence[dict]]) -> dict: """ Given a proof request and cred-brief(s), return a requested-creds structure. The proof request must have cred def id restrictions on all requested attribute specifications. :param proof_req: proof request...
[ "def", "proof_req_briefs2req_creds", "(", "proof_req", ":", "dict", ",", "briefs", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ")", "->", "dict", ":", "rv", "=", "{", "'self_attested_attributes'", ":", "{", "}", ",", "'requested_attr...
Given a proof request and cred-brief(s), return a requested-creds structure. The proof request must have cred def id restrictions on all requested attribute specifications. :param proof_req: proof request :param briefs: credential brief, sequence thereof (as indy-sdk wallet credential search returns), ...
[ "Given", "a", "proof", "request", "and", "cred", "-", "brief", "(", "s", ")", "return", "a", "requested", "-", "creds", "structure", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L364-L485
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
creds_display
def creds_display(creds: Union[dict, Sequence[dict]], filt: dict = None, filt_dflt_incl: bool = False) -> dict: """ Find indy-sdk creds matching input filter from within input creds structure, sequence of cred-briefs/cred-infos, or cred-brief-dict. Return human-legible summary. :param creds: creds str...
python
def creds_display(creds: Union[dict, Sequence[dict]], filt: dict = None, filt_dflt_incl: bool = False) -> dict: """ Find indy-sdk creds matching input filter from within input creds structure, sequence of cred-briefs/cred-infos, or cred-brief-dict. Return human-legible summary. :param creds: creds str...
[ "def", "creds_display", "(", "creds", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ",", "filt", ":", "dict", "=", "None", ",", "filt_dflt_incl", ":", "bool", "=", "False", ")", "->", "dict", ":", "def", "_add", "(", "briefs", ...
Find indy-sdk creds matching input filter from within input creds structure, sequence of cred-briefs/cred-infos, or cred-brief-dict. Return human-legible summary. :param creds: creds structure, cred-brief/cred-info or sequence thereof, or cred-brief-dict; e.g., creds :: { "at...
[ "Find", "indy", "-", "sdk", "creds", "matching", "input", "filter", "from", "within", "input", "creds", "structure", "sequence", "of", "cred", "-", "briefs", "/", "cred", "-", "infos", "or", "cred", "-", "brief", "-", "dict", ".", "Return", "human", "-",...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L488-L615
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
proof_req2wql_all
def proof_req2wql_all(proof_req: dict, x_cd_ids: Union[str, Sequence[str]] = None) -> dict: """ Given a proof request and a list of cred def ids to omit, return an extra WQL query dict that will find all corresponding credentials in search. The proof request must have cred def id restrictions on all re...
python
def proof_req2wql_all(proof_req: dict, x_cd_ids: Union[str, Sequence[str]] = None) -> dict: """ Given a proof request and a list of cred def ids to omit, return an extra WQL query dict that will find all corresponding credentials in search. The proof request must have cred def id restrictions on all re...
[ "def", "proof_req2wql_all", "(", "proof_req", ":", "dict", ",", "x_cd_ids", ":", "Union", "[", "str", ",", "Sequence", "[", "str", "]", "]", "=", "None", ")", "->", "dict", ":", "rv", "=", "{", "}", "attr_refts", "=", "proof_req_attr_referents", "(", "...
Given a proof request and a list of cred def ids to omit, return an extra WQL query dict that will find all corresponding credentials in search. The proof request must have cred def id restrictions on all requested attribute specifications. At present, the utility does not support predicates. :param p...
[ "Given", "a", "proof", "request", "and", "a", "list", "of", "cred", "def", "ids", "to", "omit", "return", "an", "extra", "WQL", "query", "dict", "that", "will", "find", "all", "corresponding", "credentials", "in", "search", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L618-L636
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
proof_req_attr_referents
def proof_req_attr_referents(proof_req: dict) -> dict: """ Given a proof request with all requested attributes having cred def id restrictions, return its attribute referents by cred def id and attribute. The returned structure can be useful in populating the extra WQL query parameter in the creden...
python
def proof_req_attr_referents(proof_req: dict) -> dict: """ Given a proof request with all requested attributes having cred def id restrictions, return its attribute referents by cred def id and attribute. The returned structure can be useful in populating the extra WQL query parameter in the creden...
[ "def", "proof_req_attr_referents", "(", "proof_req", ":", "dict", ")", "->", "dict", ":", "rv", "=", "{", "}", "for", "uuid", ",", "spec", "in", "proof_req", "[", "'requested_attributes'", "]", ".", "items", "(", ")", ":", "cd_id", "=", "None", "for", ...
Given a proof request with all requested attributes having cred def id restrictions, return its attribute referents by cred def id and attribute. The returned structure can be useful in populating the extra WQL query parameter in the credential search API. :param proof_req: proof request with all requ...
[ "Given", "a", "proof", "request", "with", "all", "requested", "attributes", "having", "cred", "def", "id", "restrictions", "return", "its", "attribute", "referents", "by", "cred", "def", "id", "and", "attribute", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L639-L717
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
proof_req_pred_referents
def proof_req_pred_referents(proof_req: dict) -> dict: """ Given a proof request with all requested predicates having cred def id restrictions, return its predicate referents by cred def id and attribute, mapping a predicate and a limit. The returned structure can be useful in downstream processing to ...
python
def proof_req_pred_referents(proof_req: dict) -> dict: """ Given a proof request with all requested predicates having cred def id restrictions, return its predicate referents by cred def id and attribute, mapping a predicate and a limit. The returned structure can be useful in downstream processing to ...
[ "def", "proof_req_pred_referents", "(", "proof_req", ":", "dict", ")", "->", "dict", ":", "rv", "=", "{", "}", "for", "uuid", ",", "spec", "in", "proof_req", "[", "'requested_predicates'", "]", ".", "items", "(", ")", ":", "cd_id", "=", "None", "for", ...
Given a proof request with all requested predicates having cred def id restrictions, return its predicate referents by cred def id and attribute, mapping a predicate and a limit. The returned structure can be useful in downstream processing to filter cred-infos for predicates. :param proof_req: proof requ...
[ "Given", "a", "proof", "request", "with", "all", "requested", "predicates", "having", "cred", "def", "id", "restrictions", "return", "its", "predicate", "referents", "by", "cred", "def", "id", "and", "attribute", "mapping", "a", "predicate", "and", "a", "limit...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L720-L847
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
revoc_info
def revoc_info(briefs: Union[dict, Sequence[dict]], filt: dict = None) -> dict: """ Given a cred-brief, cred-info or sequence of either, return a dict mapping pairs (revocation registry identifier, credential revocation identifier) to attribute name: (raw) value dicts. If the caller includes a filt...
python
def revoc_info(briefs: Union[dict, Sequence[dict]], filt: dict = None) -> dict: """ Given a cred-brief, cred-info or sequence of either, return a dict mapping pairs (revocation registry identifier, credential revocation identifier) to attribute name: (raw) value dicts. If the caller includes a filt...
[ "def", "revoc_info", "(", "briefs", ":", "Union", "[", "dict", ",", "Sequence", "[", "dict", "]", "]", ",", "filt", ":", "dict", "=", "None", ")", "->", "dict", ":", "rv", "=", "{", "}", "for", "brief", "in", "iter_briefs", "(", "briefs", ")", ":...
Given a cred-brief, cred-info or sequence of either, return a dict mapping pairs (revocation registry identifier, credential revocation identifier) to attribute name: (raw) value dicts. If the caller includes a filter of attribute:value pairs, retain only matching attributes. :param briefs: cred-brief...
[ "Given", "a", "cred", "-", "brief", "cred", "-", "info", "or", "sequence", "of", "either", "return", "a", "dict", "mapping", "pairs", "(", "revocation", "registry", "identifier", "credential", "revocation", "identifier", ")", "to", "attribute", "name", ":", ...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L850-L906
PSPC-SPAC-buyandsell/von_anchor
von_anchor/util.py
revealed_attrs
def revealed_attrs(proof: dict) -> dict: """ Fetch revealed attributes from input proof and return dict mapping credential definition identifiers to dicts, each dict mapping attribute names to (raw) values, for processing in further creds downstream. :param proof: indy-sdk proof as dict :return: di...
python
def revealed_attrs(proof: dict) -> dict: """ Fetch revealed attributes from input proof and return dict mapping credential definition identifiers to dicts, each dict mapping attribute names to (raw) values, for processing in further creds downstream. :param proof: indy-sdk proof as dict :return: di...
[ "def", "revealed_attrs", "(", "proof", ":", "dict", ")", "->", "dict", ":", "rv", "=", "{", "}", "for", "sub_index", "in", "range", "(", "len", "(", "proof", "[", "'identifiers'", "]", ")", ")", ":", "cd_id", "=", "proof", "[", "'identifiers'", "]", ...
Fetch revealed attributes from input proof and return dict mapping credential definition identifiers to dicts, each dict mapping attribute names to (raw) values, for processing in further creds downstream. :param proof: indy-sdk proof as dict :return: dict mapping cred-ids to dicts, each mapping revealed a...
[ "Fetch", "revealed", "attributes", "from", "input", "proof", "and", "return", "dict", "mapping", "credential", "definition", "identifiers", "to", "dicts", "each", "dict", "mapping", "attribute", "names", "to", "(", "raw", ")", "values", "for", "processing", "in"...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/util.py#L909-L926
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.config
def config(self, value: dict) -> None: """ Set configuration dict :param value: configuration dict """ self._config = value or {} validate_config('verifier', self._config)
python
def config(self, value: dict) -> None: """ Set configuration dict :param value: configuration dict """ self._config = value or {} validate_config('verifier', self._config)
[ "def", "config", "(", "self", ",", "value", ":", "dict", ")", "->", "None", ":", "self", ".", "_config", "=", "value", "or", "{", "}", "validate_config", "(", "'verifier'", ",", "self", ".", "_config", ")" ]
Set configuration dict :param value: configuration dict
[ "Set", "configuration", "dict" ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L129-L137
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier._build_rr_state_json
async def _build_rr_state_json(self, rr_id: str, timestamp: int) -> (str, int): """ Build rev reg state json at a given requested timestamp. Return rev reg state json and its transaction time on the distributed ledger, with upper bound at input timestamp of interest. Raise Abse...
python
async def _build_rr_state_json(self, rr_id: str, timestamp: int) -> (str, int): """ Build rev reg state json at a given requested timestamp. Return rev reg state json and its transaction time on the distributed ledger, with upper bound at input timestamp of interest. Raise Abse...
[ "async", "def", "_build_rr_state_json", "(", "self", ",", "rr_id", ":", "str", ",", "timestamp", ":", "int", ")", "->", "(", "str", ",", "int", ")", ":", "LOGGER", ".", "debug", "(", "'_Verifier._build_rr_state_json >>> rr_id: %s, timestamp: %s'", ",", "rr_id", ...
Build rev reg state json at a given requested timestamp. Return rev reg state json and its transaction time on the distributed ledger, with upper bound at input timestamp of interest. Raise AbsentRevReg if no revocation registry exists on input rev reg id, or BadRevStateTime if request...
[ "Build", "rev", "reg", "state", "json", "at", "a", "given", "requested", "timestamp", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L149-L192
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.build_proof_req_json
async def build_proof_req_json(self, cd_id2spec: dict) -> str: """ Build and return indy-sdk proof request for input attributes and non-revocation intervals by cred def id. :param cd_id2spec: dict mapping cred def ids to: - (optionally) 'attrs': lists of names of attributes of inte...
python
async def build_proof_req_json(self, cd_id2spec: dict) -> str: """ Build and return indy-sdk proof request for input attributes and non-revocation intervals by cred def id. :param cd_id2spec: dict mapping cred def ids to: - (optionally) 'attrs': lists of names of attributes of inte...
[ "async", "def", "build_proof_req_json", "(", "self", ",", "cd_id2spec", ":", "dict", ")", "->", "str", ":", "LOGGER", ".", "debug", "(", "'Verifier.build_proof_req_json >>> cd_id2spec: %s'", ",", "cd_id2spec", ")", "cd_id2schema", "=", "{", "}", "now", "=", "int...
Build and return indy-sdk proof request for input attributes and non-revocation intervals by cred def id. :param cd_id2spec: dict mapping cred def ids to: - (optionally) 'attrs': lists of names of attributes of interest (omit for all, empty list or None for none) - (optionally) '>=': (...
[ "Build", "and", "return", "indy", "-", "sdk", "proof", "request", "for", "input", "attributes", "and", "non", "-", "revocation", "intervals", "by", "cred", "def", "id", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L194-L317
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.load_cache_for_verification
async def load_cache_for_verification(self, archive: bool = False) -> int: """ Load schema, cred def, revocation caches; optionally archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load eve...
python
async def load_cache_for_verification(self, archive: bool = False) -> int: """ Load schema, cred def, revocation caches; optionally archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load eve...
[ "async", "def", "load_cache_for_verification", "(", "self", ",", "archive", ":", "bool", "=", "False", ")", "->", "int", ":", "LOGGER", ".", "debug", "(", "'Verifier.load_cache_for_verification >>> archive: %s'", ",", "archive", ")", "rv", "=", "int", "(", "time...
Load schema, cred def, revocation caches; optionally archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load event, also used as subdirectory for cache archives. :param archive: True to arch...
[ "Load", "schema", "cred", "def", "revocation", "caches", ";", "optionally", "archive", "enough", "to", "go", "offline", "and", "be", "able", "to", "verify", "proof", "on", "content", "marked", "of", "interest", "in", "configuration", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L319-L374
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.open
async def open(self) -> 'Verifier': """ Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Verifier.open >>>') ...
python
async def open(self) -> 'Verifier': """ Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Verifier.open >>>') ...
[ "async", "def", "open", "(", "self", ")", "->", "'Verifier'", ":", "LOGGER", ".", "debug", "(", "'Verifier.open >>>'", ")", "await", "super", "(", ")", ".", "open", "(", ")", "if", "self", ".", "config", ".", "get", "(", "'parse-caches-on-open'", ",", ...
Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object
[ "Explicit", "entry", ".", "Perform", "ancestor", "opening", "operations", "then", "parse", "cache", "from", "archive", "if", "so", "configured", "and", "synchronize", "revocation", "registry", "to", "tails", "tree", "content", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L376-L392
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.close
async def close(self) -> None: """ Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object ""...
python
async def close(self) -> None: """ Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object ""...
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'Verifier.close >>>'", ")", "if", "self", ".", "config", ".", "get", "(", "'archive-verifier-caches-on-close'", ",", "{", "}", ")", ":", "await", "self", ".", "lo...
Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object
[ "Explicit", "exit", ".", "If", "so", "configured", "populate", "cache", "to", "prove", "for", "any", "creds", "on", "schemata", "cred", "defs", "and", "rev", "regs", "marked", "of", "interest", "in", "configuration", "at", "initialization", "archive", "cache",...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L394-L411
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.check_encoding
def check_encoding(proof_req: dict, proof: dict) -> bool: """ Return whether the proof's raw values correspond to their encodings as cross-referenced against proof request. :param proof request: proof request :param proof: corresponding proof to check :return: True if OK...
python
def check_encoding(proof_req: dict, proof: dict) -> bool: """ Return whether the proof's raw values correspond to their encodings as cross-referenced against proof request. :param proof request: proof request :param proof: corresponding proof to check :return: True if OK...
[ "def", "check_encoding", "(", "proof_req", ":", "dict", ",", "proof", ":", "dict", ")", "->", "bool", ":", "LOGGER", ".", "debug", "(", "'Verifier.check_encoding <<< proof_req: %s, proof: %s'", ",", "proof_req", ",", "proof", ")", "cd_id2proof_id", "=", "{", "}"...
Return whether the proof's raw values correspond to their encodings as cross-referenced against proof request. :param proof request: proof request :param proof: corresponding proof to check :return: True if OK, False for encoding mismatch
[ "Return", "whether", "the", "proof", "s", "raw", "values", "correspond", "to", "their", "encodings", "as", "cross", "-", "referenced", "against", "proof", "request", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L414-L457
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/verifier.py
Verifier.verify_proof
async def verify_proof(self, proof_req: dict, proof: dict) -> str: """ Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above ...
python
async def verify_proof(self, proof_req: dict, proof: dict) -> str: """ Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above ...
[ "async", "def", "verify_proof", "(", "self", ",", "proof_req", ":", "dict", ",", "proof", ":", "dict", ")", "->", "str", ":", "LOGGER", ".", "debug", "(", "'Verifier.verify_proof >>> proof_req: %s, proof: %s'", ",", "proof_req", ",", "proof", ")", "if", "not",...
Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above :param proof: proof as HolderProver creates :return: json encoded True if p...
[ "Verify", "proof", "as", "Verifier", ".", "Raise", "AbsentRevReg", "if", "a", "proof", "cites", "a", "revocation", "registry", "that", "does", "not", "exist", "on", "the", "distributed", "ledger", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/verifier.py#L459-L545
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/publickey.py
PublicKeyType.get
def get(value: str) -> 'Protocol': """ Return enum instance corresponding to input version value ('RsaVerificationKey2018' etc.) """ for pktype in PublicKeyType: if value in (pktype.ver_type, pktype.authn_type): return pktype return None
python
def get(value: str) -> 'Protocol': """ Return enum instance corresponding to input version value ('RsaVerificationKey2018' etc.) """ for pktype in PublicKeyType: if value in (pktype.ver_type, pktype.authn_type): return pktype return None
[ "def", "get", "(", "value", ":", "str", ")", "->", "'Protocol'", ":", "for", "pktype", "in", "PublicKeyType", ":", "if", "value", "in", "(", "pktype", ".", "ver_type", ",", "pktype", ".", "authn_type", ")", ":", "return", "pktype", "return", "None" ]
Return enum instance corresponding to input version value ('RsaVerificationKey2018' etc.)
[ "Return", "enum", "instance", "corresponding", "to", "input", "version", "value", "(", "RsaVerificationKey2018", "etc", ".", ")" ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/publickey.py#L46-L54
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/publickey.py
PublicKey.to_dict
def to_dict(self): """ Return dict representation of public key to embed in DID document. """ return { 'id': self.id, 'type': str(self.type.ver_type), 'controller': canon_ref(self.did, self.controller), **self.type.specification(self.value...
python
def to_dict(self): """ Return dict representation of public key to embed in DID document. """ return { 'id': self.id, 'type': str(self.type.ver_type), 'controller': canon_ref(self.did, self.controller), **self.type.specification(self.value...
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "'id'", ":", "self", ".", "id", ",", "'type'", ":", "str", "(", "self", ".", "type", ".", "ver_type", ")", ",", "'controller'", ":", "canon_ref", "(", "self", ".", "did", ",", "self", ".", "...
Return dict representation of public key to embed in DID document.
[ "Return", "dict", "representation", "of", "public", "key", "to", "embed", "in", "DID", "document", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/publickey.py#L195-L205
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
main
async def main(wallet_name: str) -> None: """ Main line for revocation registry builder operating in external process on behalf of issuer agent. :param wallet_name: wallet name - must match that of issuer with existing wallet """ logging.basicConfig(level=logging.WARN, format='%(levelname)-8s | %(...
python
async def main(wallet_name: str) -> None: """ Main line for revocation registry builder operating in external process on behalf of issuer agent. :param wallet_name: wallet name - must match that of issuer with existing wallet """ logging.basicConfig(level=logging.WARN, format='%(levelname)-8s | %(...
[ "async", "def", "main", "(", "wallet_name", ":", "str", ")", "->", "None", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "WARN", ",", "format", "=", "'%(levelname)-8s | %(name)-12s | %(message)s'", ")", "logging", ".", "getLogger", "("...
Main line for revocation registry builder operating in external process on behalf of issuer agent. :param wallet_name: wallet name - must match that of issuer with existing wallet
[ "Main", "line", "for", "revocation", "registry", "builder", "operating", "in", "external", "process", "on", "behalf", "of", "issuer", "agent", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L400-L428
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder._start_data_json
def _start_data_json(self) -> str: """ Output json with start data to write for external revocation registry builder process pickup. :return: logging and wallet init data json """ rv = { 'logging': { 'paths': [] }, 'wallet': {...
python
def _start_data_json(self) -> str: """ Output json with start data to write for external revocation registry builder process pickup. :return: logging and wallet init data json """ rv = { 'logging': { 'paths': [] }, 'wallet': {...
[ "def", "_start_data_json", "(", "self", ")", "->", "str", ":", "rv", "=", "{", "'logging'", ":", "{", "'paths'", ":", "[", "]", "}", ",", "'wallet'", ":", "{", "}", "}", "logger", "=", "LOGGER", "while", "not", "logger", ".", "level", ":", "logger"...
Output json with start data to write for external revocation registry builder process pickup. :return: logging and wallet init data json
[ "Output", "json", "with", "start", "data", "to", "write", "for", "external", "revocation", "registry", "builder", "process", "pickup", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L143-L179
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder._get_state
def _get_state(wallet_name: str) -> _STATE: """ Return current state of revocation registry builder process. :param wallet_name: name of wallet for corresponding Issuer :return: current process state as _STATE enum """ dir_sentinel = RevRegBuilder.dir_tails_sentinel(wal...
python
def _get_state(wallet_name: str) -> _STATE: """ Return current state of revocation registry builder process. :param wallet_name: name of wallet for corresponding Issuer :return: current process state as _STATE enum """ dir_sentinel = RevRegBuilder.dir_tails_sentinel(wal...
[ "def", "_get_state", "(", "wallet_name", ":", "str", ")", "->", "_STATE", ":", "dir_sentinel", "=", "RevRegBuilder", ".", "dir_tails_sentinel", "(", "wallet_name", ")", "file_pid", "=", "join", "(", "dir_sentinel", ",", "'.pid'", ")", "file_start", "=", "join"...
Return current state of revocation registry builder process. :param wallet_name: name of wallet for corresponding Issuer :return: current process state as _STATE enum
[ "Return", "current", "state", "of", "revocation", "registry", "builder", "process", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L182-L201
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.dir_tails_top
def dir_tails_top(self, rr_id) -> str: """ Return top of tails tree for input rev reg id. :param rr_id: revocation registry identifier :return: top of tails tree """ return join(self.dir_tails_hopper, rr_id) if self.external else self.dir_tails
python
def dir_tails_top(self, rr_id) -> str: """ Return top of tails tree for input rev reg id. :param rr_id: revocation registry identifier :return: top of tails tree """ return join(self.dir_tails_hopper, rr_id) if self.external else self.dir_tails
[ "def", "dir_tails_top", "(", "self", ",", "rr_id", ")", "->", "str", ":", "return", "join", "(", "self", ".", "dir_tails_hopper", ",", "rr_id", ")", "if", "self", ".", "external", "else", "self", ".", "dir_tails" ]
Return top of tails tree for input rev reg id. :param rr_id: revocation registry identifier :return: top of tails tree
[ "Return", "top", "of", "tails", "tree", "for", "input", "rev", "reg", "id", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L215-L223
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.dir_tails_target
def dir_tails_target(self, rr_id) -> str: """ Return target directory for revocation registry and tails file production. :param rr_id: revocation registry identifier :return: tails target directory """ return join(self.dir_tails_top(rr_id), rev_reg_id2cred_def_id(rr_id)...
python
def dir_tails_target(self, rr_id) -> str: """ Return target directory for revocation registry and tails file production. :param rr_id: revocation registry identifier :return: tails target directory """ return join(self.dir_tails_top(rr_id), rev_reg_id2cred_def_id(rr_id)...
[ "def", "dir_tails_target", "(", "self", ",", "rr_id", ")", "->", "str", ":", "return", "join", "(", "self", ".", "dir_tails_top", "(", "rr_id", ")", ",", "rev_reg_id2cred_def_id", "(", "rr_id", ")", ")" ]
Return target directory for revocation registry and tails file production. :param rr_id: revocation registry identifier :return: tails target directory
[ "Return", "target", "directory", "for", "revocation", "registry", "and", "tails", "file", "production", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L225-L233
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.mark_in_progress
def mark_in_progress(self, rr_id: str, rr_size: int) -> None: """ Prepare sentinel directory for revocation registry construction. :param rr_id: revocation registry identifier :rr_size: size of revocation registry to build """ try: makedirs(join(self._dir_tai...
python
def mark_in_progress(self, rr_id: str, rr_size: int) -> None: """ Prepare sentinel directory for revocation registry construction. :param rr_id: revocation registry identifier :rr_size: size of revocation registry to build """ try: makedirs(join(self._dir_tai...
[ "def", "mark_in_progress", "(", "self", ",", "rr_id", ":", "str", ",", "rr_size", ":", "int", ")", "->", "None", ":", "try", ":", "makedirs", "(", "join", "(", "self", ".", "_dir_tails_sentinel", ",", "rr_id", ")", ",", "exist_ok", "=", "False", ")", ...
Prepare sentinel directory for revocation registry construction. :param rr_id: revocation registry identifier :rr_size: size of revocation registry to build
[ "Prepare", "sentinel", "directory", "for", "revocation", "registry", "construction", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L235-L247
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.serve
async def serve(self) -> None: """ Write pidfile to sentinel directory if need be, and wait for sentinels to shut down or build revocation registry and tails file. """ LOGGER.debug('RevRegBuilder.serve >>>') assert self.external file_pid = join(self._dir_tails_...
python
async def serve(self) -> None: """ Write pidfile to sentinel directory if need be, and wait for sentinels to shut down or build revocation registry and tails file. """ LOGGER.debug('RevRegBuilder.serve >>>') assert self.external file_pid = join(self._dir_tails_...
[ "async", "def", "serve", "(", "self", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'RevRegBuilder.serve >>>'", ")", "assert", "self", ".", "external", "file_pid", "=", "join", "(", "self", ".", "_dir_tails_sentinel", ",", "'.pid'", ")", "if", "isf...
Write pidfile to sentinel directory if need be, and wait for sentinels to shut down or build revocation registry and tails file.
[ "Write", "pidfile", "to", "sentinel", "directory", "if", "need", "be", "and", "wait", "for", "sentinels", "to", "shut", "down", "or", "build", "revocation", "registry", "and", "tails", "file", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L249-L301
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.stop
async def stop(wallet_name: str) -> None: """ Gracefully stop an external revocation registry builder, waiting for its current. The indy-sdk toolkit uses a temporary directory for tails file mustration, and shutting down the toolkit removes the directory, crashing the external t...
python
async def stop(wallet_name: str) -> None: """ Gracefully stop an external revocation registry builder, waiting for its current. The indy-sdk toolkit uses a temporary directory for tails file mustration, and shutting down the toolkit removes the directory, crashing the external t...
[ "async", "def", "stop", "(", "wallet_name", ":", "str", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'RevRegBuilder.stop >>>'", ")", "dir_sentinel", "=", "join", "(", "RevRegBuilder", ".", "dir_tails_sentinel", "(", "wallet_name", ")", ")", "if", "i...
Gracefully stop an external revocation registry builder, waiting for its current. The indy-sdk toolkit uses a temporary directory for tails file mustration, and shutting down the toolkit removes the directory, crashing the external tails file write. This method allows a graceful stop to wait fo...
[ "Gracefully", "stop", "an", "external", "revocation", "registry", "builder", "waiting", "for", "its", "current", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L304-L327
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/rrbuilder.py
RevRegBuilder.create_rev_reg
async def create_rev_reg(self, rr_id: str, rr_size: int = None) -> None: """ Create revocation registry artifacts and new tails file (with association to corresponding revocation registry identifier via symbolic link name) for input revocation registry identifier. Symbolic link presence ...
python
async def create_rev_reg(self, rr_id: str, rr_size: int = None) -> None: """ Create revocation registry artifacts and new tails file (with association to corresponding revocation registry identifier via symbolic link name) for input revocation registry identifier. Symbolic link presence ...
[ "async", "def", "create_rev_reg", "(", "self", ",", "rr_id", ":", "str", ",", "rr_size", ":", "int", "=", "None", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'RevRegBuilder.create_rev_reg >>> rr_id: %s, rr_size: %s'", ",", "rr_id", ",", "rr_size", ")...
Create revocation registry artifacts and new tails file (with association to corresponding revocation registry identifier via symbolic link name) for input revocation registry identifier. Symbolic link presence signals completion. If revocation registry builder operates in a process external to ...
[ "Create", "revocation", "registry", "artifacts", "and", "new", "tails", "file", "(", "with", "association", "to", "corresponding", "revocation", "registry", "identifier", "via", "symbolic", "link", "name", ")", "for", "input", "revocation", "registry", "identifier",...
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/rrbuilder.py#L329-L397
praekelt/django-ultracache
ultracache/templatetags/ultracache_tags.py
do_ultracache
def do_ultracache(parser, token): """Based on Django's default cache template tag""" nodelist = parser.parse(("endultracache",)) parser.delete_first_token() tokens = token.split_contents() if len(tokens) < 3: raise TemplateSyntaxError(""%r" tag requires at least 2 arguments." % tokens[0]) ...
python
def do_ultracache(parser, token): """Based on Django's default cache template tag""" nodelist = parser.parse(("endultracache",)) parser.delete_first_token() tokens = token.split_contents() if len(tokens) < 3: raise TemplateSyntaxError(""%r" tag requires at least 2 arguments." % tokens[0]) ...
[ "def", "do_ultracache", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "\"endultracache\"", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "tokens", "=", "token", ".", "split_contents", "(", ")", ...
Based on Django's default cache template tag
[ "Based", "on", "Django", "s", "default", "cache", "template", "tag" ]
train
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/templatetags/ultracache_tags.py#L88-L98
PSPC-SPAC-buyandsell/von_anchor
von_anchor/frill.py
ppjson
def ppjson(dumpit: Any, elide_to: int = None) -> str: """ JSON pretty printer, whether already json-encoded or not :param dumpit: object to pretty-print :param elide_to: optional maximum length including ellipses ('...') :return: json pretty-print """ if elide_to is not None: elide...
python
def ppjson(dumpit: Any, elide_to: int = None) -> str: """ JSON pretty printer, whether already json-encoded or not :param dumpit: object to pretty-print :param elide_to: optional maximum length including ellipses ('...') :return: json pretty-print """ if elide_to is not None: elide...
[ "def", "ppjson", "(", "dumpit", ":", "Any", ",", "elide_to", ":", "int", "=", "None", ")", "->", "str", ":", "if", "elide_to", "is", "not", "None", ":", "elide_to", "=", "max", "(", "elide_to", ",", "3", ")", "# make room for ellipses '...'", "try", ":...
JSON pretty printer, whether already json-encoded or not :param dumpit: object to pretty-print :param elide_to: optional maximum length including ellipses ('...') :return: json pretty-print
[ "JSON", "pretty", "printer", "whether", "already", "json", "-", "encoded", "or", "not" ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/frill.py#L30-L45
PSPC-SPAC-buyandsell/von_anchor
von_anchor/frill.py
do_wait
def do_wait(coro: Callable) -> Any: """ Perform aynchronous operation; await then return the result. :param coro: coroutine to await :return: coroutine result """ event_loop = None try: event_loop = asyncio.get_event_loop() except RuntimeError: event_loop = asyncio.new_...
python
def do_wait(coro: Callable) -> Any: """ Perform aynchronous operation; await then return the result. :param coro: coroutine to await :return: coroutine result """ event_loop = None try: event_loop = asyncio.get_event_loop() except RuntimeError: event_loop = asyncio.new_...
[ "def", "do_wait", "(", "coro", ":", "Callable", ")", "->", "Any", ":", "event_loop", "=", "None", "try", ":", "event_loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "except", "RuntimeError", ":", "event_loop", "=", "asyncio", ".", "new_event_loop", ...
Perform aynchronous operation; await then return the result. :param coro: coroutine to await :return: coroutine result
[ "Perform", "aynchronous", "operation", ";", "await", "then", "return", "the", "result", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/frill.py#L48-L62
PSPC-SPAC-buyandsell/von_anchor
von_anchor/frill.py
inis2dict
def inis2dict(ini_paths: Union[str, Sequence[str]]) -> dict: """ Take one or more ini files and return a dict with configuration from all, interpolating bash-style variables ${VAR} or ${VAR:-DEFAULT}. :param ini_paths: path or paths to .ini files """ var_dflt = r'\${(.*?):-(.*?)}' def _int...
python
def inis2dict(ini_paths: Union[str, Sequence[str]]) -> dict: """ Take one or more ini files and return a dict with configuration from all, interpolating bash-style variables ${VAR} or ${VAR:-DEFAULT}. :param ini_paths: path or paths to .ini files """ var_dflt = r'\${(.*?):-(.*?)}' def _int...
[ "def", "inis2dict", "(", "ini_paths", ":", "Union", "[", "str", ",", "Sequence", "[", "str", "]", "]", ")", "->", "dict", ":", "var_dflt", "=", "r'\\${(.*?):-(.*?)}'", "def", "_interpolate", "(", "content", ")", ":", "rv", "=", "expandvars", "(", "conten...
Take one or more ini files and return a dict with configuration from all, interpolating bash-style variables ${VAR} or ${VAR:-DEFAULT}. :param ini_paths: path or paths to .ini files
[ "Take", "one", "or", "more", "ini", "files", "and", "return", "a", "dict", "with", "configuration", "from", "all", "interpolating", "bash", "-", "style", "variables", "$", "{", "VAR", "}", "or", "$", "{", "VAR", ":", "-", "DEFAULT", "}", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/frill.py#L65-L95
PSPC-SPAC-buyandsell/von_anchor
von_anchor/frill.py
Stopwatch.mark
def mark(self, digits: int = None) -> float: """ Return time in seconds since last mark, reset, or construction. :param digits: number of fractional decimal digits to retain (default as constructed) """ self._mark[:] = [self._mark[1], time()] rv = self._mark[1] - self._...
python
def mark(self, digits: int = None) -> float: """ Return time in seconds since last mark, reset, or construction. :param digits: number of fractional decimal digits to retain (default as constructed) """ self._mark[:] = [self._mark[1], time()] rv = self._mark[1] - self._...
[ "def", "mark", "(", "self", ",", "digits", ":", "int", "=", "None", ")", "->", "float", ":", "self", ".", "_mark", "[", ":", "]", "=", "[", "self", ".", "_mark", "[", "1", "]", ",", "time", "(", ")", "]", "rv", "=", "self", ".", "_mark", "[...
Return time in seconds since last mark, reset, or construction. :param digits: number of fractional decimal digits to retain (default as constructed)
[ "Return", "time", "in", "seconds", "since", "last", "mark", "reset", "or", "construction", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/frill.py#L113-L130
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/search.py
StorageRecordSearch.open
async def open(self) -> None: """ Begin the search operation. """ LOGGER.debug('StorageRecordSearch.open >>>') if self.opened: LOGGER.debug('StorageRecordSearch.open <!< Search is already opened') raise BadSearch('Search is already opened') if n...
python
async def open(self) -> None: """ Begin the search operation. """ LOGGER.debug('StorageRecordSearch.open >>>') if self.opened: LOGGER.debug('StorageRecordSearch.open <!< Search is already opened') raise BadSearch('Search is already opened') if n...
[ "async", "def", "open", "(", "self", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'StorageRecordSearch.open >>>'", ")", "if", "self", ".", "opened", ":", "LOGGER", ".", "debug", "(", "'StorageRecordSearch.open <!< Search is already opened'", ")", "raise",...
Begin the search operation.
[ "Begin", "the", "search", "operation", "." ]
train
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/search.py#L97-L118