hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
097d53d68175b519a04c92e81ce2055dfa82de98 | collectiveacuity/labPack | labpack/platforms/heroku.py | [
"MIT"
] | Python | _validate_login | <not_specific> | def _validate_login(self):
''' a method to validate user can access heroku account '''
title = '%s.validate_login' % self.__class__.__name__
# verbosity
windows_insert = ' On windows, run in cmd.exe'
self.printer('Checking heroku credentials ...... | a method to validate user can access heroku account | a method to validate user can access heroku account | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"heroku",
"account"
] | def _validate_login(self):
title = '%s.validate_login' % self.__class__.__name__
windows_insert = ' On windows, run in cmd.exe'
self.printer('Checking heroku credentials ... ', flush=True)
from os import path
netrc_path = path.join(self.localhost.home, '.netrc')
if not pa... | [
"def",
"_validate_login",
"(",
"self",
")",
":",
"title",
"=",
"'%s.validate_login'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"windows_insert",
"=",
"' On windows, run in cmd.exe'",
"self",
".",
"printer",
"(",
"'Checking heroku credentials ... '",
",",
"flush... | a method to validate user can access heroku account | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"heroku",
"account"
] | [
"''' a method to validate user can access heroku account '''",
"# verbosity\r",
"# validate netrc exists\r",
"# TODO verify path exists on Windows\r",
"# replace value in netrc\r",
"# verify remote access\r",
"# define process closing helper\r",
"# close process\r",
"# restore values to netrc\r",
... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
097d53d68175b519a04c92e81ce2055dfa82de98 | collectiveacuity/labPack | labpack/platforms/heroku.py | [
"MIT"
] | Python | access | <not_specific> | def access(self, app_subdomain):
''' a method to validate user can access app '''
title = '%s.access' % self.__class__.__name__
# validate input
input_fields = {
'app_subdomain': app_subdomain
}
for key, value in input_fields.items():
... | a method to validate user can access app | a method to validate user can access app | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"app"
] | def access(self, app_subdomain):
title = '%s.access' % self.__class__.__name__
input_fields = {
'app_subdomain': app_subdomain
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validate(value, '... | [
"def",
"access",
"(",
"self",
",",
"app_subdomain",
")",
":",
"title",
"=",
"'%s.access'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'app_subdomain'",
":",
"app_subdomain",
"}",
"for",
"key",
",",
"value",
"in",
"input_fields... | a method to validate user can access app | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"app"
] | [
"''' a method to validate user can access app '''",
"# validate input\r",
"# verbosity\r",
"# confirm existence of subdomain\r",
"# refresh app list and search again\r",
"# check reason for failure\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "app_subdomain",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "app_subdomain",
"type": null,
"docstring": null,
"docstring_t... |
097d53d68175b519a04c92e81ce2055dfa82de98 | collectiveacuity/labPack | labpack/platforms/heroku.py | [
"MIT"
] | Python | deploy_docker | <not_specific> | def deploy_docker(self, dockerfile_path, virtualbox_name='default'):
''' a method to deploy app to heroku using docker '''
title = '%s.deploy_docker' % self.__class__.__name__
# validate inputs
input_fields = {
'dockerfile_path': dockerfile_path,
'virtualb... | a method to deploy app to heroku using docker | a method to deploy app to heroku using docker | [
"a",
"method",
"to",
"deploy",
"app",
"to",
"heroku",
"using",
"docker"
] | def deploy_docker(self, dockerfile_path, virtualbox_name='default'):
title = '%s.deploy_docker' % self.__class__.__name__
input_fields = {
'dockerfile_path': dockerfile_path,
'virtualbox_name': virtualbox_name
}
for key, value in input_fields.items():
... | [
"def",
"deploy_docker",
"(",
"self",
",",
"dockerfile_path",
",",
"virtualbox_name",
"=",
"'default'",
")",
":",
"title",
"=",
"'%s.deploy_docker'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'dockerfile_path'",
":",
"dockerfile_pat... | a method to deploy app to heroku using docker | [
"a",
"method",
"to",
"deploy",
"app",
"to",
"heroku",
"using",
"docker"
] | [
"''' a method to deploy app to heroku using docker '''",
"# validate inputs\r",
"# check app subdomain\r",
"# import dependencies\r",
"# validate docker client\r",
"# validate dockerfile\r",
"# validate container plugin\r",
"# verify container login\r",
"# sys_command = 'heroku container:login' # ra... | [
{
"param": "self",
"type": null
},
{
"param": "dockerfile_path",
"type": null
},
{
"param": "virtualbox_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dockerfile_path",
"type": null,
"docstring": null,
"docstring... |
097d53d68175b519a04c92e81ce2055dfa82de98 | collectiveacuity/labPack | labpack/platforms/heroku.py | [
"MIT"
] | Python | deploy_app | <not_specific> | def deploy_app(self, site_folder, runtime_type=''):
''' a method to deploy a static html page to heroku using php '''
title = '%s.deploy_php' % self.__class__.__name__
# validate inputs
input_fields = {
'site_folder': site_folder,
'runtime_type': runtime_t... | a method to deploy a static html page to heroku using php | a method to deploy a static html page to heroku using php | [
"a",
"method",
"to",
"deploy",
"a",
"static",
"html",
"page",
"to",
"heroku",
"using",
"php"
] | def deploy_app(self, site_folder, runtime_type=''):
title = '%s.deploy_php' % self.__class__.__name__
input_fields = {
'site_folder': site_folder,
'runtime_type': runtime_type
}
for key, value in input_fields.items():
if value:
object_t... | [
"def",
"deploy_app",
"(",
"self",
",",
"site_folder",
",",
"runtime_type",
"=",
"''",
")",
":",
"title",
"=",
"'%s.deploy_php'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'site_folder'",
":",
"site_folder",
",",
"'runtime_type'... | a method to deploy a static html page to heroku using php | [
"a",
"method",
"to",
"deploy",
"a",
"static",
"html",
"page",
"to",
"heroku",
"using",
"php"
] | [
"''' a method to deploy a static html page to heroku using php '''",
"# validate inputs\r",
"# verify app subdomain\r",
"# validate existence of site folder\r",
"# validate existence of proper runtime file\r",
"# validate container plugin\r",
"# construct temporary folder\r",
"# define cleanup functio... | [
{
"param": "self",
"type": null
},
{
"param": "site_folder",
"type": null
},
{
"param": "runtime_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "site_folder",
"type": null,
"docstring": null,
"docstring_tok... |
a1e49794c6f18e53f3a94dd7e319dd4795cbe437 | collectiveacuity/labPack | labpack/messaging/twilio.py | [
"MIT"
] | Python | send_message | <not_specific> | def send_message(self, phone_number, message_text):
''' send an SMS from the Twilio account to phone number
:param phone_number: string with phone number with country and area code
:param message_text: string with message text
:return: dictionary with details of response
... | send an SMS from the Twilio account to phone number
:param phone_number: string with phone number with country and area code
:param message_text: string with message text
:return: dictionary with details of response
{
'direction': 'outbound-api',
'to': ... | send an SMS from the Twilio account to phone number | [
"send",
"an",
"SMS",
"from",
"the",
"Twilio",
"account",
"to",
"phone",
"number"
] | def send_message(self, phone_number, message_text):
response = self.client.messages.save(
to=phone_number,
from_=self.twilio_phone,
body=message_text
)
keys = ['body', 'status', 'error_code', 'direction', 'date_updated', 'to', 'from_']
response_details... | [
"def",
"send_message",
"(",
"self",
",",
"phone_number",
",",
"message_text",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"messages",
".",
"save",
"(",
"to",
"=",
"phone_number",
",",
"from_",
"=",
"self",
".",
"twilio_phone",
",",
"body",
"="... | send an SMS from the Twilio account to phone number | [
"send",
"an",
"SMS",
"from",
"the",
"Twilio",
"account",
"to",
"phone",
"number"
] | [
"''' send an SMS from the Twilio account to phone number\r\n\r\n :param phone_number: string with phone number with country and area code\r\n :param message_text: string with message text\r\n :return: dictionary with details of response\r\n\r\n {\r\n 'direction': 'outbound-api... | [
{
"param": "self",
"type": null
},
{
"param": "phone_number",
"type": null
},
{
"param": "message_text",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7420d88e103eeb414d2e4bb818e3f8c4a58b59ef | collectiveacuity/labPack | labpack/compilers/filters.py | [
"MIT"
] | Python | positional_filter | <not_specific> | def positional_filter(positional_filters, title=''):
'''
a method to construct a conditional filter function to test positional arguments
:param positional_filters: dictionary or list of dictionaries with query criteria
:param title: string with name of function to use instead
:return: callab... |
a method to construct a conditional filter function to test positional arguments
:param positional_filters: dictionary or list of dictionaries with query criteria
:param title: string with name of function to use instead
:return: callable for filter_function
NOTE: query criteria architect... | a method to construct a conditional filter function to test positional arguments | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"to",
"test",
"positional",
"arguments"
] | def positional_filter(positional_filters, title=''):
if not title:
title = 'positional_filter'
filter_arg = '%s(positional_filters=[...])' % title
filter_schema = {
'schema': {
'byte_data': False,
'discrete_values': [ '' ],
'excluded_values': [ '' ],
... | [
"def",
"positional_filter",
"(",
"positional_filters",
",",
"title",
"=",
"''",
")",
":",
"if",
"not",
"title",
":",
"title",
"=",
"'positional_filter'",
"filter_arg",
"=",
"'%s(positional_filters=[...])'",
"%",
"title",
"filter_schema",
"=",
"{",
"'schema'",
":",... | a method to construct a conditional filter function to test positional arguments | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"to",
"test",
"positional",
"arguments"
] | [
"''' \n a method to construct a conditional filter function to test positional arguments\n\n :param positional_filters: dictionary or list of dictionaries with query criteria\n :param title: string with name of function to use instead\n :return: callable for filter_function \n\n NOTE: query cri... | [
{
"param": "positional_filters",
"type": null
},
{
"param": "title",
"type": null
}
] | {
"returns": [
{
"docstring": "callable for filter_function\nNOTE: query criteria architecture\n\neach item in the path filters argument must be a dictionary\nwhich is composed of integer-value key names that represent the\nindex value of the positional segment to test and key values\nwith the dictionary ... |
ba2d5cb569ad6889811bf9a1a38d5091a09f197d | collectiveacuity/labPack | labpack/banking/capitalone.py | [
"MIT"
] | Python | _requests | <not_specific> | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
''' a helper method for relaying requests from client to api '''
title = '%s._requests' % self.__class__.__name__
# import dependencies
from time import time
import requests
# valid... | a helper method for relaying requests from client to api | a helper method for relaying requests from client to api | [
"a",
"helper",
"method",
"for",
"relaying",
"requests",
"from",
"client",
"to",
"api"
] | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
title = '%s._requests' % self.__class__.__name__
from time import time
import requests
if not self._access_token:
self.access_token()
if self.retrieve_details:
... | [
"def",
"_requests",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"title",
"=",
"'%s._requests'",
"%",
"self",
".",
"__... | a helper method for relaying requests from client to api | [
"a",
"helper",
"method",
"for",
"relaying",
"requests",
"from",
"client",
"to",
"api"
] | [
"''' a helper method for relaying requests from client to api '''",
"# import dependencies",
"# validate access token",
"# refresh token",
"# construct request kwargs",
"# send request",
"# handle response"
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "method",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "errors",
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
ba2d5cb569ad6889811bf9a1a38d5091a09f197d | collectiveacuity/labPack | labpack/banking/capitalone.py | [
"MIT"
] | Python | _get_products | <not_specific> | def _get_products(self):
''' a method to retrieve account product details at initialization '''
# request product list
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
# construct list of produc... | a method to retrieve account product details at initialization | a method to retrieve account product details at initialization | [
"a",
"method",
"to",
"retrieve",
"account",
"product",
"details",
"at",
"initialization"
] | def _get_products(self):
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
product_ids = []
for product in products_request["json"]["entries"]:
product_ids.append(product['productId'])
self.... | [
"def",
"_get_products",
"(",
"self",
")",
":",
"products_request",
"=",
"self",
".",
"account_products",
"(",
")",
"if",
"products_request",
"[",
"'error'",
"]",
":",
"raise",
"Exception",
"(",
"products_request",
"[",
"'error'",
"]",
")",
"product_ids",
"=",
... | a method to retrieve account product details at initialization | [
"a",
"method",
"to",
"retrieve",
"account",
"product",
"details",
"at",
"initialization"
] | [
"''' a method to retrieve account product details at initialization '''",
"# request product list",
"# construct list of product ids",
"# construct default product map",
"# request product details"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba2d5cb569ad6889811bf9a1a38d5091a09f197d | collectiveacuity/labPack | labpack/banking/capitalone.py | [
"MIT"
] | Python | access_token | <not_specific> | def access_token(self):
''' a method to acquire an oauth access token '''
title = '%s.access_token' % self.__class__.__name__
# import dependencies
from time import time
import requests
# construct request kwargs
request_kwargs = {
'url': self.token_en... | a method to acquire an oauth access token | a method to acquire an oauth access token | [
"a",
"method",
"to",
"acquire",
"an",
"oauth",
"access",
"token"
] | def access_token(self):
title = '%s.access_token' % self.__class__.__name__
from time import time
import requests
request_kwargs = {
'url': self.token_endpoint,
'data': {
'client_id': self.client_id,
'client_secret': self.client_sec... | [
"def",
"access_token",
"(",
"self",
")",
":",
"title",
"=",
"'%s.access_token'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"from",
"time",
"import",
"time",
"import",
"requests",
"request_kwargs",
"=",
"{",
"'url'",
":",
"self",
".",
"token_endpoint",
... | a method to acquire an oauth access token | [
"a",
"method",
"to",
"acquire",
"an",
"oauth",
"access",
"token"
] | [
"''' a method to acquire an oauth access token '''",
"# import dependencies",
"# construct request kwargs",
"# send request"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1f347f89b3fa4703790a2929995bc77f641fc0cb | collectiveacuity/labPack | labpack/platforms/localhost.py | [
"MIT"
] | Python | walk | null | def walk(self, walk_root='', reverse_order=False, previous_file=''):
''' a generator method of file paths on localhost from walk of directories
:param walk_root: string with path from which to root walk of localhost directories
:param reverse_order: boolean to determine alphabetical direction ... | a generator method of file paths on localhost from walk of directories
:param walk_root: string with path from which to root walk of localhost directories
:param reverse_order: boolean to determine alphabetical direction of walk
:param previous_file: string with path of file after which to sta... | a generator method of file paths on localhost from walk of directories | [
"a",
"generator",
"method",
"of",
"file",
"paths",
"on",
"localhost",
"from",
"walk",
"of",
"directories"
] | def walk(self, walk_root='', reverse_order=False, previous_file=''):
__name__ = '%s.walk(...)' % self.__class__.__name__
input_kwargs = [walk_root, previous_file]
input_names = ['.walk_root', '.previous_file']
for i in range(len(input_kwargs)):
if input_kwargs[i]:
... | [
"def",
"walk",
"(",
"self",
",",
"walk_root",
"=",
"''",
",",
"reverse_order",
"=",
"False",
",",
"previous_file",
"=",
"''",
")",
":",
"__name__",
"=",
"'%s.walk(...)'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_kwargs",
"=",
"[",
"walk_root"... | a generator method of file paths on localhost from walk of directories | [
"a",
"generator",
"method",
"of",
"file",
"paths",
"on",
"localhost",
"from",
"walk",
"of",
"directories"
] | [
"''' a generator method of file paths on localhost from walk of directories\n\n :param walk_root: string with path from which to root walk of localhost directories\n :param reverse_order: boolean to determine alphabetical direction of walk\n :param previous_file: string with path of file after ... | [
{
"param": "self",
"type": null
},
{
"param": "walk_root",
"type": null
},
{
"param": "reverse_order",
"type": null
},
{
"param": "previous_file",
"type": null
}
] | {
"returns": [
{
"docstring": "string with absolute path to file",
"docstring_tokens": [
"string",
"with",
"absolute",
"path",
"to",
"file"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type... |
1f347f89b3fa4703790a2929995bc77f641fc0cb | collectiveacuity/labPack | labpack/platforms/localhost.py | [
"MIT"
] | Python | metadata | <not_specific> | def metadata(self, file_path):
''' a method to retrieve the metadata of a file on the localhost
:param file_path: string with path to file
:return: dictionary with file properties
'''
__name__ = '%s.metadata(...)' % self.__class__.__name__
# validate input
self.fi... | a method to retrieve the metadata of a file on the localhost
:param file_path: string with path to file
:return: dictionary with file properties
| a method to retrieve the metadata of a file on the localhost | [
"a",
"method",
"to",
"retrieve",
"the",
"metadata",
"of",
"a",
"file",
"on",
"the",
"localhost"
] | def metadata(self, file_path):
__name__ = '%s.metadata(...)' % self.__class__.__name__
self.fields.validate(file_path, '.file_path')
file_exists = False
if os.path.exists(file_path):
if os.path.isfile(file_path):
file_exists = True
if not file_exists:
... | [
"def",
"metadata",
"(",
"self",
",",
"file_path",
")",
":",
"__name__",
"=",
"'%s.metadata(...)'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"self",
".",
"fields",
".",
"validate",
"(",
"file_path",
",",
"'.file_path'",
")",
"file_exists",
"=",
"False"... | a method to retrieve the metadata of a file on the localhost | [
"a",
"method",
"to",
"retrieve",
"the",
"metadata",
"of",
"a",
"file",
"on",
"the",
"localhost"
] | [
"''' a method to retrieve the metadata of a file on the localhost\n\n :param file_path: string with path to file\n :return: dictionary with file properties\n '''",
"# validate input",
"# construct metadata dictionary"
] | [
{
"param": "self",
"type": null
},
{
"param": "file_path",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with file properties",
"docstring_tokens": [
"dictionary",
"with",
"file",
"properties"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring"... |
1f347f89b3fa4703790a2929995bc77f641fc0cb | collectiveacuity/labPack | labpack/platforms/localhost.py | [
"MIT"
] | Python | conditional_filter | <not_specific> | def conditional_filter(self, metadata_filters):
''' a method to construct a conditional filter function for the list method
:param metadata_filters: list with query criteria dictionaries
:return: filter_function object
NOTE: query criteria architecture
each ... | a method to construct a conditional filter function for the list method
:param metadata_filters: list with query criteria dictionaries
:return: filter_function object
NOTE: query criteria architecture
each item in the metadata filters list must be a dictionary
... | a method to construct a conditional filter function for the list method | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"for",
"the",
"list",
"method"
] | def conditional_filter(self, metadata_filters):
self.fields.validate(metadata_filters, '.metadata_filters')
def query_function(**kwargs):
file_metadata = {}
for key, value in kwargs.items():
if key in self.file_model.schema.keys():
file_metadat... | [
"def",
"conditional_filter",
"(",
"self",
",",
"metadata_filters",
")",
":",
"self",
".",
"fields",
".",
"validate",
"(",
"metadata_filters",
",",
"'.metadata_filters'",
")",
"def",
"query_function",
"(",
"**",
"kwargs",
")",
":",
"file_metadata",
"=",
"{",
"}... | a method to construct a conditional filter function for the list method | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"for",
"the",
"list",
"method"
] | [
"''' a method to construct a conditional filter function for the list method\n\n :param metadata_filters: list with query criteria dictionaries\n :return: filter_function object\n\n NOTE: query criteria architecture\n\n each item in the metadata filters list must be a d... | [
{
"param": "self",
"type": null
},
{
"param": "metadata_filters",
"type": null
}
] | {
"returns": [
{
"docstring": "filter_function object\nNOTE: query criteria architecture\n\neach item in the metadata filters list must be a dictionary\nwhich is composed of one or more key names which represent the\ndotpath to a metadata element of the record to be queried with a\nkey value that is a dic... |
1f347f89b3fa4703790a2929995bc77f641fc0cb | collectiveacuity/labPack | labpack/platforms/localhost.py | [
"MIT"
] | Python | list | <not_specific> | def list(self, filter_function=None, list_root='', max_results=1, reverse_order=False, previous_file=''):
''' a method to list files on localhost from walk of directories
:param filter_function: (keyword arguments) function used to filter results
:param list_root: string with localhost path fr... | a method to list files on localhost from walk of directories
:param filter_function: (keyword arguments) function used to filter results
:param list_root: string with localhost path from which to root list of files
:param max_results: integer with maximum number of results to return
:p... | a method to list files on localhost from walk of directories | [
"a",
"method",
"to",
"list",
"files",
"on",
"localhost",
"from",
"walk",
"of",
"directories"
] | def list(self, filter_function=None, list_root='', max_results=1, reverse_order=False, previous_file=''):
__name__ = '%s.list(...)' % self.__class__.__name__
input_kwargs = [list_root, max_results, previous_file]
input_names = ['.list_root', '.max_results', '.previous_file']
for i in ran... | [
"def",
"list",
"(",
"self",
",",
"filter_function",
"=",
"None",
",",
"list_root",
"=",
"''",
",",
"max_results",
"=",
"1",
",",
"reverse_order",
"=",
"False",
",",
"previous_file",
"=",
"''",
")",
":",
"__name__",
"=",
"'%s.list(...)'",
"%",
"self",
"."... | a method to list files on localhost from walk of directories | [
"a",
"method",
"to",
"list",
"files",
"on",
"localhost",
"from",
"walk",
"of",
"directories"
] | [
"''' a method to list files on localhost from walk of directories\n\n :param filter_function: (keyword arguments) function used to filter results\n :param list_root: string with localhost path from which to root list of files\n :param max_results: integer with maximum number of results to retur... | [
{
"param": "self",
"type": null
},
{
"param": "filter_function",
"type": null
},
{
"param": "list_root",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "reverse_order",
"type": null
},
{
"param": "previous_file",
"type": null
... | {
"returns": [
{
"docstring": "list of file absolute path strings\nNOTE: the filter_function must be able to accept keyword arguments and\nreturn a value that can evaluate to true or false. while walking\nthe local file structure, the metadata for each file will be\nfed to the filter function. if the func... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _extract_columns | <not_specific> | def _extract_columns(self, table_name):
''' a method to extract the column properties of an existing table '''
import re
from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA, BIGI... | a method to extract the column properties of an existing table | a method to extract the column properties of an existing table | [
"a",
"method",
"to",
"extract",
"the",
"column",
"properties",
"of",
"an",
"existing",
"table"
] | def _extract_columns(self, table_name):
import re
from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA, BIGINT
metadata_object = MetaData()
table_list = self.engine.table_names()
pr... | [
"def",
"_extract_columns",
"(",
"self",
",",
"table_name",
")",
":",
"import",
"re",
"from",
"sqlalchemy",
"import",
"MetaData",
",",
"VARCHAR",
",",
"INTEGER",
",",
"BLOB",
",",
"BOOLEAN",
",",
"FLOAT",
"from",
"sqlalchemy",
".",
"dialects",
".",
"postgresq... | a method to extract the column properties of an existing table | [
"a",
"method",
"to",
"extract",
"the",
"column",
"properties",
"of",
"an",
"existing",
"table"
] | [
"''' a method to extract the column properties of an existing table '''",
"# retrieve list of tables",
"# determine columns",
"# Postgres"
] | [
{
"param": "self",
"type": null
},
{
"param": "table_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table_name",
"type": null,
"docstring": null,
"docstring_toke... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _parse_columns | <not_specific> | def _parse_columns(self):
''' a helper method for parsing the column properties from the record schema '''
# construct column list
column_map = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.it... | a helper method for parsing the column properties from the record schema | a helper method for parsing the column properties from the record schema | [
"a",
"helper",
"method",
"for",
"parsing",
"the",
"column",
"properties",
"from",
"the",
"record",
"schema"
] | def _parse_columns(self):
column_map = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.item_key.findall(record_key):
pass
else:
if value['value_datatype'] == 'map':... | [
"def",
"_parse_columns",
"(",
"self",
")",
":",
"column_map",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap",
".",
"items",
"(",
")",
":",
"record_key",
"=",
"key",
"[",
"1",
":",
"]",
"if",
"record_key",
":",
... | a helper method for parsing the column properties from the record schema | [
"a",
"helper",
"method",
"for",
"parsing",
"the",
"column",
"properties",
"from",
"the",
"record",
"schema"
] | [
"''' a helper method for parsing the column properties from the record schema '''",
"# construct column list"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _construct_columns | <not_specific> | def _construct_columns(self, column_map):
''' a helper method for constructing the column objects for a table object '''
from sqlalchemy import Column, String, Boolean, Integer, Float, Binary
column_args = []
for key, value in column_map.items():
recor... | a helper method for constructing the column objects for a table object | a helper method for constructing the column objects for a table object | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"column",
"objects",
"for",
"a",
"table",
"object"
] | def _construct_columns(self, column_map):
from sqlalchemy import Column, String, Boolean, Integer, Float, Binary
column_args = []
for key, value in column_map.items():
record_key = value[0]
datatype = value[1]
max_length = value[2]
if record_key =... | [
"def",
"_construct_columns",
"(",
"self",
",",
"column_map",
")",
":",
"from",
"sqlalchemy",
"import",
"Column",
",",
"String",
",",
"Boolean",
",",
"Integer",
",",
"Float",
",",
"Binary",
"column_args",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"... | a helper method for constructing the column objects for a table object | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"column",
"objects",
"for",
"a",
"table",
"object"
] | [
"''' a helper method for constructing the column objects for a table object '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "column_map",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "column_map",
"type": null,
"docstring": null,
"docstring_toke... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _reconstruct_record | <not_specific> | def _reconstruct_record(self, record_object):
''' a helper method for reconstructing record fields from record object '''
record_details = {}
current_details = record_details
for key, value in self.model.keyMap.items():
record_key = key[1:]
if re... | a helper method for reconstructing record fields from record object | a helper method for reconstructing record fields from record object | [
"a",
"helper",
"method",
"for",
"reconstructing",
"record",
"fields",
"from",
"record",
"object"
] | def _reconstruct_record(self, record_object):
record_details = {}
current_details = record_details
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
record_value = getattr(record_object, record_key, None)
if r... | [
"def",
"_reconstruct_record",
"(",
"self",
",",
"record_object",
")",
":",
"record_details",
"=",
"{",
"}",
"current_details",
"=",
"record_details",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap",
".",
"items",
"(",
")",
":",
"recor... | a helper method for reconstructing record fields from record object | [
"a",
"helper",
"method",
"for",
"reconstructing",
"record",
"fields",
"from",
"record",
"object"
] | [
"''' a helper method for reconstructing record fields from record object '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "record_object",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record_object",
"type": null,
"docstring": null,
"docstring_t... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _compare_columns | <not_specific> | def _compare_columns(self, new_columns, old_columns):
''' a helper method for generating differences between column properties '''
# print(new_columns)
# print(old_columns)
add_columns = {}
remove_columns = {}
rename_columns = {}
retype_... | a helper method for generating differences between column properties | a helper method for generating differences between column properties | [
"a",
"helper",
"method",
"for",
"generating",
"differences",
"between",
"column",
"properties"
] | def _compare_columns(self, new_columns, old_columns):
add_columns = {}
remove_columns = {}
rename_columns = {}
retype_columns = {}
resize_columns = {}
for key, value in new_columns.items():
if key not in old_columns.keys():
add_columns[key] = T... | [
"def",
"_compare_columns",
"(",
"self",
",",
"new_columns",
",",
"old_columns",
")",
":",
"add_columns",
"=",
"{",
"}",
"remove_columns",
"=",
"{",
"}",
"rename_columns",
"=",
"{",
"}",
"retype_columns",
"=",
"{",
"}",
"resize_columns",
"=",
"{",
"}",
"for... | a helper method for generating differences between column properties | [
"a",
"helper",
"method",
"for",
"generating",
"differences",
"between",
"column",
"properties"
] | [
"''' a helper method for generating differences between column properties '''",
"# print(new_columns)",
"# print(old_columns)"
] | [
{
"param": "self",
"type": null
},
{
"param": "new_columns",
"type": null
},
{
"param": "old_columns",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_columns",
"type": null,
"docstring": null,
"docstring_tok... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _construct_inserts | <not_specific> | def _construct_inserts(self, record, new_columns, rename_columns, retype_columns, resize_columns):
''' a helper method for constructing the insert kwargs for a record '''
insert_kwargs = {}
for key, value in new_columns.items():
# retrieve value for key (or from old key name)
... | a helper method for constructing the insert kwargs for a record | a helper method for constructing the insert kwargs for a record | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"insert",
"kwargs",
"for",
"a",
"record"
] | def _construct_inserts(self, record, new_columns, rename_columns, retype_columns, resize_columns):
insert_kwargs = {}
for key, value in new_columns.items():
if key in rename_columns.keys():
record_value = getattr(record, rename_columns[key], None)
else:
... | [
"def",
"_construct_inserts",
"(",
"self",
",",
"record",
",",
"new_columns",
",",
"rename_columns",
",",
"retype_columns",
",",
"resize_columns",
")",
":",
"insert_kwargs",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"new_columns",
".",
"items",
"(",
")... | a helper method for constructing the insert kwargs for a record | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"insert",
"kwargs",
"for",
"a",
"record"
] | [
"''' a helper method for constructing the insert kwargs for a record '''",
"# retrieve value for key (or from old key name)",
"# attempt to convert datatype",
"# attempt to resize string data "
] | [
{
"param": "self",
"type": null
},
{
"param": "record",
"type": null
},
{
"param": "new_columns",
"type": null
},
{
"param": "rename_columns",
"type": null
},
{
"param": "retype_columns",
"type": null
},
{
"param": "resize_columns",
"type": null
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record",
"type": null,
"docstring": null,
"docstring_tokens":... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _rebuild_table | <not_specific> | def _rebuild_table(self, new_name, old_name, new_columns, old_columns):
''' a helper method for rebuilding table (by renaming & migrating) '''
# verbosity
print('Rebuilding %s table in %s database' % (self.table_name, self.database_name), end='', flush=True)
from sqla... | a helper method for rebuilding table (by renaming & migrating) | a helper method for rebuilding table (by renaming & migrating) | [
"a",
"helper",
"method",
"for",
"rebuilding",
"table",
"(",
"by",
"renaming",
"&",
"migrating",
")"
] | def _rebuild_table(self, new_name, old_name, new_columns, old_columns):
print('Rebuilding %s table in %s database' % (self.table_name, self.database_name), end='', flush=True)
from sqlalchemy import Table, MetaData
metadata_object = MetaData()
old_table_args = [ old_name, metadata_objec... | [
"def",
"_rebuild_table",
"(",
"self",
",",
"new_name",
",",
"old_name",
",",
"new_columns",
",",
"old_columns",
")",
":",
"print",
"(",
"'Rebuilding %s table in %s database'",
"%",
"(",
"self",
".",
"table_name",
",",
"self",
".",
"database_name",
")",
",",
"e... | a helper method for rebuilding table (by renaming & migrating) | [
"a",
"helper",
"method",
"for",
"rebuilding",
"table",
"(",
"by",
"renaming",
"&",
"migrating",
")"
] | [
"''' a helper method for rebuilding table (by renaming & migrating) '''",
"# verbosity",
"# construct old table",
"# construct new table",
"# determine differences between tables",
"# rename table and recreate table if it doesn't already exist",
"# wait for renamed table to be responsive",
"# migrate ... | [
{
"param": "self",
"type": null
},
{
"param": "new_name",
"type": null
},
{
"param": "old_name",
"type": null
},
{
"param": "new_columns",
"type": null
},
{
"param": "old_columns",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_name",
"type": null,
"docstring": null,
"docstring_tokens... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | exists | <not_specific> | def exists(self, primary_key):
'''
a method to determine if record exists
:param primary_key: string with primary key of record
:return: boolean to indicate existence of record
'''
select_statement = self.table.select(self.table).where(... |
a method to determine if record exists
:param primary_key: string with primary key of record
:return: boolean to indicate existence of record
| a method to determine if record exists | [
"a",
"method",
"to",
"determine",
"if",
"record",
"exists"
] | def exists(self, primary_key):
select_statement = self.table.select(self.table).where(self.table.c.id==primary_key)
record_object = self.session.execute(select_statement).first()
if record_object:
return True
return False | [
"def",
"exists",
"(",
"self",
",",
"primary_key",
")",
":",
"select_statement",
"=",
"self",
".",
"table",
".",
"select",
"(",
"self",
".",
"table",
")",
".",
"where",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",
"primary_key",
")",
"record_... | a method to determine if record exists | [
"a",
"method",
"to",
"determine",
"if",
"record",
"exists"
] | [
"'''\n a method to determine if record exists\n \n :param primary_key: string with primary key of record \n :return: boolean to indicate existence of record\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "primary_key",
"type": null
}
] | {
"returns": [
{
"docstring": "boolean to indicate existence of record",
"docstring_tokens": [
"boolean",
"to",
"indicate",
"existence",
"of",
"record"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | list | null | def list(self, query_criteria=None, order_criteria=None):
'''
a generator method to list records in table which match query criteria
:param query_criteria: dictionary with schema dot-path field names and query qualifiers
:param order_criteria: list of single key... |
a generator method to list records in table which match query criteria
:param query_criteria: dictionary with schema dot-path field names and query qualifiers
:param order_criteria: list of single keypair dictionaries with field names to order by
:return: generator obj... | a generator method to list records in table which match query criteria | [
"a",
"generator",
"method",
"to",
"list",
"records",
"in",
"table",
"which",
"match",
"query",
"criteria"
] | def list(self, query_criteria=None, order_criteria=None):
title = '%s.list' % self.__class__.__name__
from sqlalchemy import desc as order_desc
if query_criteria:
self.model.query(query_criteria)
else:
query_criteria = {}
if order_criteria:
obj... | [
"def",
"list",
"(",
"self",
",",
"query_criteria",
"=",
"None",
",",
"order_criteria",
"=",
"None",
")",
":",
"title",
"=",
"'%s.list'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"from",
"sqlalchemy",
"import",
"desc",
"as",
"order_desc",
"if",
"quer... | a generator method to list records in table which match query criteria | [
"a",
"generator",
"method",
"to",
"list",
"records",
"in",
"table",
"which",
"match",
"query",
"criteria"
] | [
"'''\n a generator method to list records in table which match query criteria\n \n :param query_criteria: dictionary with schema dot-path field names and query qualifiers\n :param order_criteria: list of single keypair dictionaries with field names to order by \n :return: ... | [
{
"param": "self",
"type": null
},
{
"param": "query_criteria",
"type": null
},
{
"param": "order_criteria",
"type": null
}
] | {
"returns": [
{
"docstring": "generator object with string of primary key\nan example of how to construct the query_criteria argument.\n\n\n\nsql only supports a limited number of query conditions and all list\nfields in a record are stored as a blob. this method constructs a\nsql query which contains clau... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | create | <not_specific> | def create(self, record_details):
'''
a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, the... |
a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, then it will be used as the primary key. if the id
... | a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, then it will be used as the primary key. if the id
field is missing, a unique 24 character url safe string will be
created for th... | [
"a",
"method",
"to",
"create",
"a",
"new",
"record",
"in",
"the",
"table",
"NOTE",
":",
"this",
"class",
"uses",
"the",
"id",
"key",
"as",
"the",
"primary",
"key",
"for",
"all",
"records",
"if",
"record_details",
"includes",
"an",
"id",
"field",
"that",
... | def create(self, record_details):
record_details = self.model.validate(record_details)
create_kwargs = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.item_key.findall(record_key):
pass
... | [
"def",
"create",
"(",
"self",
",",
"record_details",
")",
":",
"record_details",
"=",
"self",
".",
"model",
".",
"validate",
"(",
"record_details",
")",
"create_kwargs",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap"... | a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, then it will be used as the primary key. | [
"a",
"method",
"to",
"create",
"a",
"new",
"record",
"in",
"the",
"table",
"NOTE",
":",
"this",
"class",
"uses",
"the",
"id",
"key",
"as",
"the",
"primary",
"key",
"for",
"all",
"records",
"if",
"record_details",
"includes",
"an",
"id",
"field",
"that",
... | [
"'''\n a method to create a new record in the table \n \n NOTE: this class uses the id key as the primary key for all records\n if record_details includes an id field that is an integer, float\n or string, then it will be used as the primary key. ... | [
{
"param": "self",
"type": null
},
{
"param": "record_details",
"type": null
}
] | {
"returns": [
{
"docstring": "string with primary key for record",
"docstring_tokens": [
"string",
"with",
"primary",
"key",
"for",
"record"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"ty... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | read | <not_specific> | def read(self, primary_key):
'''
a method to retrieve the details for a record in the table
:param primary_key: string with primary key of record
:return: dictionary with record fields
'''
title = '%s.read' % self.__class__.__name__
... |
a method to retrieve the details for a record in the table
:param primary_key: string with primary key of record
:return: dictionary with record fields
| a method to retrieve the details for a record in the table | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"a",
"record",
"in",
"the",
"table"
] | def read(self, primary_key):
title = '%s.read' % self.__class__.__name__
select_statement = self.table.select(self.table.c.id==primary_key)
record_object = self.session.execute(select_statement).first()
if not record_object:
raise ValueError('%s(primary_key=%s) does not exist... | [
"def",
"read",
"(",
"self",
",",
"primary_key",
")",
":",
"title",
"=",
"'%s.read'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"select_statement",
"=",
"self",
".",
"table",
".",
"select",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",
"... | a method to retrieve the details for a record in the table | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"a",
"record",
"in",
"the",
"table"
] | [
"''' \n a method to retrieve the details for a record in the table \n \n :param primary_key: string with primary key of record \n :return: dictionary with record fields \n '''",
"# retrieve record object",
"# record_object = self.session.query(self.record).filter_by(id... | [
{
"param": "self",
"type": null
},
{
"param": "primary_key",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with record fields",
"docstring_tokens": [
"dictionary",
"with",
"record",
"fields"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": nu... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | update | <not_specific> | def update(self, new_details, old_details=None):
''' a method to upsert changes to a record in the table
:param new_details: dictionary with updated record fields
:param old_details: [optional] dictionary with original record fields
:return: list of dictionaries with u... | a method to upsert changes to a record in the table
:param new_details: dictionary with updated record fields
:param old_details: [optional] dictionary with original record fields
:return: list of dictionaries with updated field details
NOTE: if old_details is empty... | a method to upsert changes to a record in the table | [
"a",
"method",
"to",
"upsert",
"changes",
"to",
"a",
"record",
"in",
"the",
"table"
] | def update(self, new_details, old_details=None):
title = '%s.update' % self.__class__.__name__
input_fields = {
'new_details': new_details,
'old_details': old_details
}
for key, value in input_fields.items():
if value:
object_title = '%... | [
"def",
"update",
"(",
"self",
",",
"new_details",
",",
"old_details",
"=",
"None",
")",
":",
"title",
"=",
"'%s.update'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'new_details'",
":",
"new_details",
",",
"'old_details'",
":"... | a method to upsert changes to a record in the table | [
"a",
"method",
"to",
"upsert",
"changes",
"to",
"a",
"record",
"in",
"the",
"table"
] | [
"''' a method to upsert changes to a record in the table\n \n :param new_details: dictionary with updated record fields\n :param old_details: [optional] dictionary with original record fields \n :return: list of dictionaries with updated field details\n \n NOTE: if old_de... | [
{
"param": "self",
"type": null
},
{
"param": "new_details",
"type": null
},
{
"param": "old_details",
"type": null
}
] | {
"returns": [
{
"docstring": "list of dictionaries with updated field details\nNOTE: if old_details is empty, method will poll database for the\nmost recent version of the record with which to compare the\nnew details for changes",
"docstring_tokens": [
"list",
"of",
"dictio... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | delete | <not_specific> | def delete(self, primary_key):
'''
a method to delete a record in the table
:param primary_key: string with primary key of record
:return: string with status message
'''
title = '%s.delete' % self.__class__.__name__
# delete obje... |
a method to delete a record in the table
:param primary_key: string with primary key of record
:return: string with status message
| a method to delete a record in the table | [
"a",
"method",
"to",
"delete",
"a",
"record",
"in",
"the",
"table"
] | def delete(self, primary_key):
title = '%s.delete' % self.__class__.__name__
delete_statement = self.table.delete(self.table.c.id==primary_key)
self.session.execute(delete_statement)
exit_msg = '%s has been deleted.' % primary_key
return exit_msg | [
"def",
"delete",
"(",
"self",
",",
"primary_key",
")",
":",
"title",
"=",
"'%s.delete'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"delete_statement",
"=",
"self",
".",
"table",
".",
"delete",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",... | a method to delete a record in the table | [
"a",
"method",
"to",
"delete",
"a",
"record",
"in",
"the",
"table"
] | [
"''' \n a method to delete a record in the table\n \n :param primary_key: string with primary key of record \n :return: string with status message\n '''",
"# delete object",
"# return message"
] | [
{
"param": "self",
"type": null
},
{
"param": "primary_key",
"type": null
}
] | {
"returns": [
{
"docstring": "string with status message",
"docstring_tokens": [
"string",
"with",
"status",
"message"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | remove | <not_specific> | def remove(self):
'''
a method to remove the entire table
:return string with status message
'''
self.table.drop(self.engine)
exit_msg = '%s table has been removed from %s database.' % (self.table_name, self.database_name)
... |
a method to remove the entire table
:return string with status message
| a method to remove the entire table
:return string with status message | [
"a",
"method",
"to",
"remove",
"the",
"entire",
"table",
":",
"return",
"string",
"with",
"status",
"message"
] | def remove(self):
self.table.drop(self.engine)
exit_msg = '%s table has been removed from %s database.' % (self.table_name, self.database_name)
self.printer(exit_msg)
return exit_msg | [
"def",
"remove",
"(",
"self",
")",
":",
"self",
".",
"table",
".",
"drop",
"(",
"self",
".",
"engine",
")",
"exit_msg",
"=",
"'%s table has been removed from %s database.'",
"%",
"(",
"self",
".",
"table_name",
",",
"self",
".",
"database_name",
")",
"self",... | a method to remove the entire table
:return string with status message | [
"a",
"method",
"to",
"remove",
"the",
"entire",
"table",
":",
"return",
"string",
"with",
"status",
"message"
] | [
"''' \n a method to remove the entire table \n \n :return string with status message \n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | export | <not_specific> | def export(self, sql_client, merge_rule='skip', coerce=False):
'''
a method to export all the records in table to another table
:param sql_client: class object with sql client methods
:param merge_rule: string with name of rule to adopt for pre-existing records
:param coerc... |
a method to export all the records in table to another table
:param sql_client: class object with sql client methods
:param merge_rule: string with name of rule to adopt for pre-existing records
:param coerce: boolean to enable migration even if table schemas don't match
:r... | a method to export all the records in table to another table | [
"a",
"method",
"to",
"export",
"all",
"the",
"records",
"in",
"table",
"to",
"another",
"table"
] | def export(self, sql_client, merge_rule='skip', coerce=False):
title = '%s.export' % self.__class__.__name__
method_list = [ 'list', 'create', 'read', 'update', 'delete', 'remove', 'export', 'exists', '_construct_inserts', '_parse_columns', '_compare_columns', 'table', 'session', 'table_name', 'database... | [
"def",
"export",
"(",
"self",
",",
"sql_client",
",",
"merge_rule",
"=",
"'skip'",
",",
"coerce",
"=",
"False",
")",
":",
"title",
"=",
"'%s.export'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"method_list",
"=",
"[",
"'list'",
",",
"'create'",
","... | a method to export all the records in table to another table | [
"a",
"method",
"to",
"export",
"all",
"the",
"records",
"in",
"table",
"to",
"another",
"table"
] | [
"'''\n a method to export all the records in table to another table\n\n :param sql_client: class object with sql client methods\n :param merge_rule: string with name of rule to adopt for pre-existing records\n :param coerce: boolean to enable migration even if table schemas don't mat... | [
{
"param": "self",
"type": null
},
{
"param": "sql_client",
"type": null
},
{
"param": "merge_rule",
"type": null
},
{
"param": "coerce",
"type": null
}
] | {
"returns": [
{
"docstring": "string with exit message\nNOTE: available merge rules include: overwrite, skip and upsert",
"docstring_tokens": [
"string",
"with",
"exit",
"message",
"NOTE",
":",
"available",
"merge",
"rules",
... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _extract_columns | <not_specific> | def _extract_columns(self, table_name):
''' a method to extract the column properties of an existing table '''
import re
from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA, BIGINT
# re... | a method to extract the column properties of an existing table | a method to extract the column properties of an existing table | [
"a",
"method",
"to",
"extract",
"the",
"column",
"properties",
"of",
"an",
"existing",
"table"
] | def _extract_columns(self, table_name):
import re
from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT
from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA, BIGINT
metadata_object = MetaData()
table_list = self.engine.table_names()
pr... | [
"def",
"_extract_columns",
"(",
"self",
",",
"table_name",
")",
":",
"import",
"re",
"from",
"sqlalchemy",
"import",
"MetaData",
",",
"VARCHAR",
",",
"INTEGER",
",",
"BLOB",
",",
"BOOLEAN",
",",
"FLOAT",
"from",
"sqlalchemy",
".",
"dialects",
".",
"postgresq... | a method to extract the column properties of an existing table | [
"a",
"method",
"to",
"extract",
"the",
"column",
"properties",
"of",
"an",
"existing",
"table"
] | [
"''' a method to extract the column properties of an existing table '''",
"# retrieve list of tables",
"# determine columns",
"# Postgres"
] | [
{
"param": "self",
"type": null
},
{
"param": "table_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table_name",
"type": null,
"docstring": null,
"docstring_toke... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _parse_columns | <not_specific> | def _parse_columns(self):
''' a helper method for parsing the column properties from the record schema '''
# construct column list
column_map = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.item_key.f... | a helper method for parsing the column properties from the record schema | a helper method for parsing the column properties from the record schema | [
"a",
"helper",
"method",
"for",
"parsing",
"the",
"column",
"properties",
"from",
"the",
"record",
"schema"
] | def _parse_columns(self):
column_map = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.item_key.findall(record_key):
pass
else:
if value['value_datatype'] == 'map' ... | [
"def",
"_parse_columns",
"(",
"self",
")",
":",
"column_map",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap",
".",
"items",
"(",
")",
":",
"record_key",
"=",
"key",
"[",
"1",
":",
"]",
"if",
"record_key",
":",
... | a helper method for parsing the column properties from the record schema | [
"a",
"helper",
"method",
"for",
"parsing",
"the",
"column",
"properties",
"from",
"the",
"record",
"schema"
] | [
"''' a helper method for parsing the column properties from the record schema '''",
"# construct column list",
"# label empty map fields as lists for column determinations"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _construct_columns | <not_specific> | def _construct_columns(self, column_map):
''' a helper method for constructing the column objects for a table object '''
from sqlalchemy import Column, String, Boolean, Integer, Float, Binary
column_args = []
for key, value in column_map.items():
record_key = value[0]
... | a helper method for constructing the column objects for a table object | a helper method for constructing the column objects for a table object | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"column",
"objects",
"for",
"a",
"table",
"object"
] | def _construct_columns(self, column_map):
from sqlalchemy import Column, String, Boolean, Integer, Float, Binary
column_args = []
for key, value in column_map.items():
record_key = value[0]
datatype = value[1]
max_length = value[2]
if record_key ==... | [
"def",
"_construct_columns",
"(",
"self",
",",
"column_map",
")",
":",
"from",
"sqlalchemy",
"import",
"Column",
",",
"String",
",",
"Boolean",
",",
"Integer",
",",
"Float",
",",
"Binary",
"column_args",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"... | a helper method for constructing the column objects for a table object | [
"a",
"helper",
"method",
"for",
"constructing",
"the",
"column",
"objects",
"for",
"a",
"table",
"object"
] | [
"''' a helper method for constructing the column objects for a table object '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "column_map",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "column_map",
"type": null,
"docstring": null,
"docstring_toke... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _prepare_record | <not_specific> | def _prepare_record(self, record_details):
''' a helper method for converting a record to column-based fields '''
# add fields to create request
fields = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.... | a helper method for converting a record to column-based fields | a helper method for converting a record to column-based fields | [
"a",
"helper",
"method",
"for",
"converting",
"a",
"record",
"to",
"column",
"-",
"based",
"fields"
] | def _prepare_record(self, record_details):
fields = {}
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
if self.item_key.findall(record_key):
pass
else:
if value['value_datatyp... | [
"def",
"_prepare_record",
"(",
"self",
",",
"record_details",
")",
":",
"fields",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap",
".",
"items",
"(",
")",
":",
"record_key",
"=",
"key",
"[",
"1",
":",
"]",
"if",... | a helper method for converting a record to column-based fields | [
"a",
"helper",
"method",
"for",
"converting",
"a",
"record",
"to",
"column",
"-",
"based",
"fields"
] | [
"''' a helper method for converting a record to column-based fields '''",
"# add fields to create request",
"# add id field if missing",
"# TODO auto increment record",
"# sqlite and postgres do not support > 64-bit integers",
"# produce a non-colliding integer derived from uuid"
] | [
{
"param": "self",
"type": null
},
{
"param": "record_details",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record_details",
"type": null,
"docstring": null,
"docstring_... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _reconstruct_record | <not_specific> | def _reconstruct_record(self, record_object):
''' a helper method for reconstructing record fields from record object '''
record_details = {}
current_details = record_details
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
... | a helper method for reconstructing record fields from record object | a helper method for reconstructing record fields from record object | [
"a",
"helper",
"method",
"for",
"reconstructing",
"record",
"fields",
"from",
"record",
"object"
] | def _reconstruct_record(self, record_object):
record_details = {}
current_details = record_details
for key, value in self.model.keyMap.items():
record_key = key[1:]
if record_key:
record_value = getattr(record_object, record_key, None)
if r... | [
"def",
"_reconstruct_record",
"(",
"self",
",",
"record_object",
")",
":",
"record_details",
"=",
"{",
"}",
"current_details",
"=",
"record_details",
"for",
"key",
",",
"value",
"in",
"self",
".",
"model",
".",
"keyMap",
".",
"items",
"(",
")",
":",
"recor... | a helper method for reconstructing record fields from record object | [
"a",
"helper",
"method",
"for",
"reconstructing",
"record",
"fields",
"from",
"record",
"object"
] | [
"''' a helper method for reconstructing record fields from record object '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "record_object",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "record_object",
"type": null,
"docstring": null,
"docstring_t... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | _rebuild_table | <not_specific> | def _rebuild_table(self, new_name, old_name, new_columns, old_columns):
''' a helper method for rebuilding table (by renaming & migrating) '''
# verbosity
self.printer('Rebuilding %s table in %s database' % (self.table_name, self.database_name), flush=True)
from sqlalchemy import Tabl... | a helper method for rebuilding table (by renaming & migrating) | a helper method for rebuilding table (by renaming & migrating) | [
"a",
"helper",
"method",
"for",
"rebuilding",
"table",
"(",
"by",
"renaming",
"&",
"migrating",
")"
] | def _rebuild_table(self, new_name, old_name, new_columns, old_columns):
self.printer('Rebuilding %s table in %s database' % (self.table_name, self.database_name), flush=True)
from sqlalchemy import Table, MetaData
metadata_object = MetaData()
old_table_args = [old_name, metadata_object]
... | [
"def",
"_rebuild_table",
"(",
"self",
",",
"new_name",
",",
"old_name",
",",
"new_columns",
",",
"old_columns",
")",
":",
"self",
".",
"printer",
"(",
"'Rebuilding %s table in %s database'",
"%",
"(",
"self",
".",
"table_name",
",",
"self",
".",
"database_name",... | a helper method for rebuilding table (by renaming & migrating) | [
"a",
"helper",
"method",
"for",
"rebuilding",
"table",
"(",
"by",
"renaming",
"&",
"migrating",
")"
] | [
"''' a helper method for rebuilding table (by renaming & migrating) '''",
"# verbosity",
"# construct old table",
"# construct new table",
"# determine differences between tables",
"# rename table and recreate table if it doesn't already exist",
"# wait for renamed table to be responsive",
"# migrate ... | [
{
"param": "self",
"type": null
},
{
"param": "new_name",
"type": null
},
{
"param": "old_name",
"type": null
},
{
"param": "new_columns",
"type": null
},
{
"param": "old_columns",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_name",
"type": null,
"docstring": null,
"docstring_tokens... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | exists | <not_specific> | def exists(self, record_id):
'''
a method to determine if record exists
:param record_id: string or number with unique identifier of record
:return: boolean to indicate existence of record
'''
select_statement = self.table.select(self.table).where(self.table.c.id =... |
a method to determine if record exists
:param record_id: string or number with unique identifier of record
:return: boolean to indicate existence of record
| a method to determine if record exists | [
"a",
"method",
"to",
"determine",
"if",
"record",
"exists"
] | def exists(self, record_id):
select_statement = self.table.select(self.table).where(self.table.c.id == record_id)
record_object = self.session.execute(select_statement).first()
if record_object:
return True
return False | [
"def",
"exists",
"(",
"self",
",",
"record_id",
")",
":",
"select_statement",
"=",
"self",
".",
"table",
".",
"select",
"(",
"self",
".",
"table",
")",
".",
"where",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",
"record_id",
")",
"record_obje... | a method to determine if record exists | [
"a",
"method",
"to",
"determine",
"if",
"record",
"exists"
] | [
"'''\n a method to determine if record exists\n\n :param record_id: string or number with unique identifier of record\n :return: boolean to indicate existence of record\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "record_id",
"type": null
}
] | {
"returns": [
{
"docstring": "boolean to indicate existence of record",
"docstring_tokens": [
"boolean",
"to",
"indicate",
"existence",
"of",
"record"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | list | <not_specific> | def list(self, filter=None, sort=None, limit=100, cursor=None, ids_only=False):
'''
a method to retrieve records from table which match query criteria
:param filter: dictionary of dot path field name and jsonmodel query criteria
:param sort: list of single key-pair dictionaries wit... |
a method to retrieve records from table which match query criteria
:param filter: dictionary of dot path field name and jsonmodel query criteria
:param sort: list of single key-pair dictionaries with dot path field names
:param limit: integer with number of results to return
... | a method to retrieve records from table which match query criteria | [
"a",
"method",
"to",
"retrieve",
"records",
"from",
"table",
"which",
"match",
"query",
"criteria"
] | def list(self, filter=None, sort=None, limit=100, cursor=None, ids_only=False):
from sqlalchemy import desc as order_desc
title = '%s.list' % self.__class__.__name__
args = {
'filter': filter,
'sort': sort,
'limit': limit
}
for key, value in ar... | [
"def",
"list",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"limit",
"=",
"100",
",",
"cursor",
"=",
"None",
",",
"ids_only",
"=",
"False",
")",
":",
"from",
"sqlalchemy",
"import",
"desc",
"as",
"order_desc",
"title",
"=",... | a method to retrieve records from table which match query criteria | [
"a",
"method",
"to",
"retrieve",
"records",
"from",
"table",
"which",
"match",
"query",
"criteria"
] | [
"'''\n a method to retrieve records from table which match query criteria\n\n :param filter: dictionary of dot path field name and jsonmodel query criteria\n :param sort: list of single key-pair dictionaries with dot path field names\n :param limit: integer with number of results to ... | [
{
"param": "self",
"type": null
},
{
"param": "filter",
"type": null
},
{
"param": "sort",
"type": null
},
{
"param": "limit",
"type": null
},
{
"param": "cursor",
"type": null
},
{
"param": "ids_only",
"type": null
}
] | {
"returns": [
{
"docstring": "list of results\nfilter:\n{\n'path.to.field': 'equal to value',\n'path.to.number': {\n'min_value': 4.5\n},\n'path.to.string': {\n'discrete_values': [ 'pond', 'lake', 'stream', 'brook' ]\n}\n}\n\nsql only supports a limited number of query conditions and all list\nfields in a r... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | create | <not_specific> | def create(self, record):
'''
a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record includes an id field that is an integer, float
or string, then it will be used as the prim... |
a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record includes an id field that is an integer, float
or string, then it will be used as the primary key. if the id
... | a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record includes an id field that is an integer, float
or string, then it will be used as the primary key. if the id
field is missing, a random 64 bit integer (if a number) or a
unique 24 character url s... | [
"a",
"method",
"to",
"create",
"a",
"new",
"record",
"in",
"the",
"table",
"NOTE",
":",
"this",
"class",
"uses",
"the",
"id",
"key",
"as",
"the",
"primary",
"key",
"for",
"all",
"records",
"if",
"record",
"includes",
"an",
"id",
"field",
"that",
"is",
... | def create(self, record):
record_details = self.model.validate(record)
fields = self._prepare_record(record_details)
insert_statement = self.table.insert().values(**fields)
self.session.execute(insert_statement)
self.printer('Record %s created.' % fields['id'])
return fie... | [
"def",
"create",
"(",
"self",
",",
"record",
")",
":",
"record_details",
"=",
"self",
".",
"model",
".",
"validate",
"(",
"record",
")",
"fields",
"=",
"self",
".",
"_prepare_record",
"(",
"record_details",
")",
"insert_statement",
"=",
"self",
".",
"table... | a method to create a new record in the table
NOTE: this class uses the id key as the primary key for all records
if record includes an id field that is an integer, float
or string, then it will be used as the primary key. | [
"a",
"method",
"to",
"create",
"a",
"new",
"record",
"in",
"the",
"table",
"NOTE",
":",
"this",
"class",
"uses",
"the",
"id",
"key",
"as",
"the",
"primary",
"key",
"for",
"all",
"records",
"if",
"record",
"includes",
"an",
"id",
"field",
"that",
"is",
... | [
"'''\n a method to create a new record in the table \n\n NOTE: this class uses the id key as the primary key for all records\n if record includes an id field that is an integer, float\n or string, then it will be used as the primary key. if the id\n ... | [
{
"param": "self",
"type": null
},
{
"param": "record",
"type": null
}
] | {
"returns": [
{
"docstring": "string with id for record",
"docstring_tokens": [
"string",
"with",
"id",
"for",
"record"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring":... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | read | <not_specific> | def read(self, record_id):
'''
a method to retrieve the details for a record in the table
:param record_id: string or number with unique identifier of record
:return: dictionary with record fields
'''
title = '%s.read' % self.__class__.__name__
# retrie... |
a method to retrieve the details for a record in the table
:param record_id: string or number with unique identifier of record
:return: dictionary with record fields
| a method to retrieve the details for a record in the table | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"a",
"record",
"in",
"the",
"table"
] | def read(self, record_id):
title = '%s.read' % self.__class__.__name__
select_statement = self.table.select(self.table.c.id == record_id)
record_object = self.session.execute(select_statement).first()
if not record_object:
return {}
record_details = self._reconstruct_... | [
"def",
"read",
"(",
"self",
",",
"record_id",
")",
":",
"title",
"=",
"'%s.read'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"select_statement",
"=",
"self",
".",
"table",
".",
"select",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",
"re... | a method to retrieve the details for a record in the table | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"a",
"record",
"in",
"the",
"table"
] | [
"''' \n a method to retrieve the details for a record in the table \n\n :param record_id: string or number with unique identifier of record\n :return: dictionary with record fields \n '''",
"# retrieve record object",
"# record_object = self.session.query(self.record).filter_by(i... | [
{
"param": "self",
"type": null
},
{
"param": "record_id",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with record fields",
"docstring_tokens": [
"dictionary",
"with",
"record",
"fields"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": nu... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | update | <not_specific> | def update(self, updated, original=None):
''' a method to update changes to a record in the table
:param updated: dictionary with updated record fields
:param original: [optional] dictionary with original record fields
:return: list of dictionaries with updated field details
... | a method to update changes to a record in the table
:param updated: dictionary with updated record fields
:param original: [optional] dictionary with original record fields
:return: list of dictionaries with updated field details
NOTE: if original is empty, method will poll databas... | a method to update changes to a record in the table | [
"a",
"method",
"to",
"update",
"changes",
"to",
"a",
"record",
"in",
"the",
"table"
] | def update(self, updated, original=None):
title = '%s.update' % self.__class__.__name__
input_fields = {
'updated': updated,
'original': original
}
for key, value in input_fields.items():
if value:
object_title = '%s(%s=%s)' % (title, k... | [
"def",
"update",
"(",
"self",
",",
"updated",
",",
"original",
"=",
"None",
")",
":",
"title",
"=",
"'%s.update'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'updated'",
":",
"updated",
",",
"'original'",
":",
"original",
... | a method to update changes to a record in the table | [
"a",
"method",
"to",
"update",
"changes",
"to",
"a",
"record",
"in",
"the",
"table"
] | [
"''' a method to update changes to a record in the table\n\n :param updated: dictionary with updated record fields\n :param original: [optional] dictionary with original record fields \n :return: list of dictionaries with updated field details\n\n NOTE: if original is empty, method wil... | [
{
"param": "self",
"type": null
},
{
"param": "updated",
"type": null
},
{
"param": "original",
"type": null
}
] | {
"returns": [
{
"docstring": "list of dictionaries with updated field details\nNOTE: if original is empty, method will poll database for the\nmost recent version of the record with which to compare the\nnew details for changes",
"docstring_tokens": [
"list",
"of",
"dictionar... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | delete | <not_specific> | def delete(self, record_id):
'''
a method to delete a record in the table
:param record_id: string or number with unique identifier of record
:return: string with status message
'''
title = '%s.delete' % self.__class__.__name__
# delete object
del... |
a method to delete a record in the table
:param record_id: string or number with unique identifier of record
:return: string with status message
| a method to delete a record in the table | [
"a",
"method",
"to",
"delete",
"a",
"record",
"in",
"the",
"table"
] | def delete(self, record_id):
title = '%s.delete' % self.__class__.__name__
delete_statement = self.table.delete(self.table.c.id == record_id)
self.session.execute(delete_statement)
msg = 'Record %s deleted.' % record_id
self.printer(msg)
return msg | [
"def",
"delete",
"(",
"self",
",",
"record_id",
")",
":",
"title",
"=",
"'%s.delete'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"delete_statement",
"=",
"self",
".",
"table",
".",
"delete",
"(",
"self",
".",
"table",
".",
"c",
".",
"id",
"==",
... | a method to delete a record in the table | [
"a",
"method",
"to",
"delete",
"a",
"record",
"in",
"the",
"table"
] | [
"''' \n a method to delete a record in the table\n\n :param record_id: string or number with unique identifier of record\n :return: string with status message\n '''",
"# delete object",
"# return message"
] | [
{
"param": "self",
"type": null
},
{
"param": "record_id",
"type": null
}
] | {
"returns": [
{
"docstring": "string with status message",
"docstring_tokens": [
"string",
"with",
"status",
"message"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
c1c837c4a35a91dff91c284f1c4800f73c8aaa6b | collectiveacuity/labPack | labpack/databases/sql.py | [
"MIT"
] | Python | export | <not_specific> | def export(self, sql_table, merge_rule='skip', coerce=False):
'''
a method to export all the records in table to another sql table
:param sql_table: class object with sql table methods
:param merge_rule: string with name of rule to adopt for pre-existing records
:param coer... |
a method to export all the records in table to another sql table
:param sql_table: class object with sql table methods
:param merge_rule: string with name of rule to adopt for pre-existing records
:param coerce: boolean to enable migration even if table schemas don't match
... | a method to export all the records in table to another sql table | [
"a",
"method",
"to",
"export",
"all",
"the",
"records",
"in",
"table",
"to",
"another",
"sql",
"table"
] | def export(self, sql_table, merge_rule='skip', coerce=False):
title = '%s.export' % self.__class__.__name__
method_list = ['list', 'create', 'read', 'update', 'delete', 'remove', 'export', 'exists', '_construct_inserts', '_parse_columns', '_compare_columns', 'table', 'session', 'table_name', 'database_n... | [
"def",
"export",
"(",
"self",
",",
"sql_table",
",",
"merge_rule",
"=",
"'skip'",
",",
"coerce",
"=",
"False",
")",
":",
"title",
"=",
"'%s.export'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"method_list",
"=",
"[",
"'list'",
",",
"'create'",
",",... | a method to export all the records in table to another sql table | [
"a",
"method",
"to",
"export",
"all",
"the",
"records",
"in",
"table",
"to",
"another",
"sql",
"table"
] | [
"'''\n a method to export all the records in table to another sql table\n\n :param sql_table: class object with sql table methods\n :param merge_rule: string with name of rule to adopt for pre-existing records\n :param coerce: boolean to enable migration even if table schemas don't m... | [
{
"param": "self",
"type": null
},
{
"param": "sql_table",
"type": null
},
{
"param": "merge_rule",
"type": null
},
{
"param": "coerce",
"type": null
}
] | {
"returns": [
{
"docstring": "string with exit message\nNOTE: available merge rules include: overwrite, skip and upsert",
"docstring_tokens": [
"string",
"with",
"exit",
"message",
"NOTE",
":",
"available",
"merge",
"rules",
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _validate_install | <not_specific> | def _validate_install(self):
''' a method to validate docker is installed '''
from subprocess import check_output, STDOUT
sys_command = 'docker --help'
try:
check_output(sys_command, shell=True, stderr=STDOUT).decode('utf-8')
# call(sys_command, stdout=o... | a method to validate docker is installed | a method to validate docker is installed | [
"a",
"method",
"to",
"validate",
"docker",
"is",
"installed"
] | def _validate_install(self):
from subprocess import check_output, STDOUT
sys_command = 'docker --help'
try:
check_output(sys_command, shell=True, stderr=STDOUT).decode('utf-8')
except Exception as err:
raise Exception('"docker" not installed. GoTo: https://www.doc... | [
"def",
"_validate_install",
"(",
"self",
")",
":",
"from",
"subprocess",
"import",
"check_output",
",",
"STDOUT",
"sys_command",
"=",
"'docker --help'",
"try",
":",
"check_output",
"(",
"sys_command",
",",
"shell",
"=",
"True",
",",
"stderr",
"=",
"STDOUT",
")... | a method to validate docker is installed | [
"a",
"method",
"to",
"validate",
"docker",
"is",
"installed"
] | [
"''' a method to validate docker is installed '''",
"# call(sys_command, stdout=open(devnull, 'wb'))\r"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _validate_virtualbox | <not_specific> | def _validate_virtualbox(self):
'''
a method to validate that virtualbox is running on Win 7/8 machines
:return: boolean indicating whether virtualbox is running
'''
# validate operating system
if self.localhost.os.sysname != 'Windows':
return Fal... |
a method to validate that virtualbox is running on Win 7/8 machines
:return: boolean indicating whether virtualbox is running
| a method to validate that virtualbox is running on Win 7/8 machines | [
"a",
"method",
"to",
"validate",
"that",
"virtualbox",
"is",
"running",
"on",
"Win",
"7",
"/",
"8",
"machines"
] | def _validate_virtualbox(self):
if self.localhost.os.sysname != 'Windows':
return False
win_release = float(self.localhost.os.release)
if win_release >= 10.0:
return False
from os import devnull
from subprocess import call, check_output, STDOUT
sys... | [
"def",
"_validate_virtualbox",
"(",
"self",
")",
":",
"if",
"self",
".",
"localhost",
".",
"os",
".",
"sysname",
"!=",
"'Windows'",
":",
"return",
"False",
"win_release",
"=",
"float",
"(",
"self",
".",
"localhost",
".",
"os",
".",
"release",
")",
"if",
... | a method to validate that virtualbox is running on Win 7/8 machines | [
"a",
"method",
"to",
"validate",
"that",
"virtualbox",
"is",
"running",
"on",
"Win",
"7",
"/",
"8",
"machines"
] | [
"'''\r\n a method to validate that virtualbox is running on Win 7/8 machines\r\n\r\n :return: boolean indicating whether virtualbox is running\r\n '''",
"# validate operating system\r",
"# validate docker-machine installation\r",
"# validate virtualbox is running\r"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "boolean indicating whether virtualbox is running",
"docstring_tokens": [
"boolean",
"indicating",
"whether",
"virtualbox",
"is",
"running"
],
"type": null
}
],
"raises": [],
"params": [
{
"id... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _set_virtualbox | <not_specific> | def _set_virtualbox(self):
'''
a method to set virtualbox environment variables for docker-machine
:return: True
'''
from os import environ
if not environ.get('DOCKER_CERT_PATH'):
import re
sys_command = 'docke... |
a method to set virtualbox environment variables for docker-machine
:return: True
| a method to set virtualbox environment variables for docker-machine | [
"a",
"method",
"to",
"set",
"virtualbox",
"environment",
"variables",
"for",
"docker",
"-",
"machine"
] | def _set_virtualbox(self):
from os import environ
if not environ.get('DOCKER_CERT_PATH'):
import re
sys_command = 'docker-machine env %s' % self.vbox
cmd_output = self.command(sys_command)
variable_list = ['DOCKER_TLS_VERIFY', 'DOCKER_HOST', 'DOCKER_CERT_P... | [
"def",
"_set_virtualbox",
"(",
"self",
")",
":",
"from",
"os",
"import",
"environ",
"if",
"not",
"environ",
".",
"get",
"(",
"'DOCKER_CERT_PATH'",
")",
":",
"import",
"re",
"sys_command",
"=",
"'docker-machine env %s'",
"%",
"self",
".",
"vbox",
"cmd_output",
... | a method to set virtualbox environment variables for docker-machine | [
"a",
"method",
"to",
"set",
"virtualbox",
"environment",
"variables",
"for",
"docker",
"-",
"machine"
] | [
"'''\r\n a method to set virtualbox environment variables for docker-machine\r\n \r\n :return: True\r\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _images | <not_specific> | def _images(self, sys_output):
''' a helper method for parsing docker image output '''
import re
gap_pattern = re.compile('\t|\s{2,}')
image_list = []
output_lines = sys_output.split('\n')
column_headers = gap_pattern.split(output_lines[0])
for i in... | a helper method for parsing docker image output | a helper method for parsing docker image output | [
"a",
"helper",
"method",
"for",
"parsing",
"docker",
"image",
"output"
] | def _images(self, sys_output):
import re
gap_pattern = re.compile('\t|\s{2,}')
image_list = []
output_lines = sys_output.split('\n')
column_headers = gap_pattern.split(output_lines[0])
for i in range(1,len(output_lines)):
columns = gap_pattern.split(output_lin... | [
"def",
"_images",
"(",
"self",
",",
"sys_output",
")",
":",
"import",
"re",
"gap_pattern",
"=",
"re",
".",
"compile",
"(",
"'\\t|\\s{2,}'",
")",
"image_list",
"=",
"[",
"]",
"output_lines",
"=",
"sys_output",
".",
"split",
"(",
"'\\n'",
")",
"column_header... | a helper method for parsing docker image output | [
"a",
"helper",
"method",
"for",
"parsing",
"docker",
"image",
"output"
] | [
"''' a helper method for parsing docker image output '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "sys_output",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sys_output",
"type": null,
"docstring": null,
"docstring_toke... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _ps | <not_specific> | def _ps(self, sys_output):
''' a helper method for parsing docker ps output '''
import re
gap_pattern = re.compile('\t|\s{2,}')
container_list = []
output_lines = sys_output.split('\n')
column_headers = gap_pattern.split(output_lines[0])
... | a helper method for parsing docker ps output | a helper method for parsing docker ps output | [
"a",
"helper",
"method",
"for",
"parsing",
"docker",
"ps",
"output"
] | def _ps(self, sys_output):
import re
gap_pattern = re.compile('\t|\s{2,}')
container_list = []
output_lines = sys_output.split('\n')
column_headers = gap_pattern.split(output_lines[0])
for i in range(1,len(output_lines)):
columns = gap_pattern.split(output_lin... | [
"def",
"_ps",
"(",
"self",
",",
"sys_output",
")",
":",
"import",
"re",
"gap_pattern",
"=",
"re",
".",
"compile",
"(",
"'\\t|\\s{2,}'",
")",
"container_list",
"=",
"[",
"]",
"output_lines",
"=",
"sys_output",
".",
"split",
"(",
"'\\n'",
")",
"column_header... | a helper method for parsing docker ps output | [
"a",
"helper",
"method",
"for",
"parsing",
"docker",
"ps",
"output"
] | [
"''' a helper method for parsing docker ps output '''",
"# stupid hack for possible empty port column\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "sys_output",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sys_output",
"type": null,
"docstring": null,
"docstring_toke... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | _synopsis | <not_specific> | def _synopsis(self, container_settings, container_status=''):
''' a helper method for summarizing container settings '''
# compose default response
settings = {
'container_status': container_settings['State']['Status'],
'container_exit': container_settings['State... | a helper method for summarizing container settings | a helper method for summarizing container settings | [
"a",
"helper",
"method",
"for",
"summarizing",
"container",
"settings"
] | def _synopsis(self, container_settings, container_status=''):
settings = {
'container_status': container_settings['State']['Status'],
'container_exit': container_settings['State']['ExitCode'],
'container_ip': container_settings['NetworkSettings']['IPAddress'],
'im... | [
"def",
"_synopsis",
"(",
"self",
",",
"container_settings",
",",
"container_status",
"=",
"''",
")",
":",
"settings",
"=",
"{",
"'container_status'",
":",
"container_settings",
"[",
"'State'",
"]",
"[",
"'Status'",
"]",
",",
"'container_exit'",
":",
"container_s... | a helper method for summarizing container settings | [
"a",
"helper",
"method",
"for",
"summarizing",
"container",
"settings"
] | [
"''' a helper method for summarizing container settings '''",
"# compose default response\r",
"# parse fields nested in container settings\r",
"# determine stopped status\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "container_settings",
"type": null
},
{
"param": "container_status",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "container_settings",
"type": null,
"docstring": null,
"docstr... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | images | <not_specific> | def images(self):
'''
a method to list the local docker images
:return: list of dictionaries with available image fields
[ {
'CREATED': '7 days ago',
'TAG': 'latest',
'IMAGE ID': '2298fbaac143',
'VIRTUAL SIZE':... |
a method to list the local docker images
:return: list of dictionaries with available image fields
[ {
'CREATED': '7 days ago',
'TAG': 'latest',
'IMAGE ID': '2298fbaac143',
'VIRTUAL SIZE': '302.7 MB',
'REPOS... | a method to list the local docker images | [
"a",
"method",
"to",
"list",
"the",
"local",
"docker",
"images"
] | def images(self):
sys_command = 'docker images'
sys_output = self.command(sys_command)
image_list = self._images(sys_output)
return image_list | [
"def",
"images",
"(",
"self",
")",
":",
"sys_command",
"=",
"'docker images'",
"sys_output",
"=",
"self",
".",
"command",
"(",
"sys_command",
")",
"image_list",
"=",
"self",
".",
"_images",
"(",
"sys_output",
")",
"return",
"image_list"
] | a method to list the local docker images | [
"a",
"method",
"to",
"list",
"the",
"local",
"docker",
"images"
] | [
"'''\r\n a method to list the local docker images\r\n \r\n :return: list of dictionaries with available image fields\r\n\r\n [ {\r\n 'CREATED': '7 days ago',\r\n 'TAG': 'latest',\r\n 'IMAGE ID': '2298fbaac143',\r\n 'VIRTUAL SIZE': '302.... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "list of dictionaries with available image fields\n[ {\n'CREATED': '7 days ago',\n'TAG': 'latest',\n'IMAGE ID': '2298fbaac143',\n'VIRTUAL SIZE': '302.7 MB',\n'REPOSITORY': 'test1'\n} ]",
"docstring_tokens": [
"list",
"of",
"dictionaries",
"... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | ps | <not_specific> | def ps(self):
'''
a method to list the local active docker containers
:return: list of dictionaries with active container fields
[{
'CREATED': '6 minutes ago',
'NAMES': 'flask',
'PORTS': '0.0.0.0:5000->5000/tcp',
... |
a method to list the local active docker containers
:return: list of dictionaries with active container fields
[{
'CREATED': '6 minutes ago',
'NAMES': 'flask',
'PORTS': '0.0.0.0:5000->5000/tcp',
'CONTAINER ID': '38eb0bb... | a method to list the local active docker containers | [
"a",
"method",
"to",
"list",
"the",
"local",
"active",
"docker",
"containers"
] | def ps(self):
sys_command = 'docker ps -a'
sys_output = self.command(sys_command)
container_list = self._ps(sys_output)
return container_list | [
"def",
"ps",
"(",
"self",
")",
":",
"sys_command",
"=",
"'docker ps -a'",
"sys_output",
"=",
"self",
".",
"command",
"(",
"sys_command",
")",
"container_list",
"=",
"self",
".",
"_ps",
"(",
"sys_output",
")",
"return",
"container_list"
] | a method to list the local active docker containers | [
"a",
"method",
"to",
"list",
"the",
"local",
"active",
"docker",
"containers"
] | [
"'''\r\n a method to list the local active docker containers \r\n \r\n :return: list of dictionaries with active container fields\r\n\r\n [{\r\n 'CREATED': '6 minutes ago',\r\n 'NAMES': 'flask',\r\n 'PORTS': '0.0.0.0:5000->5000/tcp',\r\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "list of dictionaries with active container fields\n[{\n'CREATED': '6 minutes ago',\n'NAMES': 'flask',\n'PORTS': '0.0.0.0:5000->5000/tcp',\n'CONTAINER ID': '38eb0bbeb2e5',\n'STATUS': 'Up 6 minutes',\n'COMMAND': '\"gunicorn --chdir ser\"',\n'IMAGE': 'rc42/flaskserver'\n}]",
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | network_ls | <not_specific> | def network_ls(self):
'''
a method to list the available networks
:return: list of dictionaries with docker network fields
[{
'NETWORK ID': '3007476acfe5',
'NAME': 'bridge',
'DRIVER': 'bridge',
'SCOPE':... |
a method to list the available networks
:return: list of dictionaries with docker network fields
[{
'NETWORK ID': '3007476acfe5',
'NAME': 'bridge',
'DRIVER': 'bridge',
'SCOPE': 'local'
}]
| a method to list the available networks | [
"a",
"method",
"to",
"list",
"the",
"available",
"networks"
] | def network_ls(self):
import re
gap_pattern = re.compile('\t|\s{2,}')
network_list = []
sys_command = 'docker network ls'
output_lines = self.command(sys_command).split('\n')
column_headers = gap_pattern.split(output_lines[0])
for i in range(1,len(output_lines)):
... | [
"def",
"network_ls",
"(",
"self",
")",
":",
"import",
"re",
"gap_pattern",
"=",
"re",
".",
"compile",
"(",
"'\\t|\\s{2,}'",
")",
"network_list",
"=",
"[",
"]",
"sys_command",
"=",
"'docker network ls'",
"output_lines",
"=",
"self",
".",
"command",
"(",
"sys_... | a method to list the available networks | [
"a",
"method",
"to",
"list",
"the",
"available",
"networks"
] | [
"'''\r\n a method to list the available networks\r\n \r\n :return: list of dictionaries with docker network fields\r\n\r\n [{\r\n 'NETWORK ID': '3007476acfe5',\r\n 'NAME': 'bridge',\r\n 'DRIVER': 'bridge',\r\n 'SCOPE': 'local'\r\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "list of dictionaries with docker network fields\n[{\n'NETWORK ID': '3007476acfe5',\n'NAME': 'bridge',\n'DRIVER': 'bridge',\n'SCOPE': 'local'\n}]",
"docstring_tokens": [
"list",
"of",
"dictionaries",
"with",
"docker",
"netwo... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | inspect_container | <not_specific> | def inspect_container(self, container_alias):
'''
a method to retrieve the settings of a container
:param container_alias: string with name or id of container
:return: dictionary of settings of container
{ TOO MANY TO LIST }
'''
titl... |
a method to retrieve the settings of a container
:param container_alias: string with name or id of container
:return: dictionary of settings of container
{ TOO MANY TO LIST }
| a method to retrieve the settings of a container | [
"a",
"method",
"to",
"retrieve",
"the",
"settings",
"of",
"a",
"container"
] | def inspect_container(self, container_alias):
title = '%s.inspect_container' % self.__class__.__name__
input_fields = {
'container_alias': container_alias
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
s... | [
"def",
"inspect_container",
"(",
"self",
",",
"container_alias",
")",
":",
"title",
"=",
"'%s.inspect_container'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'container_alias'",
":",
"container_alias",
"}",
"for",
"key",
",",
"val... | a method to retrieve the settings of a container | [
"a",
"method",
"to",
"retrieve",
"the",
"settings",
"of",
"a",
"container"
] | [
"'''\r\n a method to retrieve the settings of a container\r\n \r\n :param container_alias: string with name or id of container\r\n :return: dictionary of settings of container\r\n\r\n { TOO MANY TO LIST }\r\n '''",
"# validate inputs\r",
"# send inspect command\... | [
{
"param": "self",
"type": null
},
{
"param": "container_alias",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | inspect_image | <not_specific> | def inspect_image(self, image_name, image_tag=''):
'''
a method to retrieve the settings of an image
:param image_name: string with name or id of image
:param image_tag: [optional] string with tag associated with image
:return: dictionary of settings of imag... |
a method to retrieve the settings of an image
:param image_name: string with name or id of image
:param image_tag: [optional] string with tag associated with image
:return: dictionary of settings of image
{ TOO MANY TO LIST }
| a method to retrieve the settings of an image | [
"a",
"method",
"to",
"retrieve",
"the",
"settings",
"of",
"an",
"image"
] | def inspect_image(self, image_name, image_tag=''):
title = '%s.inspect_image' % self.__class__.__name__
input_fields = {
'image_name': image_name,
'image_tag': image_tag
}
for key, value in input_fields.items():
if value:
object_title =... | [
"def",
"inspect_image",
"(",
"self",
",",
"image_name",
",",
"image_tag",
"=",
"''",
")",
":",
"title",
"=",
"'%s.inspect_image'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'image_name'",
":",
"image_name",
",",
"'image_tag'",
... | a method to retrieve the settings of an image | [
"a",
"method",
"to",
"retrieve",
"the",
"settings",
"of",
"an",
"image"
] | [
"'''\r\n a method to retrieve the settings of an image\r\n\r\n :param image_name: string with name or id of image\r\n :param image_tag: [optional] string with tag associated with image \r\n :return: dictionary of settings of image\r\n\r\n { TOO MANY TO LIST }\r\n '''",
... | [
{
"param": "self",
"type": null
},
{
"param": "image_name",
"type": null
},
{
"param": "image_tag",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | rm | <not_specific> | def rm(self, container_alias):
'''
a method to remove an active container
:param container_alias: string with name or id of container
:return: string with container id
'''
title = '%s.rm' % self.__class__.__name__
# validate inputs
... |
a method to remove an active container
:param container_alias: string with name or id of container
:return: string with container id
| a method to remove an active container | [
"a",
"method",
"to",
"remove",
"an",
"active",
"container"
] | def rm(self, container_alias):
title = '%s.rm' % self.__class__.__name__
input_fields = {
'container_alias': container_alias
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validate(value, '.%... | [
"def",
"rm",
"(",
"self",
",",
"container_alias",
")",
":",
"title",
"=",
"'%s.rm'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'container_alias'",
":",
"container_alias",
"}",
"for",
"key",
",",
"value",
"in",
"input_fields",... | a method to remove an active container | [
"a",
"method",
"to",
"remove",
"an",
"active",
"container"
] | [
"'''\r\n a method to remove an active container\r\n \r\n :param container_alias: string with name or id of container \r\n :return: string with container id\r\n '''",
"# validate inputs\r",
"# run remove command\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "container_alias",
"type": null
}
] | {
"returns": [
{
"docstring": "string with container id",
"docstring_tokens": [
"string",
"with",
"container",
"id"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | rmi | <not_specific> | def rmi(self, image_id):
'''
a method to remove an image
:param image_name: string with id of image
:return: list of strings with image layers removed
'''
title = '%s.rmi' % self.__class__.__name__
# validate inputs
input_fields = {
... |
a method to remove an image
:param image_name: string with id of image
:return: list of strings with image layers removed
| a method to remove an image | [
"a",
"method",
"to",
"remove",
"an",
"image"
] | def rmi(self, image_id):
title = '%s.rmi' % self.__class__.__name__
input_fields = {
'image_id': image_id
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validate(value, '.%s' % key, object_ti... | [
"def",
"rmi",
"(",
"self",
",",
"image_id",
")",
":",
"title",
"=",
"'%s.rmi'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'image_id'",
":",
"image_id",
"}",
"for",
"key",
",",
"value",
"in",
"input_fields",
".",
"items",
... | a method to remove an image | [
"a",
"method",
"to",
"remove",
"an",
"image"
] | [
"'''\r\n a method to remove an image\r\n\r\n :param image_name: string with id of image\r\n :return: list of strings with image layers removed\r\n '''",
"# validate inputs\r",
"# send remove command \r"
] | [
{
"param": "self",
"type": null
},
{
"param": "image_id",
"type": null
}
] | {
"returns": [
{
"docstring": "list of strings with image layers removed",
"docstring_tokens": [
"list",
"of",
"strings",
"with",
"image",
"layers",
"removed"
],
"type": null
}
],
"raises": [],
"params": [
{
"ident... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | ip | <not_specific> | def ip(self):
'''
a method to retrieve the ip of system running docker
:return: string with ip address of system
'''
if self.localhost.os.sysname == 'Windows' and float(self.localhost.os.release) < 10:
sys_cmd = 'docker-machine ip %s' % self.vbox
... |
a method to retrieve the ip of system running docker
:return: string with ip address of system
| a method to retrieve the ip of system running docker | [
"a",
"method",
"to",
"retrieve",
"the",
"ip",
"of",
"system",
"running",
"docker"
] | def ip(self):
if self.localhost.os.sysname == 'Windows' and float(self.localhost.os.release) < 10:
sys_cmd = 'docker-machine ip %s' % self.vbox
system_ip = self.command(sys_cmd).replace('\n','')
else:
system_ip = self.localhost.ip
return system_ip | [
"def",
"ip",
"(",
"self",
")",
":",
"if",
"self",
".",
"localhost",
".",
"os",
".",
"sysname",
"==",
"'Windows'",
"and",
"float",
"(",
"self",
".",
"localhost",
".",
"os",
".",
"release",
")",
"<",
"10",
":",
"sys_cmd",
"=",
"'docker-machine ip %s'",
... | a method to retrieve the ip of system running docker | [
"a",
"method",
"to",
"retrieve",
"the",
"ip",
"of",
"system",
"running",
"docker"
] | [
"'''\r\n a method to retrieve the ip of system running docker\r\n\r\n :return: string with ip address of system\r\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "string with ip address of system",
"docstring_tokens": [
"string",
"with",
"ip",
"address",
"of",
"system"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type":... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | command | <not_specific> | def command(self, sys_command):
'''
a method to run a system command in a separate shell
:param sys_command: string with docker command
:return: string output from docker
'''
title = '%s.command' % self.__class__.__name__
# validate inputs
... |
a method to run a system command in a separate shell
:param sys_command: string with docker command
:return: string output from docker
| a method to run a system command in a separate shell | [
"a",
"method",
"to",
"run",
"a",
"system",
"command",
"in",
"a",
"separate",
"shell"
] | def command(self, sys_command):
title = '%s.command' % self.__class__.__name__
input_fields = {
'sys_command': sys_command
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validate(value, '.%s'... | [
"def",
"command",
"(",
"self",
",",
"sys_command",
")",
":",
"title",
"=",
"'%s.command'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'sys_command'",
":",
"sys_command",
"}",
"for",
"key",
",",
"value",
"in",
"input_fields",
... | a method to run a system command in a separate shell | [
"a",
"method",
"to",
"run",
"a",
"system",
"command",
"in",
"a",
"separate",
"shell"
] | [
"'''\r\n a method to run a system command in a separate shell\r\n\r\n :param sys_command: string with docker command\r\n :return: string output from docker\r\n '''",
"# validate inputs\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "sys_command",
"type": null
}
] | {
"returns": [
{
"docstring": "string output from docker",
"docstring_tokens": [
"string",
"output",
"from",
"docker"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | synopsis | <not_specific> | def synopsis(self, container_alias):
'''
a method to summarize key configuration settings required for docker compose
:param container_alias: string with name or id of container
:return: dictionary with values required for module configurations
'''
title =... |
a method to summarize key configuration settings required for docker compose
:param container_alias: string with name or id of container
:return: dictionary with values required for module configurations
| a method to summarize key configuration settings required for docker compose | [
"a",
"method",
"to",
"summarize",
"key",
"configuration",
"settings",
"required",
"for",
"docker",
"compose"
] | def synopsis(self, container_alias):
title = '%s.synopsis' % self.__class__.__name__
input_fields = {
'container_alias': container_alias
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validat... | [
"def",
"synopsis",
"(",
"self",
",",
"container_alias",
")",
":",
"title",
"=",
"'%s.synopsis'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'container_alias'",
":",
"container_alias",
"}",
"for",
"key",
",",
"value",
"in",
"in... | a method to summarize key configuration settings required for docker compose | [
"a",
"method",
"to",
"summarize",
"key",
"configuration",
"settings",
"required",
"for",
"docker",
"compose"
] | [
"'''\r\n a method to summarize key configuration settings required for docker compose\r\n\r\n :param container_alias: string with name or id of container\r\n :return: dictionary with values required for module configurations\r\n '''",
"# validate inputs\r",
"# retrieve container ... | [
{
"param": "self",
"type": null
},
{
"param": "container_alias",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with values required for module configurations",
"docstring_tokens": [
"dictionary",
"with",
"values",
"required",
"for",
"module",
"configurations"
],
"type": null
}
],
"raises": [],
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | enter | null | def enter(self, container_alias):
'''
a method to open up a terminal inside a running container
:param container_alias: string with name or id of container
:return: None
'''
title = '%s.enter' % self.__class__.__name__
# validate inputs
... |
a method to open up a terminal inside a running container
:param container_alias: string with name or id of container
:return: None
| a method to open up a terminal inside a running container | [
"a",
"method",
"to",
"open",
"up",
"a",
"terminal",
"inside",
"a",
"running",
"container"
] | def enter(self, container_alias):
title = '%s.enter' % self.__class__.__name__
input_fields = {
'container_alias': container_alias
}
for key, value in input_fields.items():
object_title = '%s(%s=%s)' % (title, key, str(value))
self.fields.validate(valu... | [
"def",
"enter",
"(",
"self",
",",
"container_alias",
")",
":",
"title",
"=",
"'%s.enter'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'container_alias'",
":",
"container_alias",
"}",
"for",
"key",
",",
"value",
"in",
"input_fi... | a method to open up a terminal inside a running container | [
"a",
"method",
"to",
"open",
"up",
"a",
"terminal",
"inside",
"a",
"running",
"container"
] | [
"'''\r\n a method to open up a terminal inside a running container\r\n\r\n :param container_alias: string with name or id of container \r\n :return: None\r\n '''",
"# validate inputs\r",
"# compose system command\r",
"# open up terminal\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "container_alias",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
413ea01cee609cb192107f94528569476162e9b2 | collectiveacuity/labPack | labpack/platforms/docker.py | [
"MIT"
] | Python | run | <not_specific> | def run(self, image_name, container_alias, image_tag='', environmental_variables=None, mapped_ports=None, mounted_volumes=None, start_command='', network_name='', run_flags=''):
'''
a method to start a local container
:param image_name: string with name or id of image
:param... |
a method to start a local container
:param image_name: string with name or id of image
:param container_alias: string with name to assign to container
:param image_tag: [optional] string with tag assigned to image
:param environmental_variables: [optional] dictionary... | a method to start a local container | [
"a",
"method",
"to",
"start",
"a",
"local",
"container"
] | def run(self, image_name, container_alias, image_tag='', environmental_variables=None, mapped_ports=None, mounted_volumes=None, start_command='', network_name='', run_flags=''):
title = '%s.run' % self.__class__.__name__
input_fields = {
'image_name': image_name,
'container_alias... | [
"def",
"run",
"(",
"self",
",",
"image_name",
",",
"container_alias",
",",
"image_tag",
"=",
"''",
",",
"environmental_variables",
"=",
"None",
",",
"mapped_ports",
"=",
"None",
",",
"mounted_volumes",
"=",
"None",
",",
"start_command",
"=",
"''",
",",
"netw... | a method to start a local container | [
"a",
"method",
"to",
"start",
"a",
"local",
"container"
] | [
"'''\r\n a method to start a local container\r\n\r\n :param image_name: string with name or id of image\r\n :param container_alias: string with name to assign to container\r\n :param image_tag: [optional] string with tag assigned to image\r\n :param environmental_variables: [... | [
{
"param": "self",
"type": null
},
{
"param": "image_name",
"type": null
},
{
"param": "container_alias",
"type": null
},
{
"param": "image_tag",
"type": null
},
{
"param": "environmental_variables",
"type": null
},
{
"param": "mapped_ports",
"type... | {
"returns": [
{
"docstring": "string with container id\nNOTE: valid characters for environmental variables key names follow the shell\nstandard of upper and lower alphanumerics or underscore and cannot start\nwith a numerical value.\n\nports are mapped such that the key name is the system port and the\nv... |
3f4c35ca0c6ab68a61927300c0ab1d91f8f887cb | collectiveacuity/labPack | labpack/platforms/aws/rds.py | [
"MIT"
] | Python | _validate_tags | null | def _validate_tags(self, tag_values, title):
''' a helper method to validate tag key and value pairs '''
if tag_values:
if len(tag_values.keys()) > 10:
raise Exception(
"%s(tag_values={...}) is invalid.\n Value %s for field .tag_values failed test 'max_k... | a helper method to validate tag key and value pairs | a helper method to validate tag key and value pairs | [
"a",
"helper",
"method",
"to",
"validate",
"tag",
"key",
"and",
"value",
"pairs"
] | def _validate_tags(self, tag_values, title):
if tag_values:
if len(tag_values.keys()) > 10:
raise Exception(
"%s(tag_values={...}) is invalid.\n Value %s for field .tag_values failed test 'max_keys': 10" % (
title, len(tag_values.keys())))
... | [
"def",
"_validate_tags",
"(",
"self",
",",
"tag_values",
",",
"title",
")",
":",
"if",
"tag_values",
":",
"if",
"len",
"(",
"tag_values",
".",
"keys",
"(",
")",
")",
">",
"10",
":",
"raise",
"Exception",
"(",
"\"%s(tag_values={...}) is invalid.\\n Value %s for... | a helper method to validate tag key and value pairs | [
"a",
"helper",
"method",
"to",
"validate",
"tag",
"key",
"and",
"value",
"pairs"
] | [
"''' a helper method to validate tag key and value pairs '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "tag_values",
"type": null
},
{
"param": "title",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag_values",
"type": null,
"docstring": null,
"docstring_toke... |
3f4c35ca0c6ab68a61927300c0ab1d91f8f887cb | collectiveacuity/labPack | labpack/platforms/aws/rds.py | [
"MIT"
] | Python | list_instances | <not_specific> | def list_instances(self, tag_values=None):
'''
a method to retrieve the list of instances on AWS RDS
:param tag_values: [optional] dictionary of tag key-values pairs
:return: list of strings with db instance AWS ids
'''
title = '%s.list_instances' % self.__class__.... |
a method to retrieve the list of instances on AWS RDS
:param tag_values: [optional] dictionary of tag key-values pairs
:return: list of strings with db instance AWS ids
| a method to retrieve the list of instances on AWS RDS | [
"a",
"method",
"to",
"retrieve",
"the",
"list",
"of",
"instances",
"on",
"AWS",
"RDS"
] | def list_instances(self, tag_values=None):
title = '%s.list_instances' % self.__class__.__name__
input_fields = {
'tag_values': tag_values
}
for key, value in input_fields.items():
if value:
object_title = '%s(%s=%s)' % (title, key, str(value))
... | [
"def",
"list_instances",
"(",
"self",
",",
"tag_values",
"=",
"None",
")",
":",
"title",
"=",
"'%s.list_instances'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"input_fields",
"=",
"{",
"'tag_values'",
":",
"tag_values",
"}",
"for",
"key",
",",
"value",... | a method to retrieve the list of instances on AWS RDS | [
"a",
"method",
"to",
"retrieve",
"the",
"list",
"of",
"instances",
"on",
"AWS",
"RDS"
] | [
"'''\n a method to retrieve the list of instances on AWS RDS\n\n :param tag_values: [optional] dictionary of tag key-values pairs\n :return: list of strings with db instance AWS ids\n '''",
"# validate inputs",
"# add tags to method arguments",
"# request instance details from ... | [
{
"param": "self",
"type": null
},
{
"param": "tag_values",
"type": null
}
] | {
"returns": [
{
"docstring": "list of strings with db instance AWS ids",
"docstring_tokens": [
"list",
"of",
"strings",
"with",
"db",
"instance",
"AWS",
"ids"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
3f4c35ca0c6ab68a61927300c0ab1d91f8f887cb | collectiveacuity/labPack | labpack/platforms/aws/rds.py | [
"MIT"
] | Python | delete_instance | <not_specific> | def delete_instance(self, instance_id):
'''
method for removing a db instance from AWS EC2
:param instance_id: string of instance id on AWS
:return: string reporting state of instance
'''
title = '%s.delete_instance' % self.__class__.__name__
# # validate inpu... |
method for removing a db instance from AWS EC2
:param instance_id: string of instance id on AWS
:return: string reporting state of instance
| method for removing a db instance from AWS EC2 | [
"method",
"for",
"removing",
"a",
"db",
"instance",
"from",
"AWS",
"EC2"
] | def delete_instance(self, instance_id):
title = '%s.delete_instance' % self.__class__.__name__
self.iam.printer('Removing db instance %s from AWS region %s.' % (instance_id, self.iam.region_name))
try:
response = self.connection.delete_db_instance(
DBInstanceIdentifie... | [
"def",
"delete_instance",
"(",
"self",
",",
"instance_id",
")",
":",
"title",
"=",
"'%s.delete_instance'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"self",
".",
"iam",
".",
"printer",
"(",
"'Removing db instance %s from AWS region %s.'",
"%",
"(",
"instance... | method for removing a db instance from AWS EC2 | [
"method",
"for",
"removing",
"a",
"db",
"instance",
"from",
"AWS",
"EC2"
] | [
"'''\n method for removing a db instance from AWS EC2\n\n :param instance_id: string of instance id on AWS\n :return: string reporting state of instance\n '''",
"# # validate inputs",
"# input_fields = {",
"# 'instance_id': instance_id",
"# }",
"# for ke... | [
{
"param": "self",
"type": null
},
{
"param": "instance_id",
"type": null
}
] | {
"returns": [
{
"docstring": "string reporting state of instance",
"docstring_tokens": [
"string",
"reporting",
"state",
"of",
"instance"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
... |
d3417b11a91366bbd4ee4ac93366f8842b2f9198 | collectiveacuity/labPack | labpack/compilers/json.py | [
"MIT"
] | Python | walk_data | <not_specific> | def walk_data(target, source):
''' method to recursively walk parse tree and merge source into target '''
from copy import deepcopy
# skip if target and source are different datatypes
if target.__class__.__name__ != source.__class__.__name__:
pass
# handle maps
elif isinstance(target,... | method to recursively walk parse tree and merge source into target | method to recursively walk parse tree and merge source into target | [
"method",
"to",
"recursively",
"walk",
"parse",
"tree",
"and",
"merge",
"source",
"into",
"target"
] | def walk_data(target, source):
from copy import deepcopy
if target.__class__.__name__ != source.__class__.__name__:
pass
elif isinstance(target, dict):
count = 0
target = OrderedDict(target)
for k, v in source.items():
if k not in target.keys():
ta... | [
"def",
"walk_data",
"(",
"target",
",",
"source",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"if",
"target",
".",
"__class__",
".",
"__name__",
"!=",
"source",
".",
"__class__",
".",
"__name__",
":",
"pass",
"elif",
"isinstance",
"(",
"target",
",",
... | method to recursively walk parse tree and merge source into target | [
"method",
"to",
"recursively",
"walk",
"parse",
"tree",
"and",
"merge",
"source",
"into",
"target"
] | [
"''' method to recursively walk parse tree and merge source into target '''",
"# skip if target and source are different datatypes",
"# handle maps",
"# insert fields not found in target",
"# else walk down maps and sequences",
"# handle sequences",
"# walk down maps and sequences"
] | [
{
"param": "target",
"type": null
},
{
"param": "source",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens... |
d3417b11a91366bbd4ee4ac93366f8842b2f9198 | collectiveacuity/labPack | labpack/compilers/json.py | [
"MIT"
] | Python | merge_json | <not_specific> | def merge_json(*sources, output=''):
'''
method for merging two or more json files
this method walks the parse tree of json data to merge the fields
found in subsequent sources into the data structure of the initial source.
any number of sources can be added to the source args, but only new f... |
method for merging two or more json files
this method walks the parse tree of json data to merge the fields
found in subsequent sources into the data structure of the initial source.
any number of sources can be added to the source args, but only new fields
from subsequent sources will be add... | method for merging two or more json files
this method walks the parse tree of json data to merge the fields
found in subsequent sources into the data structure of the initial source.
any number of sources can be added to the source args, but only new fields
from subsequent sources will be added. to overwrite values in ... | [
"method",
"for",
"merging",
"two",
"or",
"more",
"json",
"files",
"this",
"method",
"walks",
"the",
"parse",
"tree",
"of",
"json",
"data",
"to",
"merge",
"the",
"fields",
"found",
"in",
"subsequent",
"sources",
"into",
"the",
"data",
"structure",
"of",
"th... | def merge_json(*sources, output=''):
from copy import deepcopy
combined = None
src = [open(json_path).read() for json_path in sources]
for text in src:
data = json_lib.loads(text)
if not isinstance(data, list) and not isinstance(data, dict):
raise ValueError('Source documents... | [
"def",
"merge_json",
"(",
"*",
"sources",
",",
"output",
"=",
"''",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"combined",
"=",
"None",
"src",
"=",
"[",
"open",
"(",
"json_path",
")",
".",
"read",
"(",
")",
"for",
"json_path",
"in",
"sources",
"... | method for merging two or more json files
this method walks the parse tree of json data to merge the fields
found in subsequent sources into the data structure of the initial source. | [
"method",
"for",
"merging",
"two",
"or",
"more",
"json",
"files",
"this",
"method",
"walks",
"the",
"parse",
"tree",
"of",
"json",
"data",
"to",
"merge",
"the",
"fields",
"found",
"in",
"subsequent",
"sources",
"into",
"the",
"data",
"structure",
"of",
"th... | [
"'''\n method for merging two or more json files\n\n this method walks the parse tree of json data to merge the fields\n found in subsequent sources into the data structure of the initial source. \n any number of sources can be added to the source args, but only new fields\n from subsequent sourc... | [
{
"param": "output",
"type": null
}
] | {
"returns": [
{
"docstring": "OrderedDict (or list of OrderedDict) with merged data",
"docstring_tokens": [
"OrderedDict",
"(",
"or",
"list",
"of",
"OrderedDict",
")",
"with",
"merged",
"data"
],
"type": null
... |
2538177ccda4e5866b67cfc67cf061310a4397a5 | collectiveacuity/labPack | labpack/activity/moves.py | [
"MIT"
] | Python | _process_dates | <not_specific> | def _process_dates(self, timezone_offset, first_date, start, end, title, track_points=False):
''' a helper method to process datetime information for other requests
:param timezone_offset: integer with timezone offset from user profile details
:param first_date: string with ISO date from ... | a helper method to process datetime information for other requests
:param timezone_offset: integer with timezone offset from user profile details
:param first_date: string with ISO date from user profile details firstDate
:param start: float with starting datetime for daily summaries
... | a helper method to process datetime information for other requests | [
"a",
"helper",
"method",
"to",
"process",
"datetime",
"information",
"for",
"other",
"requests"
] | def _process_dates(self, timezone_offset, first_date, start, end, title, track_points=False):
input_fields = {
'timezone_offset': timezone_offset,
'first_date': first_date,
'start': start,
'end': end
}
for key, value in input_fields.items():
... | [
"def",
"_process_dates",
"(",
"self",
",",
"timezone_offset",
",",
"first_date",
",",
"start",
",",
"end",
",",
"title",
",",
"track_points",
"=",
"False",
")",
":",
"input_fields",
"=",
"{",
"'timezone_offset'",
":",
"timezone_offset",
",",
"'first_date'",
":... | a helper method to process datetime information for other requests | [
"a",
"helper",
"method",
"to",
"process",
"datetime",
"information",
"for",
"other",
"requests"
] | [
"''' a helper method to process datetime information for other requests\r\n\r\n :param timezone_offset: integer with timezone offset from user profile details\r\n :param first_date: string with ISO date from user profile details firstDate\r\n :param start: float with starting datetime for daily... | [
{
"param": "self",
"type": null
},
{
"param": "timezone_offset",
"type": null
},
{
"param": "first_date",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
},
{
"param": "title",
"type": null
},
{
"param": "... | {
"returns": [
{
"docstring": "dictionary of parameters to add to request",
"docstring_tokens": [
"dictionary",
"of",
"parameters",
"to",
"add",
"to",
"request"
],
"type": null
}
],
"raises": [],
"params": [
{
"ide... |
2538177ccda4e5866b67cfc67cf061310a4397a5 | collectiveacuity/labPack | labpack/activity/moves.py | [
"MIT"
] | Python | list_activities | <not_specific> | def list_activities(self):
''' a method to retrieve the details for all activities currently supported
:return: dictionary of response details with activities list inside json key
{
'headers': { ... },
'code': 200,
'error': '',
'url':... | a method to retrieve the details for all activities currently supported
:return: dictionary of response details with activities list inside json key
{
'headers': { ... },
'code': 200,
'error': '',
'url': 'https://api.moves-app.com/api/1.1/activ... | a method to retrieve the details for all activities currently supported | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"all",
"activities",
"currently",
"supported"
] | def list_activities(self):
title = '%s.list_activities' % self.__class__.__name__
url_string = '%s/activities' % self.endpoint
response_details = self._get_request(url_string)
return response_details | [
"def",
"list_activities",
"(",
"self",
")",
":",
"title",
"=",
"'%s.list_activities'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"url_string",
"=",
"'%s/activities'",
"%",
"self",
".",
"endpoint",
"response_details",
"=",
"self",
".",
"_get_request",
"(",
... | a method to retrieve the details for all activities currently supported | [
"a",
"method",
"to",
"retrieve",
"the",
"details",
"for",
"all",
"activities",
"currently",
"supported"
] | [
"''' a method to retrieve the details for all activities currently supported\r\n\r\n :return: dictionary of response details with activities list inside json key\r\n\r\n {\r\n 'headers': { ... },\r\n 'code': 200,\r\n 'error': '',\r\n 'url': 'https://api.mov... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary of response details with activities list inside json key\n{\n'headers': { ...",
"docstring_tokens": [
"dictionary",
"of",
"response",
"details",
"with",
"activities",
"list",
"inside",
"js... |
fefb6a29153b1a46373ee9f851408834d27853e7 | collectiveacuity/labPack | labpack/parsing/flask.py | [
"MIT"
] | Python | extract_request_details | <not_specific> | def extract_request_details(request_object, session_object=None):
'''
a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
... |
a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
counter-measures for the nasty web
:param request_object: requ... | a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
counter-measures for the nasty web | [
"a",
"method",
"for",
"extracting",
"request",
"details",
"from",
"request",
"and",
"session",
"objects",
"NOTE",
":",
"method",
"is",
"also",
"a",
"placeholder",
"funnel",
"for",
"future",
"validation",
"processes",
"request",
"logging",
"request",
"context",
"... | def extract_request_details(request_object, session_object=None):
request_details = {
'error': '',
'status': 'ok',
'code': 200,
'method': request_object.method,
'session': {},
'root': request_object.url_root,
'route': request_object.path,
'headers': {}... | [
"def",
"extract_request_details",
"(",
"request_object",
",",
"session_object",
"=",
"None",
")",
":",
"request_details",
"=",
"{",
"'error'",
":",
"''",
",",
"'status'",
":",
"'ok'",
",",
"'code'",
":",
"200",
",",
"'method'",
":",
"request_object",
".",
"m... | a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
counter-measures for the nasty web | [
"a",
"method",
"for",
"extracting",
"request",
"details",
"from",
"request",
"and",
"session",
"objects",
"NOTE",
":",
"method",
"is",
"also",
"a",
"placeholder",
"funnel",
"for",
"future",
"validation",
"processes",
"request",
"logging",
"request",
"context",
"... | [
"'''\r\n a method for extracting request details from request and session objects\r\n\r\n NOTE: method is also a placeholder funnel for future validation\r\n processes, request logging, request context building and\r\n counter-measures for the nasty web\r\n\r\n :para... | [
{
"param": "request_object",
"type": null
},
{
"param": "session_object",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with request details",
"docstring_tokens": [
"dictionary",
"with",
"request",
"details"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "request_object",
"type": null,
"... |
fefb6a29153b1a46373ee9f851408834d27853e7 | collectiveacuity/labPack | labpack/parsing/flask.py | [
"MIT"
] | Python | extract_session_details | <not_specific> | def extract_session_details(request_headers, session_header, secret_key):
'''
a method to extract and validate jwt session token from request headers
:param request_headers: dictionary with header fields from request
:param session_header: string with name of session token header key
:p... |
a method to extract and validate jwt session token from request headers
:param request_headers: dictionary with header fields from request
:param session_header: string with name of session token header key
:param secret_key: string with secret key to json web token encryption
:return: d... | a method to extract and validate jwt session token from request headers | [
"a",
"method",
"to",
"extract",
"and",
"validate",
"jwt",
"session",
"token",
"from",
"request",
"headers"
] | def extract_session_details(request_headers, session_header, secret_key):
session_details = {
'error': '',
'code': 200,
'session': {}
}
if not session_header in request_headers.keys():
session_details['error'] = '%s is missing.' % session_header
session_details['code'... | [
"def",
"extract_session_details",
"(",
"request_headers",
",",
"session_header",
",",
"secret_key",
")",
":",
"session_details",
"=",
"{",
"'error'",
":",
"''",
",",
"'code'",
":",
"200",
",",
"'session'",
":",
"{",
"}",
"}",
"if",
"not",
"session_header",
"... | a method to extract and validate jwt session token from request headers | [
"a",
"method",
"to",
"extract",
"and",
"validate",
"jwt",
"session",
"token",
"from",
"request",
"headers"
] | [
"'''\r\n a method to extract and validate jwt session token from request headers\r\n\r\n :param request_headers: dictionary with header fields from request\r\n :param session_header: string with name of session token header key\r\n :param secret_key: string with secret key to json web token encrypti... | [
{
"param": "request_headers",
"type": null
},
{
"param": "session_header",
"type": null
},
{
"param": "secret_key",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with request details with session details or error coding",
"docstring_tokens": [
"dictionary",
"with",
"request",
"details",
"with",
"session",
"details",
"or",
"error",
"coding"
... |
fefb6a29153b1a46373ee9f851408834d27853e7 | collectiveacuity/labPack | labpack/parsing/flask.py | [
"MIT"
] | Python | validate_request_content | <not_specific> | def validate_request_content(request_content, request_model, request_component='body'):
'''
a method to validate the content fields of a flask request
:param request_content: dictionary with content fields to validate
:param request_model: object with jsonmodel class properties
... |
a method to validate the content fields of a flask request
:param request_content: dictionary with content fields to validate
:param request_model: object with jsonmodel class properties
:param request_component: string with name of component of request evaluated
:return: dictio... | a method to validate the content fields of a flask request | [
"a",
"method",
"to",
"validate",
"the",
"content",
"fields",
"of",
"a",
"flask",
"request"
] | def validate_request_content(request_content, request_model, request_component='body'):
from jsonmodel.validators import jsonModel
from jsonmodel.exceptions import InputValidationError
title = 'validate_request_content'
if not isinstance(request_content, dict):
raise TypeError('%s(request_conten... | [
"def",
"validate_request_content",
"(",
"request_content",
",",
"request_model",
",",
"request_component",
"=",
"'body'",
")",
":",
"from",
"jsonmodel",
".",
"validators",
"import",
"jsonModel",
"from",
"jsonmodel",
".",
"exceptions",
"import",
"InputValidationError",
... | a method to validate the content fields of a flask request | [
"a",
"method",
"to",
"validate",
"the",
"content",
"fields",
"of",
"a",
"flask",
"request"
] | [
"'''\r\n a method to validate the content fields of a flask request\r\n \r\n :param request_content: dictionary with content fields to validate \r\n :param request_model: object with jsonmodel class properties\r\n :param request_component: string with name of component of request evaluated\r\... | [
{
"param": "request_content",
"type": null
},
{
"param": "request_model",
"type": null
},
{
"param": "request_component",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with validation status details",
"docstring_tokens": [
"dictionary",
"with",
"validation",
"status",
"details"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "request_conte... |
55778cd9554986dd6d1fff6ba079b8f2e1e09a98 | collectiveacuity/labPack | labpack/parsing/comparison.py | [
"MIT"
] | Python | compare_records | <not_specific> | def compare_records(new_record, old_record):
'''
a method to generate the differences between two data architectures
:param new_record: set, list or dictionary with new details of an item
:param old_record: set, list or dictionary with old details of an item
:return: list with dictiona... |
a method to generate the differences between two data architectures
:param new_record: set, list or dictionary with new details of an item
:param old_record: set, list or dictionary with old details of an item
:return: list with dictionary of changes between old and new records
[ ... | a method to generate the differences between two data architectures | [
"a",
"method",
"to",
"generate",
"the",
"differences",
"between",
"two",
"data",
"architectures"
] | def compare_records(new_record, old_record):
if new_record.__class__ != old_record.__class__:
raise TypeError('Datatype of new and old data must match.')
from copy import deepcopy
new_map = deepcopy(new_record)
old_map = deepcopy(old_record)
if isinstance(new_map, dict):
return _comp... | [
"def",
"compare_records",
"(",
"new_record",
",",
"old_record",
")",
":",
"if",
"new_record",
".",
"__class__",
"!=",
"old_record",
".",
"__class__",
":",
"raise",
"TypeError",
"(",
"'Datatype of new and old data must match.'",
")",
"from",
"copy",
"import",
"deepco... | a method to generate the differences between two data architectures | [
"a",
"method",
"to",
"generate",
"the",
"differences",
"between",
"two",
"data",
"architectures"
] | [
"'''\n a method to generate the differences between two data architectures\n \n :param new_record: set, list or dictionary with new details of an item\n :param old_record: set, list or dictionary with old details of an item\n :return: list with dictionary of changes between old and new record... | [
{
"param": "new_record",
"type": null
},
{
"param": "old_record",
"type": null
}
] | {
"returns": [
{
"docstring": "list with dictionary of changes between old and new records\n[ {\n'path': [ 'dict2', 'dict', 'list2', 4, 'key' ],\n'action': 'UPDATE',\n'value': 'newValue'\n} ]",
"docstring_tokens": [
"list",
"with",
"dictionary",
"of",
"changes",... |
55778cd9554986dd6d1fff6ba079b8f2e1e09a98 | collectiveacuity/labPack | labpack/parsing/comparison.py | [
"MIT"
] | Python | _compare_dict | <not_specific> | def _compare_dict(new_dict, old_dict, change_list=None, root=None):
'''
a method for recursively listing changes made to a dictionary
:param new_dict: dictionary with new key-value pairs
:param old_dict: dictionary with old key-value pairs
:param change_list: list of differences between old an... |
a method for recursively listing changes made to a dictionary
:param new_dict: dictionary with new key-value pairs
:param old_dict: dictionary with old key-value pairs
:param change_list: list of differences between old and new
:patam root: string with record of path to the root of the main ob... | a method for recursively listing changes made to a dictionary | [
"a",
"method",
"for",
"recursively",
"listing",
"changes",
"made",
"to",
"a",
"dictionary"
] | def _compare_dict(new_dict, old_dict, change_list=None, root=None):
from copy import deepcopy
new_keys = set(new_dict.keys())
old_keys = set(old_dict.keys())
missing_keys = old_keys - new_keys
extra_keys = new_keys - old_keys
same_keys = new_keys.intersection(old_keys)
for key in missing_key... | [
"def",
"_compare_dict",
"(",
"new_dict",
",",
"old_dict",
",",
"change_list",
"=",
"None",
",",
"root",
"=",
"None",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"new_keys",
"=",
"set",
"(",
"new_dict",
".",
"keys",
"(",
")",
")",
"old_keys",
"=",
"... | a method for recursively listing changes made to a dictionary | [
"a",
"method",
"for",
"recursively",
"listing",
"changes",
"made",
"to",
"a",
"dictionary"
] | [
"'''\n a method for recursively listing changes made to a dictionary\n\n :param new_dict: dictionary with new key-value pairs\n :param old_dict: dictionary with old key-value pairs\n :param change_list: list of differences between old and new\n :patam root: string with record of path to the root ... | [
{
"param": "new_dict",
"type": null
},
{
"param": "old_dict",
"type": null
},
{
"param": "change_list",
"type": null
},
{
"param": "root",
"type": null
}
] | {
"returns": [
{
"docstring": "list of differences between old and new",
"docstring_tokens": [
"list",
"of",
"differences",
"between",
"old",
"and",
"new"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifie... |
55778cd9554986dd6d1fff6ba079b8f2e1e09a98 | collectiveacuity/labPack | labpack/parsing/comparison.py | [
"MIT"
] | Python | _compare_list | <not_specific> | def _compare_list(new_list, old_list, change_list=None, root=None):
'''
a method for recursively listing changes made to a list
:param new_list: list with new value
:param old_list: list with old values
:param change_list: list of differences between old and new
:param root: string with re... |
a method for recursively listing changes made to a list
:param new_list: list with new value
:param old_list: list with old values
:param change_list: list of differences between old and new
:param root: string with record of path to the root of the main object
:return: list of differences... | a method for recursively listing changes made to a list | [
"a",
"method",
"for",
"recursively",
"listing",
"changes",
"made",
"to",
"a",
"list"
] | def _compare_list(new_list, old_list, change_list=None, root=None):
from copy import deepcopy
if len(old_list) > len(new_list):
same_len = len(new_list)
for i in reversed(range(len(new_list), len(old_list))):
new_path = deepcopy(root)
new_path.append(i)
change... | [
"def",
"_compare_list",
"(",
"new_list",
",",
"old_list",
",",
"change_list",
"=",
"None",
",",
"root",
"=",
"None",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"if",
"len",
"(",
"old_list",
")",
">",
"len",
"(",
"new_list",
")",
":",
"same_len",
"... | a method for recursively listing changes made to a list | [
"a",
"method",
"for",
"recursively",
"listing",
"changes",
"made",
"to",
"a",
"list"
] | [
"'''\n a method for recursively listing changes made to a list\n\n :param new_list: list with new value\n :param old_list: list with old values\n :param change_list: list of differences between old and new\n :param root: string with record of path to the root of the main object\n :return: list... | [
{
"param": "new_list",
"type": null
},
{
"param": "old_list",
"type": null
},
{
"param": "change_list",
"type": null
},
{
"param": "root",
"type": null
}
] | {
"returns": [
{
"docstring": "list of differences between old and new",
"docstring_tokens": [
"list",
"of",
"differences",
"between",
"old",
"and",
"new"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifie... |
55778cd9554986dd6d1fff6ba079b8f2e1e09a98 | collectiveacuity/labPack | labpack/parsing/comparison.py | [
"MIT"
] | Python | _compare_set | <not_specific> | def _compare_set(new_set, old_set, change_list, root):
'''
a method for list changes made to a set
:param new_set: set with new values
:param old_set: set with old values
:param change_list: list of differences between old and new
:patam root: string with record of path to the root of the ... |
a method for list changes made to a set
:param new_set: set with new values
:param old_set: set with old values
:param change_list: list of differences between old and new
:patam root: string with record of path to the root of the main object
:return: list of differences between old and ne... | a method for list changes made to a set | [
"a",
"method",
"for",
"list",
"changes",
"made",
"to",
"a",
"set"
] | def _compare_set(new_set, old_set, change_list, root):
from copy import deepcopy
path = deepcopy(root)
missing_items = old_set - new_set
extra_items = new_set - old_set
for item in missing_items:
change_list.append({'action': 'REMOVE', 'key': None, 'value': item, 'path': path})
for item ... | [
"def",
"_compare_set",
"(",
"new_set",
",",
"old_set",
",",
"change_list",
",",
"root",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"path",
"=",
"deepcopy",
"(",
"root",
")",
"missing_items",
"=",
"old_set",
"-",
"new_set",
"extra_items",
"=",
"new_set",... | a method for list changes made to a set | [
"a",
"method",
"for",
"list",
"changes",
"made",
"to",
"a",
"set"
] | [
"'''\n a method for list changes made to a set\n\n :param new_set: set with new values\n :param old_set: set with old values\n :param change_list: list of differences between old and new\n :patam root: string with record of path to the root of the main object\n :return: list of differences bet... | [
{
"param": "new_set",
"type": null
},
{
"param": "old_set",
"type": null
},
{
"param": "change_list",
"type": null
},
{
"param": "root",
"type": null
}
] | {
"returns": [
{
"docstring": "list of differences between old and new",
"docstring_tokens": [
"list",
"of",
"differences",
"between",
"old",
"and",
"new"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifie... |
9c1f09e73b4e7373924729a30b44bbb1c80da1ff | chenchongthu/ENMF | code/ENMF.py | [
"MIT"
] | Python | dev_step | <not_specific> | def dev_step(test_set, train_m, test_m,args):
"""
Evaluates model on a dev set
"""
user_te = np.array(test_set.keys())
user_te2 = user_te[:, np.newaxis]
ll = int(len(user_te) / 128) + 1
recall50 = []
recall100 = []
recall200 = []
ndcg50 = []
ndcg100 = []
ndcg200 = []
... |
Evaluates model on a dev set
| Evaluates model on a dev set | [
"Evaluates",
"model",
"on",
"a",
"dev",
"set"
] | def dev_step(test_set, train_m, test_m,args):
user_te = np.array(test_set.keys())
user_te2 = user_te[:, np.newaxis]
ll = int(len(user_te) / 128) + 1
recall50 = []
recall100 = []
recall200 = []
ndcg50 = []
ndcg100 = []
ndcg200 = []
for batch_num in range(ll):
start_index =... | [
"def",
"dev_step",
"(",
"test_set",
",",
"train_m",
",",
"test_m",
",",
"args",
")",
":",
"user_te",
"=",
"np",
".",
"array",
"(",
"test_set",
".",
"keys",
"(",
")",
")",
"user_te2",
"=",
"user_te",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"ll",
... | Evaluates model on a dev set | [
"Evaluates",
"model",
"on",
"a",
"dev",
"set"
] | [
"\"\"\"\n Evaluates model on a dev set\n\n \"\"\"",
"# recall",
"# print pre[np.arange(batch_users)[:, np.newaxis], idx_topk_part[:, :kj]]",
"# print idx_topk_part",
"# print pre_bin",
"# print tmp",
"# ndcg10"
] | [
{
"param": "test_set",
"type": null
},
{
"param": "train_m",
"type": null
},
{
"param": "test_m",
"type": null
},
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_set",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "train_m",
"type": null,
"docstring": null,
"docstring_tok... |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | privmsg | null | def privmsg(self, target, message):
"""
A convenience function that makes it easier to send PRIVMSGs without
having to type out the corresponding `send` instrunction.
"""
self.send('PRIVMSG {} {}'.format(target, message)) |
A convenience function that makes it easier to send PRIVMSGs without
having to type out the corresponding `send` instrunction.
| A convenience function that makes it easier to send PRIVMSGs without
having to type out the corresponding `send` instrunction. | [
"A",
"convenience",
"function",
"that",
"makes",
"it",
"easier",
"to",
"send",
"PRIVMSGs",
"without",
"having",
"to",
"type",
"out",
"the",
"corresponding",
"`",
"send",
"`",
"instrunction",
"."
] | def privmsg(self, target, message):
self.send('PRIVMSG {} {}'.format(target, message)) | [
"def",
"privmsg",
"(",
"self",
",",
"target",
",",
"message",
")",
":",
"self",
".",
"send",
"(",
"'PRIVMSG {} {}'",
".",
"format",
"(",
"target",
",",
"message",
")",
")"
] | A convenience function that makes it easier to send PRIVMSGs without
having to type out the corresponding `send` instrunction. | [
"A",
"convenience",
"function",
"that",
"makes",
"it",
"easier",
"to",
"send",
"PRIVMSGs",
"without",
"having",
"to",
"type",
"out",
"the",
"corresponding",
"`",
"send",
"`",
"instrunction",
"."
] | [
"\"\"\"\n A convenience function that makes it easier to send PRIVMSGs without\n having to type out the corresponding `send` instrunction.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "message",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | start | null | def start(self):
"""
Performs the bare minimum to start up the bot actor, i.e. sending a USER
and NICK message.
"""
print("Connecting to {} at port {}".format(self.host, self.port))
if self.registered:
self.PASSWORD = ''
while not self.PASSWORD:
... |
Performs the bare minimum to start up the bot actor, i.e. sending a USER
and NICK message.
| Performs the bare minimum to start up the bot actor, i.e. sending a USER
and NICK message. | [
"Performs",
"the",
"bare",
"minimum",
"to",
"start",
"up",
"the",
"bot",
"actor",
"i",
".",
"e",
".",
"sending",
"a",
"USER",
"and",
"NICK",
"message",
"."
] | def start(self):
print("Connecting to {} at port {}".format(self.host, self.port))
if self.registered:
self.PASSWORD = ''
while not self.PASSWORD:
self.PASSWORD = getpass.getpass()
else:
print('WARNING: Unregistered nick may lead to clashes.')
... | [
"def",
"start",
"(",
"self",
")",
":",
"print",
"(",
"\"Connecting to {} at port {}\"",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
")",
"if",
"self",
".",
"registered",
":",
"self",
".",
"PASSWORD",
"=",
"''",
"while",
"not... | Performs the bare minimum to start up the bot actor, i.e. | [
"Performs",
"the",
"bare",
"minimum",
"to",
"start",
"up",
"the",
"bot",
"actor",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Performs the bare minimum to start up the bot actor, i.e. sending a USER\n and NICK message.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | on_start | null | def on_start(self):
"""
Defines a set of actions to be taken when the bot has successfully
connected to IRC, here defined as "has received an 001 message from the
server".
"""
if self.registered:
self.privmsg('NickServ', 'IDENTIFY {}'.format(self.PASSWORD))
... |
Defines a set of actions to be taken when the bot has successfully
connected to IRC, here defined as "has received an 001 message from the
server".
| Defines a set of actions to be taken when the bot has successfully
connected to IRC, here defined as "has received an 001 message from the
server". | [
"Defines",
"a",
"set",
"of",
"actions",
"to",
"be",
"taken",
"when",
"the",
"bot",
"has",
"successfully",
"connected",
"to",
"IRC",
"here",
"defined",
"as",
"\"",
"has",
"received",
"an",
"001",
"message",
"from",
"the",
"server",
"\"",
"."
] | def on_start(self):
if self.registered:
self.privmsg('NickServ', 'IDENTIFY {}'.format(self.PASSWORD))
for channel in self.channels:
self.send('JOIN {}'.format(channel)) | [
"def",
"on_start",
"(",
"self",
")",
":",
"if",
"self",
".",
"registered",
":",
"self",
".",
"privmsg",
"(",
"'NickServ'",
",",
"'IDENTIFY {}'",
".",
"format",
"(",
"self",
".",
"PASSWORD",
")",
")",
"for",
"channel",
"in",
"self",
".",
"channels",
":"... | Defines a set of actions to be taken when the bot has successfully
connected to IRC, here defined as "has received an 001 message from the
server". | [
"Defines",
"a",
"set",
"of",
"actions",
"to",
"be",
"taken",
"when",
"the",
"bot",
"has",
"successfully",
"connected",
"to",
"IRC",
"here",
"defined",
"as",
"\"",
"has",
"received",
"an",
"001",
"message",
"from",
"the",
"server",
"\"",
"."
] | [
"\"\"\"\n Defines a set of actions to be taken when the bot has successfully\n connected to IRC, here defined as \"has received an 001 message from the\n server\".\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | stop | null | def stop(self):
"""
Stops the bot actor, by sending a QUIT message to the IRC server and
then ending the program.
"""
print('Quitting from {}'.format(self.host))
self.send('QUIT {}'.format(self.quit))
self.irc.shutdown(SHUT_RDWR)
self.irc.close() |
Stops the bot actor, by sending a QUIT message to the IRC server and
then ending the program.
| Stops the bot actor, by sending a QUIT message to the IRC server and
then ending the program. | [
"Stops",
"the",
"bot",
"actor",
"by",
"sending",
"a",
"QUIT",
"message",
"to",
"the",
"IRC",
"server",
"and",
"then",
"ending",
"the",
"program",
"."
] | def stop(self):
print('Quitting from {}'.format(self.host))
self.send('QUIT {}'.format(self.quit))
self.irc.shutdown(SHUT_RDWR)
self.irc.close() | [
"def",
"stop",
"(",
"self",
")",
":",
"print",
"(",
"'Quitting from {}'",
".",
"format",
"(",
"self",
".",
"host",
")",
")",
"self",
".",
"send",
"(",
"'QUIT {}'",
".",
"format",
"(",
"self",
".",
"quit",
")",
")",
"self",
".",
"irc",
".",
"shutdow... | Stops the bot actor, by sending a QUIT message to the IRC server and
then ending the program. | [
"Stops",
"the",
"bot",
"actor",
"by",
"sending",
"a",
"QUIT",
"message",
"to",
"the",
"IRC",
"server",
"and",
"then",
"ending",
"the",
"program",
"."
] | [
"\"\"\"\n Stops the bot actor, by sending a QUIT message to the IRC server and\n then ending the program.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | on_message | null | def on_message(self):
"""
Defines the actions that the bot object should take when it receives
a message.
"""
if self.mailbox.find('PING') != -1:
self.send('PONG {}'.format(self.mailbox.split(' ')[1])) |
Defines the actions that the bot object should take when it receives
a message.
| Defines the actions that the bot object should take when it receives
a message. | [
"Defines",
"the",
"actions",
"that",
"the",
"bot",
"object",
"should",
"take",
"when",
"it",
"receives",
"a",
"message",
"."
] | def on_message(self):
if self.mailbox.find('PING') != -1:
self.send('PONG {}'.format(self.mailbox.split(' ')[1])) | [
"def",
"on_message",
"(",
"self",
")",
":",
"if",
"self",
".",
"mailbox",
".",
"find",
"(",
"'PING'",
")",
"!=",
"-",
"1",
":",
"self",
".",
"send",
"(",
"'PONG {}'",
".",
"format",
"(",
"self",
".",
"mailbox",
".",
"split",
"(",
"' '",
")",
"[",... | Defines the actions that the bot object should take when it receives
a message. | [
"Defines",
"the",
"actions",
"that",
"the",
"bot",
"object",
"should",
"take",
"when",
"it",
"receives",
"a",
"message",
"."
] | [
"\"\"\"\n Defines the actions that the bot object should take when it receives\n a message.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75c22d2a58b59f9ef8cab696826e1bae2bf17b9e | Vaylide/threshette | threshette/irc.py | [
"MIT"
] | Python | run | null | def run(self):
"""
The function that gets the bot actually running,
"""
self.start()
while True:
self.get_message()
if "PRIVMSG #()" in self.mailbox:
if "hello" in self.mailbox:
self.privmsg("#()", "Hello!")
... |
The function that gets the bot actually running,
| The function that gets the bot actually running. | [
"The",
"function",
"that",
"gets",
"the",
"bot",
"actually",
"running",
"."
] | def run(self):
self.start()
while True:
self.get_message()
if "PRIVMSG #()" in self.mailbox:
if "hello" in self.mailbox:
self.privmsg("#()", "Hello!")
if "!quit" in self.mailbox:
break
self.stop() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"start",
"(",
")",
"while",
"True",
":",
"self",
".",
"get_message",
"(",
")",
"if",
"\"PRIVMSG #()\"",
"in",
"self",
".",
"mailbox",
":",
"if",
"\"hello\"",
"in",
"self",
".",
"mailbox",
":",
"self",... | The function that gets the bot actually running, | [
"The",
"function",
"that",
"gets",
"the",
"bot",
"actually",
"running"
] | [
"\"\"\"\n The function that gets the bot actually running, \n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a9a18881f824032903dc10d2a27e2697f5781840 | thes01/robotanik_analysis | parsing.py | [
"MIT"
] | Python | parse_gamelog | <not_specific> | def parse_gamelog(path):
"""
parse gamelog and return list of users
:param problemId: id (as string) of problem to process
:param path: path to directory with logs
:return: list of users
"""
users = []
firstLine = True
currentUser = None
with open(path, "r") as f:
for ... |
parse gamelog and return list of users
:param problemId: id (as string) of problem to process
:param path: path to directory with logs
:return: list of users
| parse gamelog and return list of users | [
"parse",
"gamelog",
"and",
"return",
"list",
"of",
"users"
] | def parse_gamelog(path):
users = []
firstLine = True
currentUser = None
with open(path, "r") as f:
for line in f:
if firstLine:
firstLine = False
continue
if re.search("User", line):
uid = int(line.rstrip().split()[-1])
... | [
"def",
"parse_gamelog",
"(",
"path",
")",
":",
"users",
"=",
"[",
"]",
"firstLine",
"=",
"True",
"currentUser",
"=",
"None",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"firstLine",
":",
"fir... | parse gamelog and return list of users | [
"parse",
"gamelog",
"and",
"return",
"list",
"of",
"users"
] | [
"\"\"\"\n parse gamelog and return list of users\n\n :param problemId: id (as string) of problem to process\n :param path: path to directory with logs\n :return: list of users\n \"\"\"",
"# First line contains the name of the problem, which can be arbitrary and can therefore interfere",
"# with c... | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "list of users",
"docstring_tokens": [
"list",
"of",
"users"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "path to directory with logs",
"docstri... |
ae641cc99db11e9e6af1e9bddb96f27b786f9892 | thes01/robotanik_analysis | canonize.py | [
"MIT"
] | Python | canonize | <not_specific> | def canonize(problem, sub: Submit, testEquivalence=False):
'''
canonize submit according to given problem
:param problem:
:param sub: submit to canonize
:return: canonized form
'''
# deep copy to prevent changing original submit
submit = deepcopy(sub)
submit.sortFunctions()
can... |
canonize submit according to given problem
:param problem:
:param sub: submit to canonize
:return: canonized form
| canonize submit according to given problem | [
"canonize",
"submit",
"according",
"to",
"given",
"problem"
] | def canonize(problem, sub: Submit, testEquivalence=False):
submit = deepcopy(sub)
submit.sortFunctions()
canonized = Submit.empty()
canonized.is_solution = submit.is_solution
simulationInfo = simulate(problem, submit)
for i in range(5):
if not simulationInfo.functionsExecuted[i]:
... | [
"def",
"canonize",
"(",
"problem",
",",
"sub",
":",
"Submit",
",",
"testEquivalence",
"=",
"False",
")",
":",
"submit",
"=",
"deepcopy",
"(",
"sub",
")",
"submit",
".",
"sortFunctions",
"(",
")",
"canonized",
"=",
"Submit",
".",
"empty",
"(",
")",
"can... | canonize submit according to given problem | [
"canonize",
"submit",
"according",
"to",
"given",
"problem"
] | [
"'''\n canonize submit according to given problem\n :param problem:\n :param sub: submit to canonize\n :return: canonized form\n '''",
"# deep copy to prevent changing original submit",
"# simulates the submit to get simulation information",
"# remove functions that were not executed - set as e... | [
{
"param": "problem",
"type": null
},
{
"param": "sub",
"type": "Submit"
},
{
"param": "testEquivalence",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "problem",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
6a5c6470a0b2e07c752dca3e4d45b2eb604b671d | thes01/robotanik_analysis | produceGraph.py | [
"MIT"
] | Python | computeDifferentionFromSolutionsMatrix | <not_specific> | def computeDifferentionFromSolutionsMatrix(submits, use_visited: bool):
"""
for each submit, compute its difference from all solutions,
so the output matrix is N_SUBMITS x N_SOLUTIONS
:param submits
:param use_visited: see global variable USE_VISITED
:return: difference matrix
"""
... |
for each submit, compute its difference from all solutions,
so the output matrix is N_SUBMITS x N_SOLUTIONS
:param submits
:param use_visited: see global variable USE_VISITED
:return: difference matrix
| for each submit, compute its difference from all solutions,
so the output matrix is N_SUBMITS x N_SOLUTIONS
| [
"for",
"each",
"submit",
"compute",
"its",
"difference",
"from",
"all",
"solutions",
"so",
"the",
"output",
"matrix",
"is",
"N_SUBMITS",
"x",
"N_SOLUTIONS"
] | def computeDifferentionFromSolutionsMatrix(submits, use_visited: bool):
solutions = [submit for submit in submits if submit.flowers_left == 0]
print("{} solutions".format(len(solutions)))
matrix = np.zeros((len(submits), len(solutions)))
for i in range(len(submits)):
print(i)
for s in ra... | [
"def",
"computeDifferentionFromSolutionsMatrix",
"(",
"submits",
",",
"use_visited",
":",
"bool",
")",
":",
"solutions",
"=",
"[",
"submit",
"for",
"submit",
"in",
"submits",
"if",
"submit",
".",
"flowers_left",
"==",
"0",
"]",
"print",
"(",
"\"{} solutions\"",
... | for each submit, compute its difference from all solutions,
so the output matrix is N_SUBMITS x N_SOLUTIONS | [
"for",
"each",
"submit",
"compute",
"its",
"difference",
"from",
"all",
"solutions",
"so",
"the",
"output",
"matrix",
"is",
"N_SUBMITS",
"x",
"N_SOLUTIONS"
] | [
"\"\"\"\n for each submit, compute its difference from all solutions,\n so the output matrix is N_SUBMITS x N_SOLUTIONS\n\n :param submits\n :param use_visited: see global variable USE_VISITED\n :return: difference matrix\n \"\"\""
] | [
{
"param": "submits",
"type": null
},
{
"param": "use_visited",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "submits",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_visited",
"type": "bool",
"docstring": null,
"docstrin... |
dbae807950aa63c69b6cfb12bafc397f7e051ab5 | thes01/robotanik_analysis | simulation.py | [
"MIT"
] | Python | simulate | <not_specific> | def simulate(problem: Problem, submit: Submit):
'''
simulates given solution of the problem, animation works only when run from command line
:param problem:
:param solution:
:return: dictionary with simulation information
'''
board = problem.getBoardCopy()
flowersLeft = problem.getFlowe... |
simulates given solution of the problem, animation works only when run from command line
:param problem:
:param solution:
:return: dictionary with simulation information
| simulates given solution of the problem, animation works only when run from command line | [
"simulates",
"given",
"solution",
"of",
"the",
"problem",
"animation",
"works",
"only",
"when",
"run",
"from",
"command",
"line"
] | def simulate(problem: Problem, submit: Submit):
board = problem.getBoardCopy()
flowersLeft = problem.getFlowerCount()
simInfo = SimulationInfo()
recDepth = 0
order = 2
col = problem.robotCol
row = problem.robotRow
rot = problem.robotDir
simInfo.visited.append((row, col))
moves... | [
"def",
"simulate",
"(",
"problem",
":",
"Problem",
",",
"submit",
":",
"Submit",
")",
":",
"board",
"=",
"problem",
".",
"getBoardCopy",
"(",
")",
"flowersLeft",
"=",
"problem",
".",
"getFlowerCount",
"(",
")",
"simInfo",
"=",
"SimulationInfo",
"(",
")",
... | simulates given solution of the problem, animation works only when run from command line | [
"simulates",
"given",
"solution",
"of",
"the",
"problem",
"animation",
"works",
"only",
"when",
"run",
"from",
"command",
"line"
] | [
"'''\n simulates given solution of the problem, animation works only when run from command line\n :param problem:\n :param solution:\n :return: dictionary with simulation information\n '''",
"# current recursion depth",
"# ordering of functions - number which will be associated with the next fun... | [
{
"param": "problem",
"type": "Problem"
},
{
"param": "submit",
"type": "Submit"
}
] | {
"returns": [
{
"docstring": "dictionary with simulation information",
"docstring_tokens": [
"dictionary",
"with",
"simulation",
"information"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "problem",
"type": "Probl... |
b8435b37fd81f84433be9c541a02298fdb880a29 | thes01/robotanik_analysis | parseProcessedSubmits.py | [
"MIT"
] | Python | loadProcessedSubmits | <not_specific> | def loadProcessedSubmits(filePath: str):
'''
load processed submits given the id of problem
:param problem_id
:return: list of ProcessedSubmits
'''
submits = []
with open(filePath) as src:
user_id = 0
for line in src.readlines():
if len(line) > 0:
... |
load processed submits given the id of problem
:param problem_id
:return: list of ProcessedSubmits
| load processed submits given the id of problem
:param problem_id
:return: list of ProcessedSubmits | [
"load",
"processed",
"submits",
"given",
"the",
"id",
"of",
"problem",
":",
"param",
"problem_id",
":",
"return",
":",
"list",
"of",
"ProcessedSubmits"
] | def loadProcessedSubmits(filePath: str):
submits = []
with open(filePath) as src:
user_id = 0
for line in src.readlines():
if len(line) > 0:
if re.match("user", line):
user_id = line.split(' ')[1]
else:
submits.a... | [
"def",
"loadProcessedSubmits",
"(",
"filePath",
":",
"str",
")",
":",
"submits",
"=",
"[",
"]",
"with",
"open",
"(",
"filePath",
")",
"as",
"src",
":",
"user_id",
"=",
"0",
"for",
"line",
"in",
"src",
".",
"readlines",
"(",
")",
":",
"if",
"len",
"... | load processed submits given the id of problem
:param problem_id
:return: list of ProcessedSubmits | [
"load",
"processed",
"submits",
"given",
"the",
"id",
"of",
"problem",
":",
"param",
"problem_id",
":",
"return",
":",
"list",
"of",
"ProcessedSubmits"
] | [
"'''\n load processed submits given the id of problem\n :param problem_id\n :return: list of ProcessedSubmits\n '''"
] | [
{
"param": "filePath",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filePath",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3e20ecb5dbcab053472611fc5813bfe49b5257e8 | tungsd/SliceXblock | slicexblock/slicexblock/slicexblock.py | [
"MIT"
] | Python | student_view | <not_specific> | def student_view(self, context=None):
"""
The primary view of the SliceXBlock, shown to students
when viewing courses.
"""
html = self.resource_string("static/html/slicexblock.html")
frag = Fragment(html.format(self=self))
frag.add_css(self.resource_string("static... |
The primary view of the SliceXBlock, shown to students
when viewing courses.
| The primary view of the SliceXBlock, shown to students
when viewing courses. | [
"The",
"primary",
"view",
"of",
"the",
"SliceXBlock",
"shown",
"to",
"students",
"when",
"viewing",
"courses",
"."
] | def student_view(self, context=None):
html = self.resource_string("static/html/slicexblock.html")
frag = Fragment(html.format(self=self))
frag.add_css(self.resource_string("static/css/slicexblock.css"))
frag.add_javascript(self.resource_string("static/js/src/slicexblock.js"))
fra... | [
"def",
"student_view",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"html",
"=",
"self",
".",
"resource_string",
"(",
"\"static/html/slicexblock.html\"",
")",
"frag",
"=",
"Fragment",
"(",
"html",
".",
"format",
"(",
"self",
"=",
"self",
")",
")",
... | The primary view of the SliceXBlock, shown to students
when viewing courses. | [
"The",
"primary",
"view",
"of",
"the",
"SliceXBlock",
"shown",
"to",
"students",
"when",
"viewing",
"courses",
"."
] | [
"\"\"\"\n The primary view of the SliceXBlock, shown to students\n when viewing courses.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context",
"type": null,
"docstring": null,
"docstring_tokens"... |
3e20ecb5dbcab053472611fc5813bfe49b5257e8 | tungsd/SliceXblock | slicexblock/slicexblock/slicexblock.py | [
"MIT"
] | Python | studio_view | <not_specific> | def studio_view(self, _context):
"""
The setting view of the SliceXBlock, shown to students
when viewing courses.
"""
html = self.resource_string("static/html/settings.html")
frag = Fragment(html.format(self=self))
frag.add_css(self.resource_string("static/css/set... |
The setting view of the SliceXBlock, shown to students
when viewing courses.
| The setting view of the SliceXBlock, shown to students
when viewing courses. | [
"The",
"setting",
"view",
"of",
"the",
"SliceXBlock",
"shown",
"to",
"students",
"when",
"viewing",
"courses",
"."
] | def studio_view(self, _context):
html = self.resource_string("static/html/settings.html")
frag = Fragment(html.format(self=self))
frag.add_css(self.resource_string("static/css/settings.css"))
frag.add_javascript(self.resource_string("static/js/src/slicexblock.js"))
frag.initializ... | [
"def",
"studio_view",
"(",
"self",
",",
"_context",
")",
":",
"html",
"=",
"self",
".",
"resource_string",
"(",
"\"static/html/settings.html\"",
")",
"frag",
"=",
"Fragment",
"(",
"html",
".",
"format",
"(",
"self",
"=",
"self",
")",
")",
"frag",
".",
"a... | The setting view of the SliceXBlock, shown to students
when viewing courses. | [
"The",
"setting",
"view",
"of",
"the",
"SliceXBlock",
"shown",
"to",
"students",
"when",
"viewing",
"courses",
"."
] | [
"\"\"\"\n The setting view of the SliceXBlock, shown to students\n when viewing courses.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "_context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "_context",
"type": null,
"docstring": null,
"docstring_tokens... |
3e20ecb5dbcab053472611fc5813bfe49b5257e8 | tungsd/SliceXblock | slicexblock/slicexblock/slicexblock.py | [
"MIT"
] | Python | generate_slices | <not_specific> | def generate_slices(self, data, suffix=''):
"""
It takes the id and then download the video file
After that it slices the video to images.
it is done using slicevideo thread.
"""
self.video_id = data['video_id']
# Create two threads as follows
#thread.sta... |
It takes the id and then download the video file
After that it slices the video to images.
it is done using slicevideo thread.
| It takes the id and then download the video file
After that it slices the video to images.
it is done using slicevideo thread. | [
"It",
"takes",
"the",
"id",
"and",
"then",
"download",
"the",
"video",
"file",
"After",
"that",
"it",
"slices",
"the",
"video",
"to",
"images",
".",
"it",
"is",
"done",
"using",
"slicevideo",
"thread",
"."
] | def generate_slices(self, data, suffix=''):
self.video_id = data['video_id']
thread1 = SliceVideo(1, self.video_id, 1)
thread1.start()
self.video_slices_div = self.video_slices_div + "<div>" + self.video_id + "</div>"
return {"video_id" : self.video_id} | [
"def",
"generate_slices",
"(",
"self",
",",
"data",
",",
"suffix",
"=",
"''",
")",
":",
"self",
".",
"video_id",
"=",
"data",
"[",
"'video_id'",
"]",
"thread1",
"=",
"SliceVideo",
"(",
"1",
",",
"self",
".",
"video_id",
",",
"1",
")",
"thread1",
".",... | It takes the id and then download the video file
After that it slices the video to images. | [
"It",
"takes",
"the",
"id",
"and",
"then",
"download",
"the",
"video",
"file",
"After",
"that",
"it",
"slices",
"the",
"video",
"to",
"images",
"."
] | [
"\"\"\"\n It takes the id and then download the video file\n After that it slices the video to images.\n it is done using slicevideo thread.\n \"\"\"",
"# Create two threads as follows",
"#thread.start_new_thread(download_video, (\"Thread-1\", 2, ))"
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "suffix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
3e20ecb5dbcab053472611fc5813bfe49b5257e8 | tungsd/SliceXblock | slicexblock/slicexblock/slicexblock.py | [
"MIT"
] | Python | workbench_scenarios | <not_specific> | def workbench_scenarios():
"""A canned scenario for display in the workbench."""
return [
("SliceXBlock",
"""<slicexblock/>
"""),
("Multiple SliceXBlock",
"""<vertical_demo>
<slicexblock/>
<slicexblock/>
... | A canned scenario for display in the workbench. | A canned scenario for display in the workbench. | [
"A",
"canned",
"scenario",
"for",
"display",
"in",
"the",
"workbench",
"."
] | def workbench_scenarios():
return [
("SliceXBlock",
"""<slicexblock/>
"""),
("Multiple SliceXBlock",
"""<vertical_demo>
<slicexblock/>
<slicexblock/>
<slicexblock/>
</vertical_demo>
... | [
"def",
"workbench_scenarios",
"(",
")",
":",
"return",
"[",
"(",
"\"SliceXBlock\"",
",",
"\"\"\"<slicexblock/>\n \"\"\"",
")",
",",
"(",
"\"Multiple SliceXBlock\"",
",",
"\"\"\"<vertical_demo>\n <slicexblock/>\n <slicexblock/>\n ... | A canned scenario for display in the workbench. | [
"A",
"canned",
"scenario",
"for",
"display",
"in",
"the",
"workbench",
"."
] | [
"\"\"\"A canned scenario for display in the workbench.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bb3a257b30626704960d00570afdf36377c174a3 | alexplaka/ML | CardiovascularDisease/CVD/data_visualizer.py | [
"MIT"
] | Python | draw_cat_plot | <not_specific> | def draw_cat_plot(df: pd.DataFrame, id_var: str, cat_feats: list, *, output_filename: str =None):
"""
Draw plot showing value counts of categorical features.
:parameter dframe: pandas dataframe containing the feature `id_var` and all of the features in `cat_feats`.
Note: this impleme... |
Draw plot showing value counts of categorical features.
:parameter dframe: pandas dataframe containing the feature `id_var` and all of the features in `cat_feats`.
Note: this implementation does not check that all of the relevant features are in `dframe`.
:parameter id_var: Feature ... | Draw plot showing value counts of categorical features. | [
"Draw",
"plot",
"showing",
"value",
"counts",
"of",
"categorical",
"features",
"."
] | def draw_cat_plot(df: pd.DataFrame, id_var: str, cat_feats: list, *, output_filename: str =None):
df_cat = pd.melt(df, id_vars=id_var, value_vars=cat_feats)
fig = sns.catplot(x="variable", hue="value", col=id_var, data=df_cat,
kind="count")
fig.set_xlabels('')
fig.set_xticklabels(... | [
"def",
"draw_cat_plot",
"(",
"df",
":",
"pd",
".",
"DataFrame",
",",
"id_var",
":",
"str",
",",
"cat_feats",
":",
"list",
",",
"*",
",",
"output_filename",
":",
"str",
"=",
"None",
")",
":",
"df_cat",
"=",
"pd",
".",
"melt",
"(",
"df",
",",
"id_var... | Draw plot showing value counts of categorical features. | [
"Draw",
"plot",
"showing",
"value",
"counts",
"of",
"categorical",
"features",
"."
] | [
"\"\"\"\n Draw plot showing value counts of categorical features.\n\n :parameter dframe: pandas dataframe containing the feature `id_var` and all of the features in `cat_feats`.\n Note: this implementation does not check that all of the relevant features are in `dframe`.\n :parameter ... | [
{
"param": "df",
"type": "pd.DataFrame"
},
{
"param": "id_var",
"type": "str"
},
{
"param": "cat_feats",
"type": "list"
},
{
"param": "output_filename",
"type": "str"
}
] | {
"returns": [
{
"docstring": "Seaborn figure object.",
"docstring_tokens": [
"Seaborn",
"figure",
"object",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": null,
... |
bb3a257b30626704960d00570afdf36377c174a3 | alexplaka/ML | CardiovascularDisease/CVD/data_visualizer.py | [
"MIT"
] | Python | draw_corr_matrix | <not_specific> | def draw_corr_matrix(df: pd.DataFrame):
"""
- Draw correlation matrix as heatmap.
- Draw correlation for target feature and mutual information in a bar plot.
Note: Assuming the target feature is in the last column of df.
:parameter df: pandas dataframe with all of the relevant features as columns.
... |
- Draw correlation matrix as heatmap.
- Draw correlation for target feature and mutual information in a bar plot.
Note: Assuming the target feature is in the last column of df.
:parameter df: pandas dataframe with all of the relevant features as columns.
:return: fig: matplotlib figure object;
... | Draw correlation matrix as heatmap.
Draw correlation for target feature and mutual information in a bar plot.
Note: Assuming the target feature is in the last column of df. | [
"Draw",
"correlation",
"matrix",
"as",
"heatmap",
".",
"Draw",
"correlation",
"for",
"target",
"feature",
"and",
"mutual",
"information",
"in",
"a",
"bar",
"plot",
".",
"Note",
":",
"Assuming",
"the",
"target",
"feature",
"is",
"in",
"the",
"last",
"column",... | def draw_corr_matrix(df: pd.DataFrame):
target = df.columns[-1]
corr = df.corr()
target_corr = corr.loc[target, corr.columns.delete(-1)]
mi = mutual_info_classif(df.iloc[:, :-1], df[target])
scores = target_corr.to_frame()
scores.rename(columns={target: "Corr"}, inplace=True)
scores["M... | [
"def",
"draw_corr_matrix",
"(",
"df",
":",
"pd",
".",
"DataFrame",
")",
":",
"target",
"=",
"df",
".",
"columns",
"[",
"-",
"1",
"]",
"corr",
"=",
"df",
".",
"corr",
"(",
")",
"target_corr",
"=",
"corr",
".",
"loc",
"[",
"target",
",",
"corr",
".... | Draw correlation matrix as heatmap. | [
"Draw",
"correlation",
"matrix",
"as",
"heatmap",
"."
] | [
"\"\"\"\n - Draw correlation matrix as heatmap.\n - Draw correlation for target feature and mutual information in a bar plot.\n Note: Assuming the target feature is in the last column of df.\n\n :parameter df: pandas dataframe with all of the relevant features as columns.\n :return: fig: matplotlib f... | [
{
"param": "df",
"type": "pd.DataFrame"
}
] | {
"returns": [
{
"docstring": "matplotlib figure object;\ncorr: correlation matrix for all features;\nscores: pandas dataframe with the correlation and mutual information scores\nfor the target feature.",
"docstring_tokens": [
"matplotlib",
"figure",
"object",
";",
... |
be4c186b3cd7e08d8a05d622e4e65495618cc91c | alexplaka/ML | CardiovascularDisease/CVD/main.py | [
"MIT"
] | Python | load | <not_specific> | def load():
""" Import data and rename the columns """
df = pd.read_csv("../cardio_data.csv", index_col="id")
# Improve column names for readability
df.rename(str.capitalize, axis='columns', inplace=True)
df.rename(columns={'Ap_hi': 'BP_hi', 'Ap_lo': 'BP_lo', 'Gluc': 'Glucose', 'Alco': 'Alcohol'},... | Import data and rename the columns | Import data and rename the columns | [
"Import",
"data",
"and",
"rename",
"the",
"columns"
] | def load():
df = pd.read_csv("../cardio_data.csv", index_col="id")
df.rename(str.capitalize, axis='columns', inplace=True)
df.rename(columns={'Ap_hi': 'BP_hi', 'Ap_lo': 'BP_lo', 'Gluc': 'Glucose', 'Alco': 'Alcohol'},
inplace=True)
return df | [
"def",
"load",
"(",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"\"../cardio_data.csv\"",
",",
"index_col",
"=",
"\"id\"",
")",
"df",
".",
"rename",
"(",
"str",
".",
"capitalize",
",",
"axis",
"=",
"'columns'",
",",
"inplace",
"=",
"True",
")",
... | Import data and rename the columns | [
"Import",
"data",
"and",
"rename",
"the",
"columns"
] | [
"\"\"\" Import data and rename the columns \"\"\"",
"# Improve column names for readability"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b5f290930619da65a9f0c862928be2485634a9ae | alexplaka/ML | CardiovascularDisease/CVD/ML_models.py | [
"MIT"
] | Python | svc_model | <not_specific> | def svc_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
"""
Support Vector Machine Classifier model: choose kernel.
Then fit to data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to training data.
:paramete... |
Support Vector Machine Classifier model: choose kernel.
Then fit to data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to training data.
:parameter X_test: Test data.
:parameter y_test: Target that corresponds to test data.
:return: Model objec... | Support Vector Machine Classifier model: choose kernel.
Then fit to data and predict. | [
"Support",
"Vector",
"Machine",
"Classifier",
"model",
":",
"choose",
"kernel",
".",
"Then",
"fit",
"to",
"data",
"and",
"predict",
"."
] | def svc_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
kernel = 'linear'
clf = SVC(kernel=kernel, probability=True)
model = clf.fit(X_train, y_train)
y_pred = model.predict(X_test)
print(f'Estimator: Support Vector Machine Classifier (kernel={kernel}... | [
"def",
"svc_model",
"(",
"X_train",
":",
"pd",
".",
"DataFrame",
",",
"X_test",
":",
"pd",
".",
"DataFrame",
",",
"y_train",
":",
"pd",
".",
"Series",
",",
"y_test",
":",
"pd",
".",
"Series",
")",
":",
"kernel",
"=",
"'linear'",
"clf",
"=",
"SVC",
... | Support Vector Machine Classifier model: choose kernel. | [
"Support",
"Vector",
"Machine",
"Classifier",
"model",
":",
"choose",
"kernel",
"."
] | [
"\"\"\"\n Support Vector Machine Classifier model: choose kernel.\n Then fit to data and predict.\n\n :parameter X_train: Training data.\n :parameter y_train: Target that corresponds to training data.\n :parameter X_test: Test data.\n :parameter y_test: Target that corresponds to test data.\n :... | [
{
"param": "X_train",
"type": "pd.DataFrame"
},
{
"param": "X_test",
"type": "pd.DataFrame"
},
{
"param": "y_train",
"type": "pd.Series"
},
{
"param": "y_test",
"type": "pd.Series"
}
] | {
"returns": [
{
"docstring": "Model object, model predictions for test dataset, and classification report (dict).",
"docstring_tokens": [
"Model",
"object",
"model",
"predictions",
"for",
"test",
"dataset",
"and",
"classification... |
b5f290930619da65a9f0c862928be2485634a9ae | alexplaka/ML | CardiovascularDisease/CVD/ML_models.py | [
"MIT"
] | Python | kNN_model | <not_specific> | def kNN_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
"""
K-nearest neighbors model: find best hyperparameter k and weight method.
Then fit to (unscaled) data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to ... |
K-nearest neighbors model: find best hyperparameter k and weight method.
Then fit to (unscaled) data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to training data.
:parameter X_test: Test data.
:parameter y_test: Target that corresponds to test da... | K-nearest neighbors model: find best hyperparameter k and weight method.
Then fit to (unscaled) data and predict. | [
"K",
"-",
"nearest",
"neighbors",
"model",
":",
"find",
"best",
"hyperparameter",
"k",
"and",
"weight",
"method",
".",
"Then",
"fit",
"to",
"(",
"unscaled",
")",
"data",
"and",
"predict",
"."
] | def kNN_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
scores_u = []
scores_d = []
k_range = range(20, 71)
for k in k_range:
for weight in ['uniform', 'distance']:
score = get_cv_score(X_train, y_train, KNeighborsClassifier,
... | [
"def",
"kNN_model",
"(",
"X_train",
":",
"pd",
".",
"DataFrame",
",",
"X_test",
":",
"pd",
".",
"DataFrame",
",",
"y_train",
":",
"pd",
".",
"Series",
",",
"y_test",
":",
"pd",
".",
"Series",
")",
":",
"scores_u",
"=",
"[",
"]",
"scores_d",
"=",
"[... | K-nearest neighbors model: find best hyperparameter k and weight method. | [
"K",
"-",
"nearest",
"neighbors",
"model",
":",
"find",
"best",
"hyperparameter",
"k",
"and",
"weight",
"method",
"."
] | [
"\"\"\"\n K-nearest neighbors model: find best hyperparameter k and weight method.\n Then fit to (unscaled) data and predict.\n\n :parameter X_train: Training data.\n :parameter y_train: Target that corresponds to training data.\n :parameter X_test: Test data.\n :parameter y_test: Target that corr... | [
{
"param": "X_train",
"type": "pd.DataFrame"
},
{
"param": "X_test",
"type": "pd.DataFrame"
},
{
"param": "y_train",
"type": "pd.Series"
},
{
"param": "y_test",
"type": "pd.Series"
}
] | {
"returns": [
{
"docstring": "Model object, model predictions for test dataset, and classification report (dict).",
"docstring_tokens": [
"Model",
"object",
"model",
"predictions",
"for",
"test",
"dataset",
"and",
"classification... |
b5f290930619da65a9f0c862928be2485634a9ae | alexplaka/ML | CardiovascularDisease/CVD/ML_models.py | [
"MIT"
] | Python | RF_model | <not_specific> | def RF_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
"""
Random Forest model model: find best hyperparameters.
Then fit to data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to training data.
:parameter X... |
Random Forest model model: find best hyperparameters.
Then fit to data and predict.
:parameter X_train: Training data.
:parameter y_train: Target that corresponds to training data.
:parameter X_test: Test data.
:parameter y_test: Target that corresponds to test data.
:return: Model object,... | Random Forest model model: find best hyperparameters.
Then fit to data and predict. | [
"Random",
"Forest",
"model",
"model",
":",
"find",
"best",
"hyperparameters",
".",
"Then",
"fit",
"to",
"data",
"and",
"predict",
"."
] | def RF_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
clf = RandomForestClassifier(random_state=0)
hyperparams = {"max_features": ["auto"],
"max_leaf_nodes": [None],
"max_depth": [9]}
cv = 10
model = GridSearchCV(clf, hype... | [
"def",
"RF_model",
"(",
"X_train",
":",
"pd",
".",
"DataFrame",
",",
"X_test",
":",
"pd",
".",
"DataFrame",
",",
"y_train",
":",
"pd",
".",
"Series",
",",
"y_test",
":",
"pd",
".",
"Series",
")",
":",
"clf",
"=",
"RandomForestClassifier",
"(",
"random_... | Random Forest model model: find best hyperparameters. | [
"Random",
"Forest",
"model",
"model",
":",
"find",
"best",
"hyperparameters",
"."
] | [
"\"\"\"\n Random Forest model model: find best hyperparameters.\n Then fit to data and predict.\n\n :parameter X_train: Training data.\n :parameter y_train: Target that corresponds to training data.\n :parameter X_test: Test data.\n :parameter y_test: Target that corresponds to test data.\n :re... | [
{
"param": "X_train",
"type": "pd.DataFrame"
},
{
"param": "X_test",
"type": "pd.DataFrame"
},
{
"param": "y_train",
"type": "pd.Series"
},
{
"param": "y_test",
"type": "pd.Series"
}
] | {
"returns": [
{
"docstring": "Model object, model predictions for test dataset, and classification report (dict).",
"docstring_tokens": [
"Model",
"object",
"model",
"predictions",
"for",
"test",
"dataset",
"and",
"classification... |
b5f290930619da65a9f0c862928be2485634a9ae | alexplaka/ML | CardiovascularDisease/CVD/ML_models.py | [
"MIT"
] | Python | group_model | <not_specific> | def group_model(X_test: pd.DataFrame, X_test_scaled: pd.DataFrame, y_test: pd.Series, models: list, *, weights=None):
"""
Creating a group/ensemble model of all of the fitted models.
Note: The below manipulations are equivalent to using sklearn.ensemble.VotingClassifier()
on the unfitted models with 's... |
Creating a group/ensemble model of all of the fitted models.
Note: The below manipulations are equivalent to using sklearn.ensemble.VotingClassifier()
on the unfitted models with 'soft' voting. Since we have already fit the models,
calculating the average class probabilities manually.
:parameter ... | Creating a group/ensemble model of all of the fitted models.
Note: The below manipulations are equivalent to using sklearn.ensemble.VotingClassifier()
on the unfitted models with 'soft' voting. Since we have already fit the models,
calculating the average class probabilities manually. | [
"Creating",
"a",
"group",
"/",
"ensemble",
"model",
"of",
"all",
"of",
"the",
"fitted",
"models",
".",
"Note",
":",
"The",
"below",
"manipulations",
"are",
"equivalent",
"to",
"using",
"sklearn",
".",
"ensemble",
".",
"VotingClassifier",
"()",
"on",
"the",
... | def group_model(X_test: pd.DataFrame, X_test_scaled: pd.DataFrame, y_test: pd.Series, models: list, *, weights=None):
n = len(models)
wgts = np.ones(n) / n if weights is None else weights
p_weighted_vals = np.empty((X_test.shape[0], 2, n))
for i, model in enumerate(models):
print(model)
... | [
"def",
"group_model",
"(",
"X_test",
":",
"pd",
".",
"DataFrame",
",",
"X_test_scaled",
":",
"pd",
".",
"DataFrame",
",",
"y_test",
":",
"pd",
".",
"Series",
",",
"models",
":",
"list",
",",
"*",
",",
"weights",
"=",
"None",
")",
":",
"n",
"=",
"le... | Creating a group/ensemble model of all of the fitted models. | [
"Creating",
"a",
"group",
"/",
"ensemble",
"model",
"of",
"all",
"of",
"the",
"fitted",
"models",
"."
] | [
"\"\"\"\n Creating a group/ensemble model of all of the fitted models.\n\n Note: The below manipulations are equivalent to using sklearn.ensemble.VotingClassifier()\n on the unfitted models with 'soft' voting. Since we have already fit the models,\n calculating the average class probabilities manually.\... | [
{
"param": "X_test",
"type": "pd.DataFrame"
},
{
"param": "X_test_scaled",
"type": "pd.DataFrame"
},
{
"param": "y_test",
"type": "pd.Series"
},
{
"param": "models",
"type": "list"
},
{
"param": "weights",
"type": null
}
] | {
"returns": [
{
"docstring": "Group model predictions for test dataset and classification report (dict).",
"docstring_tokens": [
"Group",
"model",
"predictions",
"for",
"test",
"dataset",
"and",
"classification",
"report",
... |
f4ec6090648746cd652464added6ec2558c19c3e | alexplaka/ML | CardiovascularDisease/CVD/postprocessor.py | [
"MIT"
] | Python | find_mislabels | <not_specific> | def find_mislabels(y_test, model_preds):
"""
Find all mislabels given the predictions of a given estimator/model.
Find the false positive and negatives.
RETURN: list of indices of all mislabeled, false positive, and false negative samples
"""
y_pred = pd.Series(model_preds, index=y_test.index)... |
Find all mislabels given the predictions of a given estimator/model.
Find the false positive and negatives.
RETURN: list of indices of all mislabeled, false positive, and false negative samples
| Find all mislabels given the predictions of a given estimator/model.
Find the false positive and negatives.
RETURN: list of indices of all mislabeled, false positive, and false negative samples | [
"Find",
"all",
"mislabels",
"given",
"the",
"predictions",
"of",
"a",
"given",
"estimator",
"/",
"model",
".",
"Find",
"the",
"false",
"positive",
"and",
"negatives",
".",
"RETURN",
":",
"list",
"of",
"indices",
"of",
"all",
"mislabeled",
"false",
"positive"... | def find_mislabels(y_test, model_preds):
y_pred = pd.Series(model_preds, index=y_test.index)
diffs = y_pred - y_test
mislabels = diffs[diffs != 0]
fp = mislabels[mislabels == 1]
fn = mislabels[mislabels == -1]
return list(mislabels.index), list(fp.index), list(fn.index) | [
"def",
"find_mislabels",
"(",
"y_test",
",",
"model_preds",
")",
":",
"y_pred",
"=",
"pd",
".",
"Series",
"(",
"model_preds",
",",
"index",
"=",
"y_test",
".",
"index",
")",
"diffs",
"=",
"y_pred",
"-",
"y_test",
"mislabels",
"=",
"diffs",
"[",
"diffs",
... | Find all mislabels given the predictions of a given estimator/model. | [
"Find",
"all",
"mislabels",
"given",
"the",
"predictions",
"of",
"a",
"given",
"estimator",
"/",
"model",
"."
] | [
"\"\"\"\n Find all mislabels given the predictions of a given estimator/model.\n Find the false positive and negatives.\n RETURN: list of indices of all mislabeled, false positive, and false negative samples\n\n \"\"\"",
"# All mislabeled samples",
"# False positives",
"# False negatives"
] | [
{
"param": "y_test",
"type": null
},
{
"param": "model_preds",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "y_test",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_preds",
"type": null,
"docstring": null,
"docstring_t... |
f4ec6090648746cd652464added6ec2558c19c3e | alexplaka/ML | CardiovascularDisease/CVD/postprocessor.py | [
"MIT"
] | Python | find_common_mislabels | <not_specific> | def find_common_mislabels(*args):
"""
Find mislabeled predictions that are common to several estimators/models.
Note: This function can be used generally to find common entries in iterables
by converting them to sets and finding their intersections.
"""
common = set()
for i in range(len(a... |
Find mislabeled predictions that are common to several estimators/models.
Note: This function can be used generally to find common entries in iterables
by converting them to sets and finding their intersections.
| Find mislabeled predictions that are common to several estimators/models.
Note: This function can be used generally to find common entries in iterables
by converting them to sets and finding their intersections. | [
"Find",
"mislabeled",
"predictions",
"that",
"are",
"common",
"to",
"several",
"estimators",
"/",
"models",
".",
"Note",
":",
"This",
"function",
"can",
"be",
"used",
"generally",
"to",
"find",
"common",
"entries",
"in",
"iterables",
"by",
"converting",
"them"... | def find_common_mislabels(*args):
common = set()
for i in range(len(args) - 1):
common.update(set(args[i]).intersection(set(args[i + 1])))
return common | [
"def",
"find_common_mislabels",
"(",
"*",
"args",
")",
":",
"common",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"args",
")",
"-",
"1",
")",
":",
"common",
".",
"update",
"(",
"set",
"(",
"args",
"[",
"i",
"]",
")",
".",
... | Find mislabeled predictions that are common to several estimators/models. | [
"Find",
"mislabeled",
"predictions",
"that",
"are",
"common",
"to",
"several",
"estimators",
"/",
"models",
"."
] | [
"\"\"\"\n Find mislabeled predictions that are common to several estimators/models.\n\n Note: This function can be used generally to find common entries in iterables\n by converting them to sets and finding their intersections.\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f4ec6090648746cd652464added6ec2558c19c3e | alexplaka/ML | CardiovascularDisease/CVD/postprocessor.py | [
"MIT"
] | Python | model_group_mislabels | <not_specific> | def model_group_mislabels(y_test, *preds):
"""
Find the intersection of the set of all mislabels, false positives, and false negatives
from a group or collection of estimators/models.
PARAMETER preds: arrays/lists containing the predictions of the estimators/models.
"""
mislabels, fp, fn = [],... |
Find the intersection of the set of all mislabels, false positives, and false negatives
from a group or collection of estimators/models.
PARAMETER preds: arrays/lists containing the predictions of the estimators/models.
| Find the intersection of the set of all mislabels, false positives, and false negatives
from a group or collection of estimators/models.
PARAMETER preds: arrays/lists containing the predictions of the estimators/models. | [
"Find",
"the",
"intersection",
"of",
"the",
"set",
"of",
"all",
"mislabels",
"false",
"positives",
"and",
"false",
"negatives",
"from",
"a",
"group",
"or",
"collection",
"of",
"estimators",
"/",
"models",
".",
"PARAMETER",
"preds",
":",
"arrays",
"/",
"lists... | def model_group_mislabels(y_test, *preds):
mislabels, fp, fn = [], [], []
for pred in preds:
m, p, n = find_mislabels(y_test, pred)
mislabels.append(m)
fp.append(p)
fn.append(n)
common_mislabels = find_common_mislabels(*mislabels)
common_fp = find_common_mislabels(*fp)
... | [
"def",
"model_group_mislabels",
"(",
"y_test",
",",
"*",
"preds",
")",
":",
"mislabels",
",",
"fp",
",",
"fn",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"for",
"pred",
"in",
"preds",
":",
"m",
",",
"p",
",",
"n",
"=",
"find_mislabels",
"(",
... | Find the intersection of the set of all mislabels, false positives, and false negatives
from a group or collection of estimators/models. | [
"Find",
"the",
"intersection",
"of",
"the",
"set",
"of",
"all",
"mislabels",
"false",
"positives",
"and",
"false",
"negatives",
"from",
"a",
"group",
"or",
"collection",
"of",
"estimators",
"/",
"models",
"."
] | [
"\"\"\"\n Find the intersection of the set of all mislabels, false positives, and false negatives\n from a group or collection of estimators/models.\n\n PARAMETER preds: arrays/lists containing the predictions of the estimators/models.\n \"\"\""
] | [
{
"param": "y_test",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "y_test",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4017e4de6f5c06a8498f45b5415561b67f0357f1 | alexplaka/ML | CardiovascularDisease/CVD/preprocessor.py | [
"MIT"
] | Python | cleanup | <not_specific> | def cleanup(df: pd.DataFrame):
"""
- Change "Age" from days to years.
- Make "Gender" values start from 0.
- Normalize data by making 0 always good and 1 always bad.
- Remove wrong data or outliers.
:parameter df: pandas dataframe containing all of the data
:return: cleaned dataframe
""... |
- Change "Age" from days to years.
- Make "Gender" values start from 0.
- Normalize data by making 0 always good and 1 always bad.
- Remove wrong data or outliers.
:parameter df: pandas dataframe containing all of the data
:return: cleaned dataframe
| Change "Age" from days to years.
Make "Gender" values start from 0.
Normalize data by making 0 always good and 1 always bad.
Remove wrong data or outliers. | [
"Change",
"\"",
"Age",
"\"",
"from",
"days",
"to",
"years",
".",
"Make",
"\"",
"Gender",
"\"",
"values",
"start",
"from",
"0",
".",
"Normalize",
"data",
"by",
"making",
"0",
"always",
"good",
"and",
"1",
"always",
"bad",
".",
"Remove",
"wrong",
"data",... | def cleanup(df: pd.DataFrame):
df["Age"] = df["Age"] / 365
df["Gender"] = df["Gender"] - 1
for feat in ["Glucose", "Cholesterol"]:
df[feat] = df[feat].apply(lambda x: 0 if x == 1 else 1)
df = df[(df.BP_lo < df.BP_hi) &
(df.BP_lo.between(50, 120)) &
(df.BP_hi.between(1... | [
"def",
"cleanup",
"(",
"df",
":",
"pd",
".",
"DataFrame",
")",
":",
"df",
"[",
"\"Age\"",
"]",
"=",
"df",
"[",
"\"Age\"",
"]",
"/",
"365",
"df",
"[",
"\"Gender\"",
"]",
"=",
"df",
"[",
"\"Gender\"",
"]",
"-",
"1",
"for",
"feat",
"in",
"[",
"\"G... | Change "Age" from days to years. | [
"Change",
"\"",
"Age",
"\"",
"from",
"days",
"to",
"years",
"."
] | [
"\"\"\"\n - Change \"Age\" from days to years.\n - Make \"Gender\" values start from 0.\n - Normalize data by making 0 always good and 1 always bad.\n - Remove wrong data or outliers.\n\n :parameter df: pandas dataframe containing all of the data\n :return: cleaned dataframe\n \"\"\"",
"# If ... | [
{
"param": "df",
"type": "pd.DataFrame"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": "pandas dataframe containing all of the data",
"docstring_tokens": [
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.