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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
72dc36202a8374c586aacb7d2cbe9279f63b2378 | junqueira/aztk | aztk/spark/client/cluster/operations.py | [
"MIT"
] | Python | copy | <not_specific> | def copy(
self,
id: str,
source_path: str,
destination_path: str,
host: bool = False,
internal: bool = False,
timeout: int = None,
):
"""Copy a file to every node in a cluster.
Args:
id (:obj:`str`): the... | Copy a file to every node in a cluster.
Args:
id (:obj:`str`): the id of the cluster to copy files with.
source_path (:obj:`str`): the local path of the file to copy.
destination_path (:obj:`str`, optional): the path on each node the file is copied to.
container_... | Copy a file to every node in a cluster. | [
"Copy",
"a",
"file",
"to",
"every",
"node",
"in",
"a",
"cluster",
"."
] | def copy(
self,
id: str,
source_path: str,
destination_path: str,
host: bool = False,
internal: bool = False,
timeout: int = None,
):
return copy.cluster_copy(self._core_cluster_operations, id, source_path, destination_path,... | [
"def",
"copy",
"(",
"self",
",",
"id",
":",
"str",
",",
"source_path",
":",
"str",
",",
"destination_path",
":",
"str",
",",
"host",
":",
"bool",
"=",
"False",
",",
"internal",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
"=",
"None",
","... | Copy a file to every node in a cluster. | [
"Copy",
"a",
"file",
"to",
"every",
"node",
"in",
"a",
"cluster",
"."
] | [
"\"\"\"Copy a file to every node in a cluster.\n\n Args:\n id (:obj:`str`): the id of the cluster to copy files with.\n source_path (:obj:`str`): the local path of the file to copy.\n destination_path (:obj:`str`, optional): the path on each node the file is copied to.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": "str"
},
{
"param": "source_path",
"type": "str"
},
{
"param": "destination_path",
"type": "str"
},
{
"param": "host",
"type": "bool"
},
{
"param": "internal",
"type": "bool"
},
{
... | {
"returns": [
{
"docstring": ":obj:`List[aztk.spark.models.NodeOutput]`:\nA list of NodeOutput objects representing the output of the copy command.",
"docstring_tokens": [
":",
"obj",
":",
"`",
"List",
"[",
"aztk",
".",
"spark",
... |
72dc36202a8374c586aacb7d2cbe9279f63b2378 | junqueira/aztk | aztk/spark/client/cluster/operations.py | [
"MIT"
] | Python | download | <not_specific> | def download(
self,
id: str,
source_path: str,
destination_path: str = None,
host: bool = False,
internal: bool = False,
timeout: int = None,
):
"""Download a file from every node in a cluster.
Args:
id ... | Download a file from every node in a cluster.
Args:
id (:obj:`str`): the id of the cluster to copy files with.
source_path (:obj:`str`): the path of the file to copy from.
destination_path (:obj:`str`, optional): the local directory path where the output should be written.
... | Download a file from every node in a cluster. | [
"Download",
"a",
"file",
"from",
"every",
"node",
"in",
"a",
"cluster",
"."
] | def download(
self,
id: str,
source_path: str,
destination_path: str = None,
host: bool = False,
internal: bool = False,
timeout: int = None,
):
return download.cluster_download(self._core_cluster_operations, id, source_path... | [
"def",
"download",
"(",
"self",
",",
"id",
":",
"str",
",",
"source_path",
":",
"str",
",",
"destination_path",
":",
"str",
"=",
"None",
",",
"host",
":",
"bool",
"=",
"False",
",",
"internal",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
... | Download a file from every node in a cluster. | [
"Download",
"a",
"file",
"from",
"every",
"node",
"in",
"a",
"cluster",
"."
] | [
"\"\"\"Download a file from every node in a cluster.\n\n Args:\n id (:obj:`str`): the id of the cluster to copy files with.\n source_path (:obj:`str`): the path of the file to copy from.\n destination_path (:obj:`str`, optional): the local directory path where the output shou... | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": "str"
},
{
"param": "source_path",
"type": "str"
},
{
"param": "destination_path",
"type": "str"
},
{
"param": "host",
"type": "bool"
},
{
"param": "internal",
"type": "bool"
},
{
... | {
"returns": [
{
"docstring": ":obj:`List[aztk.spark.models.NodeOutput]`:\nA list of NodeOutput objects representing the output of the copy command.",
"docstring_tokens": [
":",
"obj",
":",
"`",
"List",
"[",
"aztk",
".",
"spark",
... |
72dc36202a8374c586aacb7d2cbe9279f63b2378 | junqueira/aztk | aztk/spark/client/cluster/operations.py | [
"MIT"
] | Python | wait | <not_specific> | def wait(self, id: str, application_name: str):
"""Wait until the application has completed
Args:
id (:obj:`str`): the id of the cluster the application was submitted to
application_name (:obj:`str`): the name of the application to wait for
Returns:
:obj:`No... | Wait until the application has completed
Args:
id (:obj:`str`): the id of the cluster the application was submitted to
application_name (:obj:`str`): the name of the application to wait for
Returns:
:obj:`None`
| Wait until the application has completed | [
"Wait",
"until",
"the",
"application",
"has",
"completed"
] | def wait(self, id: str, application_name: str):
return wait.wait_for_application_to_complete(self._core_cluster_operations, id, application_name) | [
"def",
"wait",
"(",
"self",
",",
"id",
":",
"str",
",",
"application_name",
":",
"str",
")",
":",
"return",
"wait",
".",
"wait_for_application_to_complete",
"(",
"self",
".",
"_core_cluster_operations",
",",
"id",
",",
"application_name",
")"
] | Wait until the application has completed | [
"Wait",
"until",
"the",
"application",
"has",
"completed"
] | [
"\"\"\"Wait until the application has completed\n\n Args:\n id (:obj:`str`): the id of the cluster the application was submitted to\n application_name (:obj:`str`): the name of the application to wait for\n\n Returns:\n :obj:`None`\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": "str"
},
{
"param": "application_name",
"type": "str"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
72dc36202a8374c586aacb7d2cbe9279f63b2378 | junqueira/aztk | aztk/spark/client/cluster/operations.py | [
"MIT"
] | Python | ssh_into_master | <not_specific> | def ssh_into_master(self, id, username, ssh_key=None, password=None, port_forward_list=None, internal=False):
"""Open an SSH tunnel to the Spark master node and forward the specified ports
Args:
id (:obj:`str`): the id of the cluster
username (:obj:`str`): the name of the user t... | Open an SSH tunnel to the Spark master node and forward the specified ports
Args:
id (:obj:`str`): the id of the cluster
username (:obj:`str`): the name of the user to open the ssh session with
ssh_key (:obj:`str`, optional): the ssh_key to authenticate the ssh user with.
... | Open an SSH tunnel to the Spark master node and forward the specified ports | [
"Open",
"an",
"SSH",
"tunnel",
"to",
"the",
"Spark",
"master",
"node",
"and",
"forward",
"the",
"specified",
"ports"
] | def ssh_into_master(self, id, username, ssh_key=None, password=None, port_forward_list=None, internal=False):
return ssh_into_master.ssh_into_master(self, self._core_cluster_operations, id, username, ssh_key, password,
port_forward_list, internal) | [
"def",
"ssh_into_master",
"(",
"self",
",",
"id",
",",
"username",
",",
"ssh_key",
"=",
"None",
",",
"password",
"=",
"None",
",",
"port_forward_list",
"=",
"None",
",",
"internal",
"=",
"False",
")",
":",
"return",
"ssh_into_master",
".",
"ssh_into_master",... | Open an SSH tunnel to the Spark master node and forward the specified ports | [
"Open",
"an",
"SSH",
"tunnel",
"to",
"the",
"Spark",
"master",
"node",
"and",
"forward",
"the",
"specified",
"ports"
] | [
"\"\"\"Open an SSH tunnel to the Spark master node and forward the specified ports\n\n Args:\n id (:obj:`str`): the id of the cluster\n username (:obj:`str`): the name of the user to open the ssh session with\n ssh_key (:obj:`str`, optional): the ssh_key to authenticate the s... | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
},
{
"param": "username",
"type": null
},
{
"param": "ssh_key",
"type": null
},
{
"param": "password",
"type": null
},
{
"param": "port_forward_list",
"type": null
},
{
"param... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
b992f2b0531f3ed953bff03a2b8e588c2f7fb9b3 | junqueira/aztk | aztk/client/base/helpers/get_application_log.py | [
"MIT"
] | Python | __wait_for_app_to_be_running | Task | def __wait_for_app_to_be_running(base_operations, cluster_id: str, application_name: str) -> Task:
"""
Wait for the batch task to leave the waiting state into running(or completed if it was fast enough)
"""
while True:
task_state = base_operations.get_task_state(cluster_id, application_name... |
Wait for the batch task to leave the waiting state into running(or completed if it was fast enough)
| Wait for the batch task to leave the waiting state into running(or completed if it was fast enough) | [
"Wait",
"for",
"the",
"batch",
"task",
"to",
"leave",
"the",
"waiting",
"state",
"into",
"running",
"(",
"or",
"completed",
"if",
"it",
"was",
"fast",
"enough",
")"
] | def __wait_for_app_to_be_running(base_operations, cluster_id: str, application_name: str) -> Task:
while True:
task_state = base_operations.get_task_state(cluster_id, application_name)
if task_state in [batch_models.TaskState.active, batch_models.TaskState.preparing]:
time.sleep(5)
... | [
"def",
"__wait_for_app_to_be_running",
"(",
"base_operations",
",",
"cluster_id",
":",
"str",
",",
"application_name",
":",
"str",
")",
"->",
"Task",
":",
"while",
"True",
":",
"task_state",
"=",
"base_operations",
".",
"get_task_state",
"(",
"cluster_id",
",",
... | Wait for the batch task to leave the waiting state into running(or completed if it was fast enough) | [
"Wait",
"for",
"the",
"batch",
"task",
"to",
"leave",
"the",
"waiting",
"state",
"into",
"running",
"(",
"or",
"completed",
"if",
"it",
"was",
"fast",
"enough",
")"
] | [
"\"\"\"\n Wait for the batch task to leave the waiting state into running(or completed if it was fast enough)\n \"\"\"",
"# TODO: log"
] | [
{
"param": "base_operations",
"type": null
},
{
"param": "cluster_id",
"type": "str"
},
{
"param": "application_name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_operations",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cluster_id",
"type": "str",
"docstring": null,
"do... |
a1ad2ff0ea7a8d62f4989bd75e22ddfb8bd71c9e | junqueira/aztk | aztk/node_scripts/install/spark.py | [
"MIT"
] | Python | list_nodes | List[batchmodels.ComputeNode] | def list_nodes() -> List[batchmodels.ComputeNode]:
"""
List all the nodes in the pool.
"""
# TODO use continuation token & verify against current/target dedicated of
# pool
return batch_client.compute_node.list(config.pool_id) |
List all the nodes in the pool.
| List all the nodes in the pool. | [
"List",
"all",
"the",
"nodes",
"in",
"the",
"pool",
"."
] | def list_nodes() -> List[batchmodels.ComputeNode]:
return batch_client.compute_node.list(config.pool_id) | [
"def",
"list_nodes",
"(",
")",
"->",
"List",
"[",
"batchmodels",
".",
"ComputeNode",
"]",
":",
"return",
"batch_client",
".",
"compute_node",
".",
"list",
"(",
"config",
".",
"pool_id",
")"
] | List all the nodes in the pool. | [
"List",
"all",
"the",
"nodes",
"in",
"the",
"pool",
"."
] | [
"\"\"\"\n List all the nodes in the pool.\n \"\"\"",
"# TODO use continuation token & verify against current/target dedicated of",
"# pool"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c6e24c09e5ff32a53276efc4f3992fe8aade2ff7 | junqueira/aztk | aztk/node_scripts/scheduling/job_submission.py | [
"MIT"
] | Python | schedule_tasks | null | def schedule_tasks(tasks):
"""
Handle the request to submit a task
"""
batch_client = config.batch_client
for task in tasks:
# affinitize task to master
task = affinitize_task_to_master(batch_client, os.environ["AZ_BATCH_POOL_ID"], task)
# schedule the task
batch... |
Handle the request to submit a task
| Handle the request to submit a task | [
"Handle",
"the",
"request",
"to",
"submit",
"a",
"task"
] | def schedule_tasks(tasks):
batch_client = config.batch_client
for task in tasks:
task = affinitize_task_to_master(batch_client, os.environ["AZ_BATCH_POOL_ID"], task)
batch_client.task.add(job_id=os.environ["AZ_BATCH_JOB_ID"], task=task) | [
"def",
"schedule_tasks",
"(",
"tasks",
")",
":",
"batch_client",
"=",
"config",
".",
"batch_client",
"for",
"task",
"in",
"tasks",
":",
"task",
"=",
"affinitize_task_to_master",
"(",
"batch_client",
",",
"os",
".",
"environ",
"[",
"\"AZ_BATCH_POOL_ID\"",
"]",
... | Handle the request to submit a task | [
"Handle",
"the",
"request",
"to",
"submit",
"a",
"task"
] | [
"\"\"\"\n Handle the request to submit a task\n \"\"\"",
"# affinitize task to master",
"# schedule the task"
] | [
{
"param": "tasks",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tasks",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2aacbe421a985fcd6cddd84ecc787d5b5bd04b73 | junqueira/aztk | account_setup.py | [
"MIT"
] | Python | create_aad_user | <not_specific> | def create_aad_user(credentials, tenant_id, **kwargs):
"""
Create an AAD application and service principal
:param credentials: msrestazure.azure_active_directory.AdalAuthentication
:param tenant_id: str
:param **application_name: str
"""
graph_rbac_client = GraphRbacManagemen... |
Create an AAD application and service principal
:param credentials: msrestazure.azure_active_directory.AdalAuthentication
:param tenant_id: str
:param **application_name: str
| Create an AAD application and service principal | [
"Create",
"an",
"AAD",
"application",
"and",
"service",
"principal"
] | def create_aad_user(credentials, tenant_id, **kwargs):
graph_rbac_client = GraphRbacManagementClient(
credentials, tenant_id, base_url=AZURE_PUBLIC_CLOUD.endpoints.active_directory_graph_resource_id)
application_credential = uuid.uuid4()
try:
display_name = kwargs.get("application_name", Def... | [
"def",
"create_aad_user",
"(",
"credentials",
",",
"tenant_id",
",",
"**",
"kwargs",
")",
":",
"graph_rbac_client",
"=",
"GraphRbacManagementClient",
"(",
"credentials",
",",
"tenant_id",
",",
"base_url",
"=",
"AZURE_PUBLIC_CLOUD",
".",
"endpoints",
".",
"active_dir... | Create an AAD application and service principal | [
"Create",
"an",
"AAD",
"application",
"and",
"service",
"principal"
] | [
"\"\"\"\n Create an AAD application and service principal\n :param credentials: msrestazure.azure_active_directory.AdalAuthentication\n :param tenant_id: str\n :param **application_name: str\n \"\"\""
] | [
{
"param": "credentials",
"type": null
},
{
"param": "tenant_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "credentials",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
},
{
"identifier": "tenant_id",
"type": null,
"docstring":... |
2aacbe421a985fcd6cddd84ecc787d5b5bd04b73 | junqueira/aztk | account_setup.py | [
"MIT"
] | Python | create_role_assignment | null | def create_role_assignment(credentials, subscription_id, scope, principal_id):
"""
Gives service principal contributor role authorization on scope
:param credentials: msrestazure.azure_active_directory.AdalAuthentication
:param subscription_id: str
:param scope: str
:param pr... |
Gives service principal contributor role authorization on scope
:param credentials: msrestazure.azure_active_directory.AdalAuthentication
:param subscription_id: str
:param scope: str
:param principal_id: str
| Gives service principal contributor role authorization on scope | [
"Gives",
"service",
"principal",
"contributor",
"role",
"authorization",
"on",
"scope"
] | def create_role_assignment(credentials, subscription_id, scope, principal_id):
authorization_client = AuthorizationManagementClient(credentials, subscription_id)
role_name = 'Contributor'
roles = list(authorization_client.role_definitions.list(scope, filter="roleName eq '{}'".format(role_name)))
contrib... | [
"def",
"create_role_assignment",
"(",
"credentials",
",",
"subscription_id",
",",
"scope",
",",
"principal_id",
")",
":",
"authorization_client",
"=",
"AuthorizationManagementClient",
"(",
"credentials",
",",
"subscription_id",
")",
"role_name",
"=",
"'Contributor'",
"r... | Gives service principal contributor role authorization on scope | [
"Gives",
"service",
"principal",
"contributor",
"role",
"authorization",
"on",
"scope"
] | [
"\"\"\"\n Gives service principal contributor role authorization on scope\n :param credentials: msrestazure.azure_active_directory.AdalAuthentication\n :param subscription_id: str\n :param scope: str\n :param principal_id: str\n \"\"\"",
"# ignore error if service principal h... | [
{
"param": "credentials",
"type": null
},
{
"param": "subscription_id",
"type": null
},
{
"param": "scope",
"type": null
},
{
"param": "principal_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "credentials",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
},
{
"identifier": "subscription_id",
"type": null,
"docst... |
2aacbe421a985fcd6cddd84ecc787d5b5bd04b73 | junqueira/aztk | account_setup.py | [
"MIT"
] | Python | format_secrets | <not_specific> | def format_secrets(**kwargs):
'''
Returns the secrets for the created resources to be placed in secrets.yaml
The following form is returned:
service_principal:
tenant_id: <AAD Directory ID>
client_id: <AAD App Application ID>
credential: <AAD App Password>
... |
Returns the secrets for the created resources to be placed in secrets.yaml
The following form is returned:
service_principal:
tenant_id: <AAD Directory ID>
client_id: <AAD App Application ID>
credential: <AAD App Password>
batch_account_resource_id: </ba... | Returns the secrets for the created resources to be placed in secrets.yaml
The following form is returned.
| [
"Returns",
"the",
"secrets",
"for",
"the",
"created",
"resources",
"to",
"be",
"placed",
"in",
"secrets",
".",
"yaml",
"The",
"following",
"form",
"is",
"returned",
"."
] | def format_secrets(**kwargs):
return yaml.dump({"service_principal": kwargs}, default_flow_style=False) | [
"def",
"format_secrets",
"(",
"**",
"kwargs",
")",
":",
"return",
"yaml",
".",
"dump",
"(",
"{",
"\"service_principal\"",
":",
"kwargs",
"}",
",",
"default_flow_style",
"=",
"False",
")"
] | Returns the secrets for the created resources to be placed in secrets.yaml
The following form is returned: | [
"Returns",
"the",
"secrets",
"for",
"the",
"created",
"resources",
"to",
"be",
"placed",
"in",
"secrets",
".",
"yaml",
"The",
"following",
"form",
"is",
"returned",
":"
] | [
"'''\n Returns the secrets for the created resources to be placed in secrets.yaml\n The following form is returned:\n\n service_principal:\n tenant_id: <AAD Directory ID>\n client_id: <AAD App Application ID>\n credential: <AAD App Password>\n batch_account_r... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d996453c59720d7f813a4f7ca754a0c570fe91d5 | junqueira/aztk | aztk/client/cluster/helpers/delete.py | [
"MIT"
] | Python | delete_pool_and_job_and_table | <not_specific> | def delete_pool_and_job_and_table(core_cluster_operations, pool_id: str, keep_logs: bool = False):
"""
Delete a pool and it's associated job
:param cluster_id: the pool to add the user to
:return bool: deleted the pool if exists and job if exists
"""
# job id is equal to pool id
... |
Delete a pool and it's associated job
:param cluster_id: the pool to add the user to
:return bool: deleted the pool if exists and job if exists
| Delete a pool and it's associated job | [
"Delete",
"a",
"pool",
"and",
"it",
"'",
"s",
"associated",
"job"
] | def delete_pool_and_job_and_table(core_cluster_operations, pool_id: str, keep_logs: bool = False):
job_exists = True
try:
core_cluster_operations.batch_client.job.get(pool_id)
except BatchErrorException:
job_exists = False
pool_exists = core_cluster_operations.batch_client.pool.exists(po... | [
"def",
"delete_pool_and_job_and_table",
"(",
"core_cluster_operations",
",",
"pool_id",
":",
"str",
",",
"keep_logs",
":",
"bool",
"=",
"False",
")",
":",
"job_exists",
"=",
"True",
"try",
":",
"core_cluster_operations",
".",
"batch_client",
".",
"job",
".",
"ge... | Delete a pool and it's associated job | [
"Delete",
"a",
"pool",
"and",
"it",
"'",
"s",
"associated",
"job"
] | [
"\"\"\"\n Delete a pool and it's associated job\n :param cluster_id: the pool to add the user to\n :return bool: deleted the pool if exists and job if exists\n \"\"\"",
"# job id is equal to pool id"
] | [
{
"param": "core_cluster_operations",
"type": null
},
{
"param": "pool_id",
"type": "str"
},
{
"param": "keep_logs",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "deleted the pool if exists and job if exists",
"docstring_tokens": [
"deleted",
"the",
"pool",
"if",
"exists",
"and",
"job",
"if",
"exists"
],
"type": "bool"
}
],
"raises": [],
... |
ad88e8d3481160bbfd0f202743cf9ce9bbbc7c86 | junqueira/aztk | aztk/internal/docker_cmd.py | [
"MIT"
] | Python | pass_env | null | def pass_env(self, env: str):
"""
Give the value of an environment variable in the main process to the docker image
"""
self.cmd.add_option("-e", "{0}".format(env)) |
Give the value of an environment variable in the main process to the docker image
| Give the value of an environment variable in the main process to the docker image | [
"Give",
"the",
"value",
"of",
"an",
"environment",
"variable",
"in",
"the",
"main",
"process",
"to",
"the",
"docker",
"image"
] | def pass_env(self, env: str):
self.cmd.add_option("-e", "{0}".format(env)) | [
"def",
"pass_env",
"(",
"self",
",",
"env",
":",
"str",
")",
":",
"self",
".",
"cmd",
".",
"add_option",
"(",
"\"-e\"",
",",
"\"{0}\"",
".",
"format",
"(",
"env",
")",
")"
] | Give the value of an environment variable in the main process to the docker image | [
"Give",
"the",
"value",
"of",
"an",
"environment",
"variable",
"in",
"the",
"main",
"process",
"to",
"the",
"docker",
"image"
] | [
"\"\"\"\n Give the value of an environment variable in the main process to the docker image\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "env",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "env",
"type": "str",
"docstring": null,
"docstring_tokens": [... |
a02f9a13c35dc4e951475619647d6516209223ce | junqueira/aztk | aztk/node_scripts/install/pick_master.py | [
"MIT"
] | Python | find_master | bool | def find_master(client: batch.BatchServiceClient) -> bool:
"""
Try to set a master for the cluster. If the node is dedicated it will try to assign itself if none already claimed it.
:returns bool: If the node is the master it returns true otherwise returns false
"""
# If not dedicated the no... |
Try to set a master for the cluster. If the node is dedicated it will try to assign itself if none already claimed it.
:returns bool: If the node is the master it returns true otherwise returns false
| Try to set a master for the cluster. If the node is dedicated it will try to assign itself if none already claimed it. | [
"Try",
"to",
"set",
"a",
"master",
"for",
"the",
"cluster",
".",
"If",
"the",
"node",
"is",
"dedicated",
"it",
"will",
"try",
"to",
"assign",
"itself",
"if",
"none",
"already",
"claimed",
"it",
"."
] | def find_master(client: batch.BatchServiceClient) -> bool:
for i in range(0, 5):
pool = client.pool.get(config.pool_id)
master = get_master_node_id(pool)
if master:
if master == config.node_id:
print("Node is already the master '{0}'".format(master))
... | [
"def",
"find_master",
"(",
"client",
":",
"batch",
".",
"BatchServiceClient",
")",
"->",
"bool",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"5",
")",
":",
"pool",
"=",
"client",
".",
"pool",
".",
"get",
"(",
"config",
".",
"pool_id",
")",
"mast... | Try to set a master for the cluster. | [
"Try",
"to",
"set",
"a",
"master",
"for",
"the",
"cluster",
"."
] | [
"\"\"\"\n Try to set a master for the cluster. If the node is dedicated it will try to assign itself if none already claimed it.\n :returns bool: If the node is the master it returns true otherwise returns false\n \"\"\"",
"# If not dedicated the node cannot be a master",
"# TODO enable when in... | [
{
"param": "client",
"type": "batch.BatchServiceClient"
}
] | {
"returns": [
{
"docstring": "If the node is the master it returns true otherwise returns false",
"docstring_tokens": [
"If",
"the",
"node",
"is",
"the",
"master",
"it",
"returns",
"true",
"otherwise",
"returns",
... |
5ef33658d4cc17305025d5615404cc5789665162 | junqueira/aztk | aztk/core/models/fields.py | [
"MIT"
] | Python | merge | null | def merge(self, instance, value):
"""
Method called when merging 2 models together.
This is overridden in some of the fields where merge can be handled differently
"""
if value is not None:
instance._data[self] = value |
Method called when merging 2 models together.
This is overridden in some of the fields where merge can be handled differently
| Method called when merging 2 models together.
This is overridden in some of the fields where merge can be handled differently | [
"Method",
"called",
"when",
"merging",
"2",
"models",
"together",
".",
"This",
"is",
"overridden",
"in",
"some",
"of",
"the",
"fields",
"where",
"merge",
"can",
"be",
"handled",
"differently"
] | def merge(self, instance, value):
if value is not None:
instance._data[self] = value | [
"def",
"merge",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"instance",
".",
"_data",
"[",
"self",
"]",
"=",
"value"
] | Method called when merging 2 models together. | [
"Method",
"called",
"when",
"merging",
"2",
"models",
"together",
"."
] | [
"\"\"\"\n Method called when merging 2 models together.\n This is overridden in some of the fields where merge can be handled differently\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "instance",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "instance",
"type": null,
"docstring": null,
"docstring_tokens... |
5d92b80eb83140c898a5914c9f4138f02dc55aea | junqueira/aztk | aztk/client/base/helpers/task_table.py | [
"MIT"
] | Python | create_task_table | <not_specific> | def create_task_table(table_service, id):
"""Create the task table that tracks spark app execution
Returns:
`bool`: True if creation is successful
"""
return table_service.create_table(helpers.convert_id_to_table_id(id), fail_on_exist=True) | Create the task table that tracks spark app execution
Returns:
`bool`: True if creation is successful
| Create the task table that tracks spark app execution | [
"Create",
"the",
"task",
"table",
"that",
"tracks",
"spark",
"app",
"execution"
] | def create_task_table(table_service, id):
return table_service.create_table(helpers.convert_id_to_table_id(id), fail_on_exist=True) | [
"def",
"create_task_table",
"(",
"table_service",
",",
"id",
")",
":",
"return",
"table_service",
".",
"create_table",
"(",
"helpers",
".",
"convert_id_to_table_id",
"(",
"id",
")",
",",
"fail_on_exist",
"=",
"True",
")"
] | Create the task table that tracks spark app execution | [
"Create",
"the",
"task",
"table",
"that",
"tracks",
"spark",
"app",
"execution"
] | [
"\"\"\"Create the task table that tracks spark app execution\n Returns:\n `bool`: True if creation is successful\n \"\"\""
] | [
{
"param": "table_service",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": "True if creation is successful",
"docstring_tokens": [
"True",
"if",
"creation",
"is",
"successful"
],
"type": "`bool`"
}
],
"raises": [],
"params": [
{
"identifier": "table_service",
"type": n... |
aabfc3478208d267267d938cf1372ae63ad144a0 | junqueira/aztk | aztk/spark/client/cluster/helpers/create.py | [
"MIT"
] | Python | create_cluster | <not_specific> | def create_cluster(core_cluster_operations,
spark_cluster_operations,
cluster_conf: models.ClusterConfiguration,
wait: bool = False):
"""
Create a new aztk spark cluster
Args:
cluster_conf(aztk.spark.models.models.ClusterConfiguration): Confi... |
Create a new aztk spark cluster
Args:
cluster_conf(aztk.spark.models.models.ClusterConfiguration): Configuration for the the cluster to be created
wait(bool): If you should wait for the cluster to be ready before returning
Returns:
:obj:`aztk.spark.models.Cluster`
| Create a new aztk spark cluster | [
"Create",
"a",
"new",
"aztk",
"spark",
"cluster"
] | def create_cluster(core_cluster_operations,
spark_cluster_operations,
cluster_conf: models.ClusterConfiguration,
wait: bool = False):
cluster_conf = _apply_default_for_cluster_config(cluster_conf)
cluster_conf.validate()
cluster_data = core_cluster_op... | [
"def",
"create_cluster",
"(",
"core_cluster_operations",
",",
"spark_cluster_operations",
",",
"cluster_conf",
":",
"models",
".",
"ClusterConfiguration",
",",
"wait",
":",
"bool",
"=",
"False",
")",
":",
"cluster_conf",
"=",
"_apply_default_for_cluster_config",
"(",
... | Create a new aztk spark cluster | [
"Create",
"a",
"new",
"aztk",
"spark",
"cluster"
] | [
"\"\"\"\n Create a new aztk spark cluster\n\n Args:\n cluster_conf(aztk.spark.models.models.ClusterConfiguration): Configuration for the the cluster to be created\n wait(bool): If you should wait for the cluster to be ready before returning\n\n Returns:\n :obj:`aztk.spark.models.Cluste... | [
{
"param": "core_cluster_operations",
"type": null
},
{
"param": "spark_cluster_operations",
"type": null
},
{
"param": "cluster_conf",
"type": "models.ClusterConfiguration"
},
{
"param": "wait",
"type": "bool"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "core_cluster_operations",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is... |
3cf7cd07a5e2932f488eb5e07844b3915b63c0f1 | junqueira/aztk | aztk/utils/deprecation.py | [
"MIT"
] | Python | deprecated | <not_specific> | def deprecated(version: str, advice: str = None):
"""
This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
Args:
version (str): The version in which the deprecated functionality will be removed
ad... |
This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
Args:
version (str): The version in which the deprecated functionality will be removed
advice (str): Sentence explaining alternatives to the depre... | This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used. | [
"This",
"is",
"a",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
".",
"It",
"will",
"result",
"in",
"a",
"warning",
"being",
"emitted",
"when",
"the",
"function",
"is",
"used",
"."
] | def deprecated(version: str, advice: str = None):
def decorator(func):
if inspect.isclass(func):
msg = "Call to deprecated class {name}."
else:
msg = "Call to deprecated function {name}."
@functools.wraps(func)
def new_func(*args, **kwargs):
deprec... | [
"def",
"deprecated",
"(",
"version",
":",
"str",
",",
"advice",
":",
"str",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"func",
")",
":",
"msg",
"=",
"\"Call to deprecated class {name}.\"",
"els... | This is a decorator which can be used to mark functions
as deprecated. | [
"This",
"is",
"a",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
"."
] | [
"\"\"\"\n This is a decorator which can be used to mark functions\n as deprecated. It will result in a warning being emitted\n when the function is used.\n\n Args:\n version (str): The version in which the deprecated functionality will be removed\n advice (str): Sentence explaining alterna... | [
{
"param": "version",
"type": "str"
},
{
"param": "advice",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "version",
"type": "str",
"docstring": "The version in which the deprecated functionality will be removed",
"docstring_tokens": [
"The",
"version",
"in",
"which",
"the",
"deprecat... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | node_run | <not_specific> | def node_run(self, id, node_id, command, internal, container_name=None, timeout=None, block=True):
"""Run a bash command on the given node
Args:
id (:obj:`str`): the id of the cluster to run the command on.
node_id (:obj:`str`): the id of the node in the cluster to run the comma... | Run a bash command on the given node
Args:
id (:obj:`str`): the id of the cluster to run the command on.
node_id (:obj:`str`): the id of the node in the cluster to run the command on.
command (:obj:`str`): the bash command to execute on the node.
internal (:obj:`... | Run a bash command on the given node | [
"Run",
"a",
"bash",
"command",
"on",
"the",
"given",
"node"
] | def node_run(self, id, node_id, command, internal, container_name=None, timeout=None, block=True):
return node_run.node_run(self, id, node_id, command, internal, container_name, timeout, block) | [
"def",
"node_run",
"(",
"self",
",",
"id",
",",
"node_id",
",",
"command",
",",
"internal",
",",
"container_name",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"block",
"=",
"True",
")",
":",
"return",
"node_run",
".",
"node_run",
"(",
"self",
",",
... | Run a bash command on the given node | [
"Run",
"a",
"bash",
"command",
"on",
"the",
"given",
"node"
] | [
"\"\"\"Run a bash command on the given node\n\n Args:\n id (:obj:`str`): the id of the cluster to run the command on.\n node_id (:obj:`str`): the id of the node in the cluster to run the command on.\n command (:obj:`str`): the bash command to execute on the node.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
},
{
"param": "node_id",
"type": null
},
{
"param": "command",
"type": null
},
{
"param": "internal",
"type": null
},
{
"param": "container_name",
"type": null
},
{
"param": "... | {
"returns": [
{
"docstring": ":obj:`aztk.models.NodeOutput`: object containing the output of the run command",
"docstring_tokens": [
":",
"obj",
":",
"`",
"aztk",
".",
"models",
".",
"NodeOutput",
"`",
":",
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | create_task_table | <not_specific> | def create_task_table(self, id: str):
"""Create an Azure Table Storage to track tasks
Args:
id (:obj:`str`): the id of the cluster
"""
return task_table.create_task_table(self.table_service, id) | Create an Azure Table Storage to track tasks
Args:
id (:obj:`str`): the id of the cluster
| Create an Azure Table Storage to track tasks | [
"Create",
"an",
"Azure",
"Table",
"Storage",
"to",
"track",
"tasks"
] | def create_task_table(self, id: str):
return task_table.create_task_table(self.table_service, id) | [
"def",
"create_task_table",
"(",
"self",
",",
"id",
":",
"str",
")",
":",
"return",
"task_table",
".",
"create_task_table",
"(",
"self",
".",
"table_service",
",",
"id",
")"
] | Create an Azure Table Storage to track tasks | [
"Create",
"an",
"Azure",
"Table",
"Storage",
"to",
"track",
"tasks"
] | [
"\"\"\"Create an Azure Table Storage to track tasks\n\n Args:\n id (:obj:`str`): the id of the cluster\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": "str",
"docstring": null,
"docstring_tokens": []... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | list_task_table_entries | <not_specific> | def list_task_table_entries(self, id):
"""list tasks in a storage table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table
"""
return task_table.list_task_table_ent... | list tasks in a storage table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table
| list tasks in a storage table | [
"list",
"tasks",
"in",
"a",
"storage",
"table"
] | def list_task_table_entries(self, id):
return task_table.list_task_table_entries(self.table_service, id) | [
"def",
"list_task_table_entries",
"(",
"self",
",",
"id",
")",
":",
"return",
"task_table",
".",
"list_task_table_entries",
"(",
"self",
".",
"table_service",
",",
"id",
")"
] | list tasks in a storage table | [
"list",
"tasks",
"in",
"a",
"storage",
"table"
] | [
"\"\"\"list tasks in a storage table\n\n Args:\n id (:obj:`str`): the id of the cluster\n\n Returns:\n :obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table",
"docstring_tokens": [
":",
"obj",
":",
"`",
"[",
"aztk",
".",
"models",
".",
"Task",
"]",
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | insert_task_into_task_table | <not_specific> | def insert_task_into_task_table(self, id, task):
"""Insert a task into the table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`aztk.models.Task`: a model representing an entry in the Task table
"""
return task_table.insert_task_into_task_ta... | Insert a task into the table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`aztk.models.Task`: a model representing an entry in the Task table
| Insert a task into the table | [
"Insert",
"a",
"task",
"into",
"the",
"table"
] | def insert_task_into_task_table(self, id, task):
return task_table.insert_task_into_task_table(self.table_service, id, task) | [
"def",
"insert_task_into_task_table",
"(",
"self",
",",
"id",
",",
"task",
")",
":",
"return",
"task_table",
".",
"insert_task_into_task_table",
"(",
"self",
".",
"table_service",
",",
"id",
",",
"task",
")"
] | Insert a task into the table | [
"Insert",
"a",
"task",
"into",
"the",
"table"
] | [
"\"\"\"Insert a task into the table\n\n Args:\n id (:obj:`str`): the id of the cluster\n\n Returns:\n :obj:`aztk.models.Task`: a model representing an entry in the Task table\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
},
{
"param": "task",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`aztk.models.Task`: a model representing an entry in the Task table",
"docstring_tokens": [
":",
"obj",
":",
"`",
"aztk",
".",
"models",
".",
"Task",
"`",
":",
"a",
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | update_task_in_task_table | <not_specific> | def update_task_in_task_table(self, id, task):
"""Update a task in the table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`aztk.models.Task`: a model representing an entry in the Task table
"""
return task_table.update_task_in_task_table(se... | Update a task in the table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`aztk.models.Task`: a model representing an entry in the Task table
| Update a task in the table | [
"Update",
"a",
"task",
"in",
"the",
"table"
] | def update_task_in_task_table(self, id, task):
return task_table.update_task_in_task_table(self.table_service, id, task) | [
"def",
"update_task_in_task_table",
"(",
"self",
",",
"id",
",",
"task",
")",
":",
"return",
"task_table",
".",
"update_task_in_task_table",
"(",
"self",
".",
"table_service",
",",
"id",
",",
"task",
")"
] | Update a task in the table | [
"Update",
"a",
"task",
"in",
"the",
"table"
] | [
"\"\"\"Update a task in the table\n\n Args:\n id (:obj:`str`): the id of the cluster\n\n Returns:\n :obj:`aztk.models.Task`: a model representing an entry in the Task table\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
},
{
"param": "task",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`aztk.models.Task`: a model representing an entry in the Task table",
"docstring_tokens": [
":",
"obj",
":",
"`",
"aztk",
".",
"models",
".",
"Task",
"`",
":",
"a",
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | delete_task_table | <not_specific> | def delete_task_table(self, id):
"""Delete the table that tracks tasks
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`bool`: if True, the deletion was successful
"""
return task_table.delete_task_table(self.table_service, id) | Delete the table that tracks tasks
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`bool`: if True, the deletion was successful
| Delete the table that tracks tasks | [
"Delete",
"the",
"table",
"that",
"tracks",
"tasks"
] | def delete_task_table(self, id):
return task_table.delete_task_table(self.table_service, id) | [
"def",
"delete_task_table",
"(",
"self",
",",
"id",
")",
":",
"return",
"task_table",
".",
"delete_task_table",
"(",
"self",
".",
"table_service",
",",
"id",
")"
] | Delete the table that tracks tasks | [
"Delete",
"the",
"table",
"that",
"tracks",
"tasks"
] | [
"\"\"\"Delete the table that tracks tasks\n\n Args:\n id (:obj:`str`): the id of the cluster\n\n Returns:\n :obj:`bool`: if True, the deletion was successful\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`bool`: if True, the deletion was successful",
"docstring_tokens": [
":",
"obj",
":",
"`",
"bool",
"`",
":",
"if",
"True",
"the",
"deletion",
"was",
"successful"
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | list_tasks | <not_specific> | def list_tasks(self, id):
"""list tasks in a storage table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table
"""
return list_tasks.list_tasks(self, id) | list tasks in a storage table
Args:
id (:obj:`str`): the id of the cluster
Returns:
:obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table
| list tasks in a storage table | [
"list",
"tasks",
"in",
"a",
"storage",
"table"
] | def list_tasks(self, id):
return list_tasks.list_tasks(self, id) | [
"def",
"list_tasks",
"(",
"self",
",",
"id",
")",
":",
"return",
"list_tasks",
".",
"list_tasks",
"(",
"self",
",",
"id",
")"
] | list tasks in a storage table | [
"list",
"tasks",
"in",
"a",
"storage",
"table"
] | [
"\"\"\"list tasks in a storage table\n\n Args:\n id (:obj:`str`): the id of the cluster\n\n Returns:\n :obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`[aztk.models.Task]`: a list of models representing all entries in the Task table",
"docstring_tokens": [
":",
"obj",
":",
"`",
"[",
"aztk",
".",
"models",
".",
"Task",
"]",
... |
a1cff5bec771adb80937f7ae1ac8538671fae2a4 | junqueira/aztk | aztk/client/base/base_operations.py | [
"MIT"
] | Python | list_batch_tasks | <not_specific> | def list_batch_tasks(self, id: str):
"""Get the status of a submitted task
Args:
id (:obj:`str`): the name of the cluster the task was submitted to
Returns:
:obj:`[aztk.models.Task]`: list of aztk tasks
"""
return task_table.list_batch_tasks(self.batch_c... | Get the status of a submitted task
Args:
id (:obj:`str`): the name of the cluster the task was submitted to
Returns:
:obj:`[aztk.models.Task]`: list of aztk tasks
| Get the status of a submitted task | [
"Get",
"the",
"status",
"of",
"a",
"submitted",
"task"
] | def list_batch_tasks(self, id: str):
return task_table.list_batch_tasks(self.batch_client, id) | [
"def",
"list_batch_tasks",
"(",
"self",
",",
"id",
":",
"str",
")",
":",
"return",
"task_table",
".",
"list_batch_tasks",
"(",
"self",
".",
"batch_client",
",",
"id",
")"
] | Get the status of a submitted task | [
"Get",
"the",
"status",
"of",
"a",
"submitted",
"task"
] | [
"\"\"\"Get the status of a submitted task\n\n Args:\n id (:obj:`str`): the name of the cluster the task was submitted to\n\n Returns:\n :obj:`[aztk.models.Task]`: list of aztk tasks\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": "str"
}
] | {
"returns": [
{
"docstring": ":obj:`[aztk.models.Task]`: list of aztk tasks",
"docstring_tokens": [
":",
"obj",
":",
"`",
"[",
"aztk",
".",
"models",
".",
"Task",
"]",
"`",
":",
"list",
... |
73e3366100c292feea0bb2d5630fc7ee1f8d9d4d | junqueira/aztk | aztk/utils/get_ssh_key.py | [
"MIT"
] | Python | __read_ssh_key_from_file | str | def __read_ssh_key_from_file(path: str) -> str:
"""
Read the content of the given file
"""
with open(os.path.expanduser(path), "r", encoding="UTF-8") as content_file:
content = content_file.read()
return content |
Read the content of the given file
| Read the content of the given file | [
"Read",
"the",
"content",
"of",
"the",
"given",
"file"
] | def __read_ssh_key_from_file(path: str) -> str:
with open(os.path.expanduser(path), "r", encoding="UTF-8") as content_file:
content = content_file.read()
return content | [
"def",
"__read_ssh_key_from_file",
"(",
"path",
":",
"str",
")",
"->",
"str",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
",",
"\"r\"",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
"as",
"content_file",
":",
"content",
... | Read the content of the given file | [
"Read",
"the",
"content",
"of",
"the",
"given",
"file"
] | [
"\"\"\"\n Read the content of the given file\n \"\"\""
] | [
{
"param": "path",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ca4e977a8bbc9ad8ddd91fa8ba9e6bd2a4340a7e | junqueira/aztk | aztk/internal/configuration_base.py | [
"MIT"
] | Python | from_dict | <not_specific> | def from_dict(cls, args: dict):
"""
Create a new model from a dict values
The dict is cleaned from null values and passed expanded to the constructor
"""
try:
return cls._from_dict(args)
except (ValueError, TypeError) as e:
pretty_args = yaml.dump(... |
Create a new model from a dict values
The dict is cleaned from null values and passed expanded to the constructor
| Create a new model from a dict values
The dict is cleaned from null values and passed expanded to the constructor | [
"Create",
"a",
"new",
"model",
"from",
"a",
"dict",
"values",
"The",
"dict",
"is",
"cleaned",
"from",
"null",
"values",
"and",
"passed",
"expanded",
"to",
"the",
"constructor"
] | def from_dict(cls, args: dict):
try:
return cls._from_dict(args)
except (ValueError, TypeError) as e:
pretty_args = yaml.dump(args, default_flow_style=False)
raise AztkError("{0} {1}\n{2}".format(cls.__name__, str(e), pretty_args)) | [
"def",
"from_dict",
"(",
"cls",
",",
"args",
":",
"dict",
")",
":",
"try",
":",
"return",
"cls",
".",
"_from_dict",
"(",
"args",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
"as",
"e",
":",
"pretty_args",
"=",
"yaml",
".",
"dump",
"(",
... | Create a new model from a dict values
The dict is cleaned from null values and passed expanded to the constructor | [
"Create",
"a",
"new",
"model",
"from",
"a",
"dict",
"values",
"The",
"dict",
"is",
"cleaned",
"from",
"null",
"values",
"and",
"passed",
"expanded",
"to",
"the",
"constructor"
] | [
"\"\"\"\n Create a new model from a dict values\n The dict is cleaned from null values and passed expanded to the constructor\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "args",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": "dict",
"docstring": null,
"docstring_tokens": ... |
b439d93e0147dd9534f8af43a84bfed3331e68ba | junqueira/aztk | aztk/client/cluster/helpers/list.py | [
"MIT"
] | Python | list_clusters | <not_specific> | def list_clusters(cluster_client, software_metadata_key):
"""
List all the cluster on your account.
"""
pools = cluster_client.batch_client.pool.list()
software_metadata = (constants.AZTK_SOFTWARE_METADATA_KEY, software_metadata_key)
cluster_metadata = (constants.AZTK_MODE_METADATA_KEY, cons... |
List all the cluster on your account.
| List all the cluster on your account. | [
"List",
"all",
"the",
"cluster",
"on",
"your",
"account",
"."
] | def list_clusters(cluster_client, software_metadata_key):
pools = cluster_client.batch_client.pool.list()
software_metadata = (constants.AZTK_SOFTWARE_METADATA_KEY, software_metadata_key)
cluster_metadata = (constants.AZTK_MODE_METADATA_KEY, constants.AZTK_CLUSTER_MODE_METADATA)
aztk_clusters = []
f... | [
"def",
"list_clusters",
"(",
"cluster_client",
",",
"software_metadata_key",
")",
":",
"pools",
"=",
"cluster_client",
".",
"batch_client",
".",
"pool",
".",
"list",
"(",
")",
"software_metadata",
"=",
"(",
"constants",
".",
"AZTK_SOFTWARE_METADATA_KEY",
",",
"sof... | List all the cluster on your account. | [
"List",
"all",
"the",
"cluster",
"on",
"your",
"account",
"."
] | [
"\"\"\"\n List all the cluster on your account.\n \"\"\""
] | [
{
"param": "cluster_client",
"type": null
},
{
"param": "software_metadata_key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cluster_client",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "software_metadata_key",
"type": null,
"docstring": null,
... |
804d42c39b6ddd53663ca2839fb8f34a275b6819 | junqueira/aztk | aztk/models/cluster_configuration.py | [
"MIT"
] | Python | mixed_mode | bool | def mixed_mode(self) -> bool:
"""
Return:
if the pool is using mixed mode(Both dedicated and low priority nodes)
"""
return self.size > 0 and self.size_low_priority > 0 |
Return:
if the pool is using mixed mode(Both dedicated and low priority nodes)
| if the pool is using mixed mode(Both dedicated and low priority nodes) | [
"if",
"the",
"pool",
"is",
"using",
"mixed",
"mode",
"(",
"Both",
"dedicated",
"and",
"low",
"priority",
"nodes",
")"
] | def mixed_mode(self) -> bool:
return self.size > 0 and self.size_low_priority > 0 | [
"def",
"mixed_mode",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"size",
">",
"0",
"and",
"self",
".",
"size_low_priority",
">",
"0"
] | Return:
if the pool is using mixed mode(Both dedicated and low priority nodes) | [
"Return",
":",
"if",
"the",
"pool",
"is",
"using",
"mixed",
"mode",
"(",
"Both",
"dedicated",
"and",
"low",
"priority",
"nodes",
")"
] | [
"\"\"\"\n Return:\n if the pool is using mixed mode(Both dedicated and low priority nodes)\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
861229f6b0410e5f3a60b4cd37b2059cfcab5432 | junqueira/aztk | aztk/spark/client/job/operations.py | [
"MIT"
] | Python | list_applications | <not_specific> | def list_applications(self, id):
"""List all application defined as a part of a job
Args:
id (:obj:`str`): the id of the job to list the applications of
Returns:
:obj:`List[aztk.spark.models.Application]`: a list of all applications defined as a part of the job
... | List all application defined as a part of a job
Args:
id (:obj:`str`): the id of the job to list the applications of
Returns:
:obj:`List[aztk.spark.models.Application]`: a list of all applications defined as a part of the job
| List all application defined as a part of a job | [
"List",
"all",
"application",
"defined",
"as",
"a",
"part",
"of",
"a",
"job"
] | def list_applications(self, id):
return list_applications.list_applications(self._core_job_operations, id) | [
"def",
"list_applications",
"(",
"self",
",",
"id",
")",
":",
"return",
"list_applications",
".",
"list_applications",
"(",
"self",
".",
"_core_job_operations",
",",
"id",
")"
] | List all application defined as a part of a job | [
"List",
"all",
"application",
"defined",
"as",
"a",
"part",
"of",
"a",
"job"
] | [
"\"\"\"List all application defined as a part of a job\n\n Args:\n id (:obj:`str`): the id of the job to list the applications of\n\n Returns:\n :obj:`List[aztk.spark.models.Application]`: a list of all applications defined as a part of the job\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`List[aztk.spark.models.Application]`: a list of all applications defined as a part of the job",
"docstring_tokens": [
":",
"obj",
":",
"`",
"List",
"[",
"aztk",
".",
"spark",
".",
... |
861229f6b0410e5f3a60b4cd37b2059cfcab5432 | junqueira/aztk | aztk/spark/client/job/operations.py | [
"MIT"
] | Python | submit | <not_specific> | def submit(self, job_configuration: models.JobConfiguration, wait: bool = False):
"""Submit a job
Jobs are a cluster definition and one or many application definitions which run on the cluster. The job's
cluster will be allocated and configured, then the applications will be executed with their... | Submit a job
Jobs are a cluster definition and one or many application definitions which run on the cluster. The job's
cluster will be allocated and configured, then the applications will be executed with their output stored
in Azure Storage. When all applications have completed, the cluster wi... | Submit a job
Jobs are a cluster definition and one or many application definitions which run on the cluster. The job's
cluster will be allocated and configured, then the applications will be executed with their output stored
in Azure Storage. When all applications have completed, the cluster will be automatically delet... | [
"Submit",
"a",
"job",
"Jobs",
"are",
"a",
"cluster",
"definition",
"and",
"one",
"or",
"many",
"application",
"definitions",
"which",
"run",
"on",
"the",
"cluster",
".",
"The",
"job",
"'",
"s",
"cluster",
"will",
"be",
"allocated",
"and",
"configured",
"th... | def submit(self, job_configuration: models.JobConfiguration, wait: bool = False):
return submit.submit_job(self._core_job_operations, self, job_configuration, wait) | [
"def",
"submit",
"(",
"self",
",",
"job_configuration",
":",
"models",
".",
"JobConfiguration",
",",
"wait",
":",
"bool",
"=",
"False",
")",
":",
"return",
"submit",
".",
"submit_job",
"(",
"self",
".",
"_core_job_operations",
",",
"self",
",",
"job_configur... | Submit a job
Jobs are a cluster definition and one or many application definitions which run on the cluster. | [
"Submit",
"a",
"job",
"Jobs",
"are",
"a",
"cluster",
"definition",
"and",
"one",
"or",
"many",
"application",
"definitions",
"which",
"run",
"on",
"the",
"cluster",
"."
] | [
"\"\"\"Submit a job\n\n Jobs are a cluster definition and one or many application definitions which run on the cluster. The job's\n cluster will be allocated and configured, then the applications will be executed with their output stored\n in Azure Storage. When all applications have completed,... | [
{
"param": "self",
"type": null
},
{
"param": "job_configuration",
"type": "models.JobConfiguration"
},
{
"param": "wait",
"type": "bool"
}
] | {
"returns": [
{
"docstring": ":obj:`aztk.spark.models.Job`: Model representing the state of the job.",
"docstring_tokens": [
":",
"obj",
":",
"`",
"aztk",
".",
"spark",
".",
"models",
".",
"Job",
"`",
... |
861229f6b0410e5f3a60b4cd37b2059cfcab5432 | junqueira/aztk | aztk/spark/client/job/operations.py | [
"MIT"
] | Python | wait | null | def wait(self, id):
"""Wait until the job has completed.
Args:
id (:obj:`str`): the id of the job the application belongs to
Returns:
:obj:`None`
"""
wait_until_complete.wait_until_job_finished(self._core_job_operations, id) | Wait until the job has completed.
Args:
id (:obj:`str`): the id of the job the application belongs to
Returns:
:obj:`None`
| Wait until the job has completed. | [
"Wait",
"until",
"the",
"job",
"has",
"completed",
"."
] | def wait(self, id):
wait_until_complete.wait_until_job_finished(self._core_job_operations, id) | [
"def",
"wait",
"(",
"self",
",",
"id",
")",
":",
"wait_until_complete",
".",
"wait_until_job_finished",
"(",
"self",
".",
"_core_job_operations",
",",
"id",
")"
] | Wait until the job has completed. | [
"Wait",
"until",
"the",
"job",
"has",
"completed",
"."
] | [
"\"\"\"Wait until the job has completed.\n Args:\n id (:obj:`str`): the id of the job the application belongs to\n\n Returns:\n :obj:`None`\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"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
... |
969c820b5b19e2128b176c9d61ba6fbbb40f2ffc | junqueira/aztk | aztk/client/base/helpers/list_tasks.py | [
"MIT"
] | Python | list_tasks | <not_specific> | def list_tasks(core_base_operations, id):
"""List all tasks on a job or cluster
This will work for both Batch scheduling and scheduling_target
Args:
id: cluster or job id
Returns:
List[aztk.models.Task]
"""
scheduling_target = core_base_operations.get_cluster_configuration(id)... | List all tasks on a job or cluster
This will work for both Batch scheduling and scheduling_target
Args:
id: cluster or job id
Returns:
List[aztk.models.Task]
| List all tasks on a job or cluster
This will work for both Batch scheduling and scheduling_target | [
"List",
"all",
"tasks",
"on",
"a",
"job",
"or",
"cluster",
"This",
"will",
"work",
"for",
"both",
"Batch",
"scheduling",
"and",
"scheduling_target"
] | def list_tasks(core_base_operations, id):
scheduling_target = core_base_operations.get_cluster_configuration(id).scheduling_target
if scheduling_target is not SchedulingTarget.Any:
return list_task_table_entries(core_base_operations.table_service, id)
else:
recent_run_job = get_recent_job(co... | [
"def",
"list_tasks",
"(",
"core_base_operations",
",",
"id",
")",
":",
"scheduling_target",
"=",
"core_base_operations",
".",
"get_cluster_configuration",
"(",
"id",
")",
".",
"scheduling_target",
"if",
"scheduling_target",
"is",
"not",
"SchedulingTarget",
".",
"Any",... | List all tasks on a job or cluster
This will work for both Batch scheduling and scheduling_target | [
"List",
"all",
"tasks",
"on",
"a",
"job",
"or",
"cluster",
"This",
"will",
"work",
"for",
"both",
"Batch",
"scheduling",
"and",
"scheduling_target"
] | [
"\"\"\"List all tasks on a job or cluster\n\n This will work for both Batch scheduling and scheduling_target\n\n Args:\n id: cluster or job id\n Returns:\n List[aztk.models.Task]\n\n \"\"\"",
"# note: this currently only works for job_schedules",
"# cluster impl is planned to move to j... | [
{
"param": "core_base_operations",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "core_base_operations",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_op... |
cf05a23bf7a53cba974539021518a2ffdcbf8092 | junqueira/aztk | aztk/internal/cluster_data/node_data.py | [
"MIT"
] | Python | add_dir | null | def add_dir(self, path: str, dest: str = None, exclude: List[str] = None):
"""
Zip all the files in the given directory into the zip file handler
"""
exclude = exclude or []
for base, _, files in os.walk(path):
relative_folder = os.path.relpath(base, path)
... |
Zip all the files in the given directory into the zip file handler
| Zip all the files in the given directory into the zip file handler | [
"Zip",
"all",
"the",
"files",
"in",
"the",
"given",
"directory",
"into",
"the",
"zip",
"file",
"handler"
] | def add_dir(self, path: str, dest: str = None, exclude: List[str] = None):
exclude = exclude or []
for base, _, files in os.walk(path):
relative_folder = os.path.relpath(base, path)
for file in files:
if self._includeFile(file, exclude):
self.a... | [
"def",
"add_dir",
"(",
"self",
",",
"path",
":",
"str",
",",
"dest",
":",
"str",
"=",
"None",
",",
"exclude",
":",
"List",
"[",
"str",
"]",
"=",
"None",
")",
":",
"exclude",
"=",
"exclude",
"or",
"[",
"]",
"for",
"base",
",",
"_",
",",
"files",... | Zip all the files in the given directory into the zip file handler | [
"Zip",
"all",
"the",
"files",
"in",
"the",
"given",
"directory",
"into",
"the",
"zip",
"file",
"handler"
] | [
"\"\"\"\n Zip all the files in the given directory into the zip file handler\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": "str"
},
{
"param": "dest",
"type": "str"
},
{
"param": "exclude",
"type": "List[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
e3d6521b892994745255678cb57b9a34f9da3b4c | junqueira/aztk | aztk_cli/utils.py | [
"MIT"
] | Python | ssh_in_master | <not_specific> | def ssh_in_master(
client,
cluster_id: str,
cluster_configuration: models.ClusterConfiguration,
username: str = None,
webui: str = None,
jobui: str = None,
jobhistoryui: str = None,
ports=None,
host: bool = False,
connect: bool = True,
... |
SSH into head node of spark-app
:param cluster_id: Id of the cluster to ssh in
:param username: Username to use to ssh
:param webui: Port for the spark master web ui (Local port)
:param jobui: Port for the job web ui (Local port)
:param ports: an list of local and remote... | SSH into head node of spark-app | [
"SSH",
"into",
"head",
"node",
"of",
"spark",
"-",
"app"
] | def ssh_in_master(
client,
cluster_id: str,
cluster_configuration: models.ClusterConfiguration,
username: str = None,
webui: str = None,
jobui: str = None,
jobhistoryui: str = None,
ports=None,
host: bool = False,
connect: bool = True,
... | [
"def",
"ssh_in_master",
"(",
"client",
",",
"cluster_id",
":",
"str",
",",
"cluster_configuration",
":",
"models",
".",
"ClusterConfiguration",
",",
"username",
":",
"str",
"=",
"None",
",",
"webui",
":",
"str",
"=",
"None",
",",
"jobui",
":",
"str",
"=",
... | SSH into head node of spark-app | [
"SSH",
"into",
"head",
"node",
"of",
"spark",
"-",
"app"
] | [
"\"\"\"\n SSH into head node of spark-app\n :param cluster_id: Id of the cluster to ssh in\n :param username: Username to use to ssh\n :param webui: Port for the spark master web ui (Local port)\n :param jobui: Port for the job web ui (Local port)\n :param ports: an list of... | [
{
"param": "client",
"type": null
},
{
"param": "cluster_id",
"type": "str"
},
{
"param": "cluster_configuration",
"type": "models.ClusterConfiguration"
},
{
"param": "username",
"type": "str"
},
{
"param": "webui",
"type": "str"
},
{
"param": "jobui",... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "client",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cluster_id",
"type": "str",
"docstring": "Id of the cluster to ss... |
e3d6521b892994745255678cb57b9a34f9da3b4c | junqueira/aztk | aztk_cli/utils.py | [
"MIT"
] | Python | print_batch_exception | null | def print_batch_exception(batch_exception):
"""
Prints the contents of the specified Batch exception.
:param batch_exception:
"""
log.error("-------------------------------------------")
log.error("Exception encountered:")
if batch_exception.error and batch_exception.error.message and batch_... |
Prints the contents of the specified Batch exception.
:param batch_exception:
| Prints the contents of the specified Batch exception. | [
"Prints",
"the",
"contents",
"of",
"the",
"specified",
"Batch",
"exception",
"."
] | def print_batch_exception(batch_exception):
log.error("-------------------------------------------")
log.error("Exception encountered:")
if batch_exception.error and batch_exception.error.message and batch_exception.error.message.value:
log.error(batch_exception.error.message.value)
if batch... | [
"def",
"print_batch_exception",
"(",
"batch_exception",
")",
":",
"log",
".",
"error",
"(",
"\"-------------------------------------------\"",
")",
"log",
".",
"error",
"(",
"\"Exception encountered:\"",
")",
"if",
"batch_exception",
".",
"error",
"and",
"batch_exceptio... | Prints the contents of the specified Batch exception. | [
"Prints",
"the",
"contents",
"of",
"the",
"specified",
"Batch",
"exception",
"."
] | [
"\"\"\"\n Prints the contents of the specified Batch exception.\n :param batch_exception:\n \"\"\""
] | [
{
"param": "batch_exception",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "batch_exception",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7f7449e62b6925c417be9b4194aca720ee317f4d | JohnShullTopDev/generating-traning-data-for-healthcare-machine-learningcare- | bin/binary.py | [
"Apache-2.0"
] | Python | Binary | <not_specific> | def Binary(data):
"""Builds and returns the Binary JSON"""
return {
"request": {
"method": "PUT",
"url" : "Binary/" + data["id"]
},
"resource": {
"id" : data["id"],
"resourceType": "Binary",
"contentType" : data["mim... | Builds and returns the Binary JSON | Builds and returns the Binary JSON | [
"Builds",
"and",
"returns",
"the",
"Binary",
"JSON"
] | def Binary(data):
return {
"request": {
"method": "PUT",
"url" : "Binary/" + data["id"]
},
"resource": {
"id" : data["id"],
"resourceType": "Binary",
"contentType" : data["mime_type"],
"content" : data["co... | [
"def",
"Binary",
"(",
"data",
")",
":",
"return",
"{",
"\"request\"",
":",
"{",
"\"method\"",
":",
"\"PUT\"",
",",
"\"url\"",
":",
"\"Binary/\"",
"+",
"data",
"[",
"\"id\"",
"]",
"}",
",",
"\"resource\"",
":",
"{",
"\"id\"",
":",
"data",
"[",
"\"id\"",... | Builds and returns the Binary JSON | [
"Builds",
"and",
"returns",
"the",
"Binary",
"JSON"
] | [
"\"\"\"Builds and returns the Binary JSON\"\"\""
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7b00e93928834a24105d32b8afa2e8fc5d335b10 | JohnShullTopDev/generating-traning-data-for-healthcare-machine-learningcare- | bin/no_known_allergies.py | [
"Apache-2.0"
] | Python | no_known_allergies | <not_specific> | def no_known_allergies(data, prefix=""):
"""Builds and returns the List JSON"""
if prefix:
prefix += "-"
out = {
"request": {
"method": "PUT",
"url": "List/" + prefix + "List-" + data["id"]
},
"status": "current",
"resource": {
"i... | Builds and returns the List JSON | Builds and returns the List JSON | [
"Builds",
"and",
"returns",
"the",
"List",
"JSON"
] | def no_known_allergies(data, prefix=""):
if prefix:
prefix += "-"
out = {
"request": {
"method": "PUT",
"url": "List/" + prefix + "List-" + data["id"]
},
"status": "current",
"resource": {
"id" : prefix + "List-" + data["id"],
... | [
"def",
"no_known_allergies",
"(",
"data",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"prefix",
":",
"prefix",
"+=",
"\"-\"",
"out",
"=",
"{",
"\"request\"",
":",
"{",
"\"method\"",
":",
"\"PUT\"",
",",
"\"url\"",
":",
"\"List/\"",
"+",
"prefix",
"+",
... | Builds and returns the List JSON | [
"Builds",
"and",
"returns",
"the",
"List",
"JSON"
] | [
"\"\"\"Builds and returns the List JSON\"\"\""
] | [
{
"param": "data",
"type": null
},
{
"param": "prefix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prefix",
"type": null,
"docstring": null,
"docstring_tokens":... |
f8b756f273b2db8c97d16ad9aeede806b2770b46 | ViktorMarinov/get-a-room | get_a_room/rooms/room_views.py | [
"MIT"
] | Python | filter | <not_specific> | def filter(self, request):
"""
Endpoint for filtering rooms by given query params
"""
ALLOWED_PARAMS = ['is_computer_room', 'capacity', 'min_capacity']
params = request.query_params.dict()
filter_params = {}
for key in params:
if key in ALLOWED_PARAMS... |
Endpoint for filtering rooms by given query params
| Endpoint for filtering rooms by given query params | [
"Endpoint",
"for",
"filtering",
"rooms",
"by",
"given",
"query",
"params"
] | def filter(self, request):
ALLOWED_PARAMS = ['is_computer_room', 'capacity', 'min_capacity']
params = request.query_params.dict()
filter_params = {}
for key in params:
if key in ALLOWED_PARAMS:
if key == 'is_computer_room':
filter_params[ke... | [
"def",
"filter",
"(",
"self",
",",
"request",
")",
":",
"ALLOWED_PARAMS",
"=",
"[",
"'is_computer_room'",
",",
"'capacity'",
",",
"'min_capacity'",
"]",
"params",
"=",
"request",
".",
"query_params",
".",
"dict",
"(",
")",
"filter_params",
"=",
"{",
"}",
"... | Endpoint for filtering rooms by given query params | [
"Endpoint",
"for",
"filtering",
"rooms",
"by",
"given",
"query",
"params"
] | [
"\"\"\"\n Endpoint for filtering rooms by given query params\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
f8b756f273b2db8c97d16ad9aeede806b2770b46 | ViktorMarinov/get-a-room | get_a_room/rooms/room_views.py | [
"MIT"
] | Python | find | <not_specific> | def find(self, request):
"""
Endpoint for finding free rooms for given dates and times.
If no end_date is given, the search is made for the start date only
Additional parameters:
* is_computer_room : filter results by is_computer_room property
* min_capacity : min... |
Endpoint for finding free rooms for given dates and times.
If no end_date is given, the search is made for the start date only
Additional parameters:
* is_computer_room : filter results by is_computer_room property
* min_capacity : minimum capacity for the room
| Endpoint for finding free rooms for given dates and times.
If no end_date is given, the search is made for the start date only
Additional parameters:
is_computer_room : filter results by is_computer_room property
min_capacity : minimum capacity for the room | [
"Endpoint",
"for",
"finding",
"free",
"rooms",
"for",
"given",
"dates",
"and",
"times",
".",
"If",
"no",
"end_date",
"is",
"given",
"the",
"search",
"is",
"made",
"for",
"the",
"start",
"date",
"only",
"Additional",
"parameters",
":",
"is_computer_room",
":"... | def find(self, request):
params = request.query_params.dict()
start_date = datetime.datetime.strptime(
params['start_date'], "%Y-%m-%d").date()
try:
end_date = datetime.datetime.strptime(
params['end_date'], "%Y-%m-%d").date()
except KeyError:
... | [
"def",
"find",
"(",
"self",
",",
"request",
")",
":",
"params",
"=",
"request",
".",
"query_params",
".",
"dict",
"(",
")",
"start_date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"params",
"[",
"'start_date'",
"]",
",",
"\"%Y-%m-%d\"",
")"... | Endpoint for finding free rooms for given dates and times. | [
"Endpoint",
"for",
"finding",
"free",
"rooms",
"for",
"given",
"dates",
"and",
"times",
"."
] | [
"\"\"\"\n Endpoint for finding free rooms for given dates and times.\n If no end_date is given, the search is made for the start date only\n Additional parameters:\n * is_computer_room : filter results by is_computer_room property\n * min_capacity : minimum capacity for th... | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
efa023b09a374576b8b7ad371a6e614afd8e9e25 | ViktorMarinov/get-a-room | get_a_room/accounts/views.py | [
"MIT"
] | Python | filter | <not_specific> | def filter(self, request):
"""
Filter users by the given query params.
"""
ALLOWED_PARAMS = {'username', 'role'}
params = request.query_params.dict()
params = {
key: params[key] for key in params if key in ALLOWED_PARAMS
}
try:
filt... |
Filter users by the given query params.
| Filter users by the given query params. | [
"Filter",
"users",
"by",
"the",
"given",
"query",
"params",
"."
] | def filter(self, request):
ALLOWED_PARAMS = {'username', 'role'}
params = request.query_params.dict()
params = {
key: params[key] for key in params if key in ALLOWED_PARAMS
}
try:
filtered_set = User.objects.filter(**params)
except:
ret... | [
"def",
"filter",
"(",
"self",
",",
"request",
")",
":",
"ALLOWED_PARAMS",
"=",
"{",
"'username'",
",",
"'role'",
"}",
"params",
"=",
"request",
".",
"query_params",
".",
"dict",
"(",
")",
"params",
"=",
"{",
"key",
":",
"params",
"[",
"key",
"]",
"fo... | Filter users by the given query params. | [
"Filter",
"users",
"by",
"the",
"given",
"query",
"params",
"."
] | [
"\"\"\"\n Filter users by the given query params.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
efa023b09a374576b8b7ad371a6e614afd8e9e25 | ViktorMarinov/get-a-room | get_a_room/accounts/views.py | [
"MIT"
] | Python | members | <not_specific> | def members(self, request, pk=None):
"""
Returns a list of the members of the group
"""
group = self.get_object()
members = group.user_set.all()
serializer = SimpleUserSerializer(
members,
many=True,
context={'request': request}
... |
Returns a list of the members of the group
| Returns a list of the members of the group | [
"Returns",
"a",
"list",
"of",
"the",
"members",
"of",
"the",
"group"
] | def members(self, request, pk=None):
group = self.get_object()
members = group.user_set.all()
serializer = SimpleUserSerializer(
members,
many=True,
context={'request': request}
)
return Response(serializer.data) | [
"def",
"members",
"(",
"self",
",",
"request",
",",
"pk",
"=",
"None",
")",
":",
"group",
"=",
"self",
".",
"get_object",
"(",
")",
"members",
"=",
"group",
".",
"user_set",
".",
"all",
"(",
")",
"serializer",
"=",
"SimpleUserSerializer",
"(",
"members... | Returns a list of the members of the group | [
"Returns",
"a",
"list",
"of",
"the",
"members",
"of",
"the",
"group"
] | [
"\"\"\"\n Returns a list of the members of the group\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "pk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
efa023b09a374576b8b7ad371a6e614afd8e9e25 | ViktorMarinov/get-a-room | get_a_room/accounts/views.py | [
"MIT"
] | Python | register | <not_specific> | def register(request):
"""
Endpoint for registration.
Does not require any permissions, so that anyone can access it.
"""
USER_FIELDS = ['username', 'password', 'email', 'role']
serialized = UserSerializer(data=request.data)
if serialized.is_valid(raise_exception=True):
user_data = {... |
Endpoint for registration.
Does not require any permissions, so that anyone can access it.
| Endpoint for registration.
Does not require any permissions, so that anyone can access it. | [
"Endpoint",
"for",
"registration",
".",
"Does",
"not",
"require",
"any",
"permissions",
"so",
"that",
"anyone",
"can",
"access",
"it",
"."
] | def register(request):
USER_FIELDS = ['username', 'password', 'email', 'role']
serialized = UserSerializer(data=request.data)
if serialized.is_valid(raise_exception=True):
user_data = {
field: data
for (field, data) in request.data.items()
if field in USER_FIELDS
... | [
"def",
"register",
"(",
"request",
")",
":",
"USER_FIELDS",
"=",
"[",
"'username'",
",",
"'password'",
",",
"'email'",
",",
"'role'",
"]",
"serialized",
"=",
"UserSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"if",
"serialized",
".",
"is_vali... | Endpoint for registration. | [
"Endpoint",
"for",
"registration",
"."
] | [
"\"\"\"\n Endpoint for registration.\n Does not require any permissions, so that anyone can access it.\n \"\"\""
] | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5db4f45702138708702d99a82a4b198b8fce374a | ViktorMarinov/get-a-room | get_a_room/rooms/models.py | [
"MIT"
] | Python | clean | null | def clean(self):
"""
Checks if the values of a new booking are valid
"""
if self.start_date > self.end_date:
raise serializers.ValidationError(
"Start date cannot be after end date!")
if self.start_date < datetime.datetime.now().date():
ra... |
Checks if the values of a new booking are valid
| Checks if the values of a new booking are valid | [
"Checks",
"if",
"the",
"values",
"of",
"a",
"new",
"booking",
"are",
"valid"
] | def clean(self):
if self.start_date > self.end_date:
raise serializers.ValidationError(
"Start date cannot be after end date!")
if self.start_date < datetime.datetime.now().date():
raise serializers.ValidationError(
"Start date cannot be in the pas... | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"self",
".",
"start_date",
">",
"self",
".",
"end_date",
":",
"raise",
"serializers",
".",
"ValidationError",
"(",
"\"Start date cannot be after end date!\"",
")",
"if",
"self",
".",
"start_date",
"<",
"datetime",
"... | Checks if the values of a new booking are valid | [
"Checks",
"if",
"the",
"values",
"of",
"a",
"new",
"booking",
"are",
"valid"
] | [
"\"\"\"\n Checks if the values of a new booking are valid\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5db4f45702138708702d99a82a4b198b8fce374a | ViktorMarinov/get-a-room | get_a_room/rooms/models.py | [
"MIT"
] | Python | check_time_slot | null | def check_time_slot(self, new_data):
"""
Checks if the time slot in new_data is available.
If a booking is getting updated then it is skipped
when checking the availability of the room.
"""
bookings_on_room = Booking.objects.filter(
room_number=new_data['room_... |
Checks if the time slot in new_data is available.
If a booking is getting updated then it is skipped
when checking the availability of the room.
| Checks if the time slot in new_data is available.
If a booking is getting updated then it is skipped
when checking the availability of the room. | [
"Checks",
"if",
"the",
"time",
"slot",
"in",
"new_data",
"is",
"available",
".",
"If",
"a",
"booking",
"is",
"getting",
"updated",
"then",
"it",
"is",
"skipped",
"when",
"checking",
"the",
"availability",
"of",
"the",
"room",
"."
] | def check_time_slot(self, new_data):
bookings_on_room = Booking.objects.filter(
room_number=new_data['room_number'])
id = None
if self is not None:
id = self.id
for booking in bookings_on_room:
if id is not None and id == booking.id:
co... | [
"def",
"check_time_slot",
"(",
"self",
",",
"new_data",
")",
":",
"bookings_on_room",
"=",
"Booking",
".",
"objects",
".",
"filter",
"(",
"room_number",
"=",
"new_data",
"[",
"'room_number'",
"]",
")",
"id",
"=",
"None",
"if",
"self",
"is",
"not",
"None",
... | Checks if the time slot in new_data is available. | [
"Checks",
"if",
"the",
"time",
"slot",
"in",
"new_data",
"is",
"available",
"."
] | [
"\"\"\"\n Checks if the time slot in new_data is available.\n If a booking is getting updated then it is skipped\n when checking the availability of the room.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "new_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_data",
"type": null,
"docstring": null,
"docstring_tokens... |
325865dde36a247f5d53dda095488dd24d3ad139 | ViktorMarinov/get-a-room | get_a_room/rooms/booking_views.py | [
"MIT"
] | Python | filter | <not_specific> | def filter(self, request):
"""
Endpoint for filtering bookings by given query parameters
"""
ALLOWED_PARAMS = {'room_number', 'user', 'start_date',
'end_date', 'day_of_week', 'start_time', 'end_time'}
params = request.query_params.dict()
params =... |
Endpoint for filtering bookings by given query parameters
| Endpoint for filtering bookings by given query parameters | [
"Endpoint",
"for",
"filtering",
"bookings",
"by",
"given",
"query",
"parameters"
] | def filter(self, request):
ALLOWED_PARAMS = {'room_number', 'user', 'start_date',
'end_date', 'day_of_week', 'start_time', 'end_time'}
params = request.query_params.dict()
params = {
key: params[key] for key in params if key in ALLOWED_PARAMS
}
... | [
"def",
"filter",
"(",
"self",
",",
"request",
")",
":",
"ALLOWED_PARAMS",
"=",
"{",
"'room_number'",
",",
"'user'",
",",
"'start_date'",
",",
"'end_date'",
",",
"'day_of_week'",
",",
"'start_time'",
",",
"'end_time'",
"}",
"params",
"=",
"request",
".",
"que... | Endpoint for filtering bookings by given query parameters | [
"Endpoint",
"for",
"filtering",
"bookings",
"by",
"given",
"query",
"parameters"
] | [
"\"\"\"\n Endpoint for filtering bookings by given query parameters\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
325865dde36a247f5d53dda095488dd24d3ad139 | ViktorMarinov/get-a-room | get_a_room/rooms/booking_views.py | [
"MIT"
] | Python | ondate | <not_specific> | def ondate(self, request):
"""
Endpoint for filtering booking for given date
"""
params = request.query_params.dict()
try:
date = datetime.datetime.strptime(
params['date'], "%Y-%m-%d").date()
day_of_week = DAYS_OF_THE_WEEK[date.weekday()][... |
Endpoint for filtering booking for given date
| Endpoint for filtering booking for given date | [
"Endpoint",
"for",
"filtering",
"booking",
"for",
"given",
"date"
] | def ondate(self, request):
params = request.query_params.dict()
try:
date = datetime.datetime.strptime(
params['date'], "%Y-%m-%d").date()
day_of_week = DAYS_OF_THE_WEEK[date.weekday()][0]
bookings = Booking.objects.filter(
start_date__... | [
"def",
"ondate",
"(",
"self",
",",
"request",
")",
":",
"params",
"=",
"request",
".",
"query_params",
".",
"dict",
"(",
")",
"try",
":",
"date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"params",
"[",
"'date'",
"]",
",",
"\"%Y-%m-%d\"",... | Endpoint for filtering booking for given date | [
"Endpoint",
"for",
"filtering",
"booking",
"for",
"given",
"date"
] | [
"\"\"\"\n Endpoint for filtering booking for given date\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
ba703f943838fb84e274aeecb115863b48126e58 | hotlib/magma | orc8r/gateway/python/scripts/generate_fluent_bit_config.py | [
"BSD-3-Clause"
] | Python | _get_extra_tags | <not_specific> | def _get_extra_tags():
"""
Get the extra_tags specified in the FluentBit mconfig.
"""
return load_service_mconfig('td-agent-bit', FluentBit()).extra_tags |
Get the extra_tags specified in the FluentBit mconfig.
| Get the extra_tags specified in the FluentBit mconfig. | [
"Get",
"the",
"extra_tags",
"specified",
"in",
"the",
"FluentBit",
"mconfig",
"."
] | def _get_extra_tags():
return load_service_mconfig('td-agent-bit', FluentBit()).extra_tags | [
"def",
"_get_extra_tags",
"(",
")",
":",
"return",
"load_service_mconfig",
"(",
"'td-agent-bit'",
",",
"FluentBit",
"(",
")",
")",
".",
"extra_tags"
] | Get the extra_tags specified in the FluentBit mconfig. | [
"Get",
"the",
"extra_tags",
"specified",
"in",
"the",
"FluentBit",
"mconfig",
"."
] | [
"\"\"\"\n Get the extra_tags specified in the FluentBit mconfig.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
182da3bb4d210c5ee2222b23063acf393618bd2b | hotlib/magma | lte/gateway/python/magma/captive_portal/rpc_servicer.py | [
"BSD-3-Clause"
] | Python | CreateSession | CreateSessionResponse | def CreateSession(
self,
request: CreateSessionRequest,
context,
) -> CreateSessionResponse:
"""
Handles create session request from MME by installing the necessary
flows in pipelined's enforcement app.
"""
logging.info('Creating a session for subscrib... |
Handles create session request from MME by installing the necessary
flows in pipelined's enforcement app.
| Handles create session request from MME by installing the necessary
flows in pipelined's enforcement app. | [
"Handles",
"create",
"session",
"request",
"from",
"MME",
"by",
"installing",
"the",
"necessary",
"flows",
"in",
"pipelined",
"'",
"s",
"enforcement",
"app",
"."
] | def CreateSession(
self,
request: CreateSessionRequest,
context,
) -> CreateSessionResponse:
logging.info('Creating a session for subscriber ID: %s',
request.subscriber.id)
return CreateSessionResponse(
credits=[self._get_credit_update_respons... | [
"def",
"CreateSession",
"(",
"self",
",",
"request",
":",
"CreateSessionRequest",
",",
"context",
",",
")",
"->",
"CreateSessionResponse",
":",
"logging",
".",
"info",
"(",
"'Creating a session for subscriber ID: %s'",
",",
"request",
".",
"subscriber",
".",
"id",
... | Handles create session request from MME by installing the necessary
flows in pipelined's enforcement app. | [
"Handles",
"create",
"session",
"request",
"from",
"MME",
"by",
"installing",
"the",
"necessary",
"flows",
"in",
"pipelined",
"'",
"s",
"enforcement",
"app",
"."
] | [
"\"\"\"\n Handles create session request from MME by installing the necessary\n flows in pipelined's enforcement app.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": "CreateSessionRequest"
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": "CreateSessionRequest",
"docstring": null,
... |
182da3bb4d210c5ee2222b23063acf393618bd2b | hotlib/magma | lte/gateway/python/magma/captive_portal/rpc_servicer.py | [
"BSD-3-Clause"
] | Python | UpdateSession | UpdateSessionResponse | def UpdateSession(
self,
request: UpdateSessionRequest,
context,
) -> UpdateSessionResponse:
"""
On UpdateSession, return an arbitrarily large amount of additional
credit for the session.
"""
logging.debug('Updating sessions')
resp ... |
On UpdateSession, return an arbitrarily large amount of additional
credit for the session.
| On UpdateSession, return an arbitrarily large amount of additional
credit for the session. | [
"On",
"UpdateSession",
"return",
"an",
"arbitrarily",
"large",
"amount",
"of",
"additional",
"credit",
"for",
"the",
"session",
"."
] | def UpdateSession(
self,
request: UpdateSessionRequest,
context,
) -> UpdateSessionResponse:
logging.debug('Updating sessions')
resp = UpdateSessionResponse()
for credit_usage_update in request.updates:
resp.responses.extend(
[s... | [
"def",
"UpdateSession",
"(",
"self",
",",
"request",
":",
"UpdateSessionRequest",
",",
"context",
",",
")",
"->",
"UpdateSessionResponse",
":",
"logging",
".",
"debug",
"(",
"'Updating sessions'",
")",
"resp",
"=",
"UpdateSessionResponse",
"(",
")",
"for",
"cred... | On UpdateSession, return an arbitrarily large amount of additional
credit for the session. | [
"On",
"UpdateSession",
"return",
"an",
"arbitrarily",
"large",
"amount",
"of",
"additional",
"credit",
"for",
"the",
"session",
"."
] | [
"\"\"\"\n On UpdateSession, return an arbitrarily large amount of additional\n credit for the session.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": "UpdateSessionRequest"
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": "UpdateSessionRequest",
"docstring": null,
... |
182da3bb4d210c5ee2222b23063acf393618bd2b | hotlib/magma | lte/gateway/python/magma/captive_portal/rpc_servicer.py | [
"BSD-3-Clause"
] | Python | _get_whitelist_rules | List[DynamicRuleInstall] | def _get_whitelist_rules(self) -> List[DynamicRuleInstall]:
"""
Get a list of dynamic rules to install for whitelisting.
These rules will whitelist traffic to/from the captive portal server.
"""
dynamic_rules = []
for ip, ports in self.ip_whitelist.items():
if... |
Get a list of dynamic rules to install for whitelisting.
These rules will whitelist traffic to/from the captive portal server.
| Get a list of dynamic rules to install for whitelisting.
These rules will whitelist traffic to/from the captive portal server. | [
"Get",
"a",
"list",
"of",
"dynamic",
"rules",
"to",
"install",
"for",
"whitelisting",
".",
"These",
"rules",
"will",
"whitelist",
"traffic",
"to",
"/",
"from",
"the",
"captive",
"portal",
"server",
"."
] | def _get_whitelist_rules(self) -> List[DynamicRuleInstall]:
dynamic_rules = []
for ip, ports in self.ip_whitelist.items():
if ip == 'local':
ip = '192.168.128.1'
for port in ports:
rule_id_info = {
'ip': ip,
... | [
"def",
"_get_whitelist_rules",
"(",
"self",
")",
"->",
"List",
"[",
"DynamicRuleInstall",
"]",
":",
"dynamic_rules",
"=",
"[",
"]",
"for",
"ip",
",",
"ports",
"in",
"self",
".",
"ip_whitelist",
".",
"items",
"(",
")",
":",
"if",
"ip",
"==",
"'local'",
... | Get a list of dynamic rules to install for whitelisting. | [
"Get",
"a",
"list",
"of",
"dynamic",
"rules",
"to",
"install",
"for",
"whitelisting",
"."
] | [
"\"\"\"\n Get a list of dynamic rules to install for whitelisting.\n These rules will whitelist traffic to/from the captive portal server.\n \"\"\"",
"# Build the rule id to be globally unique",
"# Activate now, and deactivate long in the future"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
182da3bb4d210c5ee2222b23063acf393618bd2b | hotlib/magma | lte/gateway/python/magma/captive_portal/rpc_servicer.py | [
"BSD-3-Clause"
] | Python | _get_default_qos | FlowQos | def _get_default_qos(self) -> FlowQos:
"""
Get a default QoS, usable for an allow-all flow, and for redirection to
a captive_portal.
"""
return FlowQos(
max_req_bw_ul=2 * 1024 * 1024 * 1024, # 2G
max_req_bw_dl=2 * 1024 * 1024 * 1024, # 2G
gbr... |
Get a default QoS, usable for an allow-all flow, and for redirection to
a captive_portal.
| Get a default QoS, usable for an allow-all flow, and for redirection to
a captive_portal. | [
"Get",
"a",
"default",
"QoS",
"usable",
"for",
"an",
"allow",
"-",
"all",
"flow",
"and",
"for",
"redirection",
"to",
"a",
"captive_portal",
"."
] | def _get_default_qos(self) -> FlowQos:
return FlowQos(
max_req_bw_ul=2 * 1024 * 1024 * 1024,
max_req_bw_dl=2 * 1024 * 1024 * 1024,
gbr_ul=1 * 1024 * 1024,
gbr_dl=1 * 1024 * 1024,
qci=FlowQos.Qci.Value('QCI_3'),
arp=QosArp(
... | [
"def",
"_get_default_qos",
"(",
"self",
")",
"->",
"FlowQos",
":",
"return",
"FlowQos",
"(",
"max_req_bw_ul",
"=",
"2",
"*",
"1024",
"*",
"1024",
"*",
"1024",
",",
"max_req_bw_dl",
"=",
"2",
"*",
"1024",
"*",
"1024",
"*",
"1024",
",",
"gbr_ul",
"=",
... | Get a default QoS, usable for an allow-all flow, and for redirection to
a captive_portal. | [
"Get",
"a",
"default",
"QoS",
"usable",
"for",
"an",
"allow",
"-",
"all",
"flow",
"and",
"for",
"redirection",
"to",
"a",
"captive_portal",
"."
] | [
"\"\"\"\n Get a default QoS, usable for an allow-all flow, and for redirection to\n a captive_portal.\n \"\"\"",
"# 2G",
"# 2G",
"# 1 Mb/s",
"# 1 Mb/s",
"# Allocation and Retention Policy",
"# Set to high priority, and disallow pre-emption",
"# capability/vulnerability"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
182da3bb4d210c5ee2222b23063acf393618bd2b | hotlib/magma | lte/gateway/python/magma/captive_portal/rpc_servicer.py | [
"BSD-3-Clause"
] | Python | _get_static_rule | StaticRuleInstall | def _get_static_rule(self) -> StaticRuleInstall:
""" Return a static rule for redirection to captive portal """
return StaticRuleInstall(
rule_id = self.redirect_rule_name,
) | Return a static rule for redirection to captive portal | Return a static rule for redirection to captive portal | [
"Return",
"a",
"static",
"rule",
"for",
"redirection",
"to",
"captive",
"portal"
] | def _get_static_rule(self) -> StaticRuleInstall:
return StaticRuleInstall(
rule_id = self.redirect_rule_name,
) | [
"def",
"_get_static_rule",
"(",
"self",
")",
"->",
"StaticRuleInstall",
":",
"return",
"StaticRuleInstall",
"(",
"rule_id",
"=",
"self",
".",
"redirect_rule_name",
",",
")"
] | Return a static rule for redirection to captive portal | [
"Return",
"a",
"static",
"rule",
"for",
"redirection",
"to",
"captive",
"portal"
] | [
"\"\"\" Return a static rule for redirection to captive portal \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | train | <not_specific> | def train(self, X, Y):
"""
Takes new X and Y to train.
"""
self.X = X
self.Y = Y
if X.size == 0 or Y.size == 0:
return
self.n,self.D = X.shape
self.Lambda0 = np.ones([self.n,1])*math.log(0.5);
self.Lambda0 = Param('Lambda0', self.Lambda... |
Takes new X and Y to train.
| Takes new X and Y to train. | [
"Takes",
"new",
"X",
"and",
"Y",
"to",
"train",
"."
] | def train(self, X, Y):
self.X = X
self.Y = Y
if X.size == 0 or Y.size == 0:
return
self.n,self.D = X.shape
self.Lambda0 = np.ones([self.n,1])*math.log(0.5);
self.Lambda0 = Param('Lambda0', self.Lambda0)
self.link_parameter(self.Lambda0,index=0)
... | [
"def",
"train",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"self",
".",
"X",
"=",
"X",
"self",
".",
"Y",
"=",
"Y",
"if",
"X",
".",
"size",
"==",
"0",
"or",
"Y",
".",
"size",
"==",
"0",
":",
"return",
"self",
".",
"n",
",",
"self",
".",
... | Takes new X and Y to train. | [
"Takes",
"new",
"X",
"and",
"Y",
"to",
"train",
"."
] | [
"\"\"\"\n Takes new X and Y to train.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "X",
"type": null
},
{
"param": "Y",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | optimize | null | def optimize(self):
"""
Optimizes by calling optimize_without_kernels and optimize_with_kernels with default steps in each.
"""
self.optimize_without_kernels();
self.optimize_with_kernels(); |
Optimizes by calling optimize_without_kernels and optimize_with_kernels with default steps in each.
| Optimizes by calling optimize_without_kernels and optimize_with_kernels with default steps in each. | [
"Optimizes",
"by",
"calling",
"optimize_without_kernels",
"and",
"optimize_with_kernels",
"with",
"default",
"steps",
"in",
"each",
"."
] | def optimize(self):
self.optimize_without_kernels();
self.optimize_with_kernels(); | [
"def",
"optimize",
"(",
"self",
")",
":",
"self",
".",
"optimize_without_kernels",
"(",
")",
";",
"self",
".",
"optimize_with_kernels",
"(",
")",
";"
] | Optimizes by calling optimize_without_kernels and optimize_with_kernels with default steps in each. | [
"Optimizes",
"by",
"calling",
"optimize_without_kernels",
"and",
"optimize_with_kernels",
"with",
"default",
"steps",
"in",
"each",
"."
] | [
"\"\"\"\n Optimizes by calling optimize_without_kernels and optimize_with_kernels with default steps in each.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | parameters_changed | null | def parameters_changed(self):
"""
Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model.
In particular in the GP class this method reperforms inference, recalculating the posterior and log marginal likelihood and gradients of the mod... |
Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model.
In particular in the GP class this method reperforms inference, recalculating the posterior and log marginal likelihood and gradients of the model
.. warning::
This... | Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model.
In particular in the GP class this method reperforms inference, recalculating the posterior and log marginal likelihood and gradients of the model
:
This method is not designed to be called manually, t... | [
"Method",
"that",
"is",
"called",
"upon",
"any",
"changes",
"to",
":",
"class",
":",
"`",
"~GPy",
".",
"core",
".",
"parameterization",
".",
"param",
".",
"Param",
"`",
"variables",
"within",
"the",
"model",
".",
"In",
"particular",
"in",
"the",
"GP",
... | def parameters_changed(self):
self.setup()
self.derivatives(True,True) | [
"def",
"parameters_changed",
"(",
"self",
")",
":",
"self",
".",
"setup",
"(",
")",
"self",
".",
"derivatives",
"(",
"True",
",",
"True",
")"
] | Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model. | [
"Method",
"that",
"is",
"called",
"upon",
"any",
"changes",
"to",
":",
"class",
":",
"`",
"~GPy",
".",
"core",
".",
"parameterization",
".",
"param",
".",
"Param",
"`",
"variables",
"within",
"the",
"model",
"."
] | [
"\"\"\"\n Method that is called upon any changes to :class:`~GPy.core.parameterization.param.Param` variables within the model.\n In particular in the GP class this method reperforms inference, recalculating the posterior and log marginal likelihood and gradients of the model\n\n .. warning::\n... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | optimize_without_kernels | null | def optimize_without_kernels(self, optimizer=None, start=None, **kwargs):
"""
Optimize the model without the kernels
kwargs are passed to the optimizer. They can be:
:param max_f_eval: maximum number of function evaluations
:type max_f_eval: int
:messages: whether to di... |
Optimize the model without the kernels
kwargs are passed to the optimizer. They can be:
:param max_f_eval: maximum number of function evaluations
:type max_f_eval: int
:messages: whether to display during optimisation
:type messages: bool
:param optimizer: whic... | Optimize the model without the kernels
kwargs are passed to the optimizer. They can be. | [
"Optimize",
"the",
"model",
"without",
"the",
"kernels",
"kwargs",
"are",
"passed",
"to",
"the",
"optimizer",
".",
"They",
"can",
"be",
"."
] | def optimize_without_kernels(self, optimizer=None, start=None, **kwargs):
if self.is_fixed or self.size == 0:
print('nothing to optimize')
if not self.update_model():
print("updates were off, setting updates on again")
self.update_model(True)
if start == None:... | [
"def",
"optimize_without_kernels",
"(",
"self",
",",
"optimizer",
"=",
"None",
",",
"start",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"is_fixed",
"or",
"self",
".",
"size",
"==",
"0",
":",
"print",
"(",
"'nothing to optimize'",
")",... | Optimize the model without the kernels
kwargs are passed to the optimizer. | [
"Optimize",
"the",
"model",
"without",
"the",
"kernels",
"kwargs",
"are",
"passed",
"to",
"the",
"optimizer",
"."
] | [
"\"\"\"\n Optimize the model without the kernels\n\n kwargs are passed to the optimizer. They can be:\n\n :param max_f_eval: maximum number of function evaluations\n :type max_f_eval: int\n :messages: whether to display during optimisation\n :type messages: bool\n :p... | [
{
"param": "self",
"type": null
},
{
"param": "optimizer",
"type": null
},
{
"param": "start",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "optimizer",
"type": null,
"docstring": "which optimizer to use (def... |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | optimize_with_kernels | null | def optimize_with_kernels(self, optimizer=None, start=None, **kwargs):
"""
Optimize the model with the kernels
kwargs are passed to the optimizer. They can be:
:param max_f_eval: maximum number of function evaluations
:type max_f_eval: int
:messages: whether to display ... |
Optimize the model with the kernels
kwargs are passed to the optimizer. They can be:
:param max_f_eval: maximum number of function evaluations
:type max_f_eval: int
:messages: whether to display during optimisation
:type messages: bool
:param optimizer: which o... | Optimize the model with the kernels
kwargs are passed to the optimizer. They can be. | [
"Optimize",
"the",
"model",
"with",
"the",
"kernels",
"kwargs",
"are",
"passed",
"to",
"the",
"optimizer",
".",
"They",
"can",
"be",
"."
] | def optimize_with_kernels(self, optimizer=None, start=None, **kwargs):
if self.is_fixed:
print 'nothing to optimize'
if self.size == 0:
print 'nothing to optimize'
if not self.update_model():
print "setting updates on again"
self.update_model(True)... | [
"def",
"optimize_with_kernels",
"(",
"self",
",",
"optimizer",
"=",
"None",
",",
"start",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"is_fixed",
":",
"print",
"'nothing to optimize'",
"if",
"self",
".",
"size",
"==",
"0",
":",
"print"... | Optimize the model with the kernels
kwargs are passed to the optimizer. | [
"Optimize",
"the",
"model",
"with",
"the",
"kernels",
"kwargs",
"are",
"passed",
"to",
"the",
"optimizer",
"."
] | [
"\"\"\"\n Optimize the model with the kernels\n\n kwargs are passed to the optimizer. They can be:\n\n :param max_f_eval: maximum number of function evaluations\n :type max_f_eval: int\n :messages: whether to display during optimisation\n :type messages: bool\n :para... | [
{
"param": "self",
"type": null
},
{
"param": "optimizer",
"type": null
},
{
"param": "start",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "optimizer",
"type": null,
"docstring": "which optimizer to use (def... |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | objective_function | <not_specific> | def objective_function(self):
"""
The objective function for the given algorithm.
"""
return self.obj_function |
The objective function for the given algorithm.
| The objective function for the given algorithm. | [
"The",
"objective",
"function",
"for",
"the",
"given",
"algorithm",
"."
] | def objective_function(self):
return self.obj_function | [
"def",
"objective_function",
"(",
"self",
")",
":",
"return",
"self",
".",
"obj_function"
] | The objective function for the given algorithm. | [
"The",
"objective",
"function",
"for",
"the",
"given",
"algorithm",
"."
] | [
"\"\"\"\n The objective function for the given algorithm.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | objective_function_gradients_without_kernels | <not_specific> | def objective_function_gradients_without_kernels(self):
"""
The gradients for the objective function without kernels
This function is the true objective, which wants to be minimized in case of training without kernels.
"""
allDerivates = np.append(self.derivate_obj_func,np.zeros(... |
The gradients for the objective function without kernels
This function is the true objective, which wants to be minimized in case of training without kernels.
| The gradients for the objective function without kernels
This function is the true objective, which wants to be minimized in case of training without kernels. | [
"The",
"gradients",
"for",
"the",
"objective",
"function",
"without",
"kernels",
"This",
"function",
"is",
"the",
"true",
"objective",
"which",
"wants",
"to",
"be",
"minimized",
"in",
"case",
"of",
"training",
"without",
"kernels",
"."
] | def objective_function_gradients_without_kernels(self):
allDerivates = np.append(self.derivate_obj_func,np.zeros([self.input_dim+1,1]))
allDerivates = np.append(allDerivates, np.zeros([self.input_dim+1,1]))
allDerivates = np.append(allDerivates, self.derivate_mean)
return allDerivates | [
"def",
"objective_function_gradients_without_kernels",
"(",
"self",
")",
":",
"allDerivates",
"=",
"np",
".",
"append",
"(",
"self",
".",
"derivate_obj_func",
",",
"np",
".",
"zeros",
"(",
"[",
"self",
".",
"input_dim",
"+",
"1",
",",
"1",
"]",
")",
")",
... | The gradients for the objective function without kernels
This function is the true objective, which wants to be minimized in case of training without kernels. | [
"The",
"gradients",
"for",
"the",
"objective",
"function",
"without",
"kernels",
"This",
"function",
"is",
"the",
"true",
"objective",
"which",
"wants",
"to",
"be",
"minimized",
"in",
"case",
"of",
"training",
"without",
"kernels",
"."
] | [
"\"\"\"\n The gradients for the objective function without kernels\n This function is the true objective, which wants to be minimized in case of training without kernels.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | objective_function_gradients_with_kernels | <not_specific> | def objective_function_gradients_with_kernels(self):
"""
The gradients for the objective function with kernels
This function is the true objective, which wants to be minimized in case of training with kernels.
"""
allDerivates = np.append(self.derivate_obj_func,self.derivate_mean... |
The gradients for the objective function with kernels
This function is the true objective, which wants to be minimized in case of training with kernels.
| The gradients for the objective function with kernels
This function is the true objective, which wants to be minimized in case of training with kernels. | [
"The",
"gradients",
"for",
"the",
"objective",
"function",
"with",
"kernels",
"This",
"function",
"is",
"the",
"true",
"objective",
"which",
"wants",
"to",
"be",
"minimized",
"in",
"case",
"of",
"training",
"with",
"kernels",
"."
] | def objective_function_gradients_with_kernels(self):
allDerivates = np.append(self.derivate_obj_func,self.derivate_mean_kernel_obj_func)
allDerivates = np.append(allDerivates, self.derivate_var_kernel_obj_func)
allDerivates = np.append(allDerivates, self.derivate_mean)
return allDerivate... | [
"def",
"objective_function_gradients_with_kernels",
"(",
"self",
")",
":",
"allDerivates",
"=",
"np",
".",
"append",
"(",
"self",
".",
"derivate_obj_func",
",",
"self",
".",
"derivate_mean_kernel_obj_func",
")",
"allDerivates",
"=",
"np",
".",
"append",
"(",
"allD... | The gradients for the objective function with kernels
This function is the true objective, which wants to be minimized in case of training with kernels. | [
"The",
"gradients",
"for",
"the",
"objective",
"function",
"with",
"kernels",
"This",
"function",
"is",
"the",
"true",
"objective",
"which",
"wants",
"to",
"be",
"minimized",
"in",
"case",
"of",
"training",
"with",
"kernels",
"."
] | [
"\"\"\"\n The gradients for the objective function with kernels\n This function is the true objective, which wants to be minimized in case of training with kernels.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | _grads_without_kernels | <not_specific> | def _grads_without_kernels(self, x):
"""
Gets the gradients from the likelihood and the priors without kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed.
... |
Gets the gradients from the likelihood and the priors without kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed.
:param x: the parameters of the model.
... | Gets the gradients from the likelihood and the priors without kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed. | [
"Gets",
"the",
"gradients",
"from",
"the",
"likelihood",
"and",
"the",
"priors",
"without",
"kernels",
"Failures",
"are",
"handled",
"robustly",
".",
"The",
"algorithm",
"will",
"try",
"several",
"times",
"to",
"return",
"the",
"gradients",
"and",
"will",
"rai... | def _grads_without_kernels(self, x):
try:
self.optimizer_array = x
self.obj_grads_without_kernels = self._transform_gradients(self.objective_function_gradients_without_kernels())
self._fail_count = 0
except (LinAlgError, ZeroDivisionError, ValueError):
if ... | [
"def",
"_grads_without_kernels",
"(",
"self",
",",
"x",
")",
":",
"try",
":",
"self",
".",
"optimizer_array",
"=",
"x",
"self",
".",
"obj_grads_without_kernels",
"=",
"self",
".",
"_transform_gradients",
"(",
"self",
".",
"objective_function_gradients_without_kernel... | Gets the gradients from the likelihood and the priors without kernels
Failures are handled robustly. | [
"Gets",
"the",
"gradients",
"from",
"the",
"likelihood",
"and",
"the",
"priors",
"without",
"kernels",
"Failures",
"are",
"handled",
"robustly",
"."
] | [
"\"\"\"\n Gets the gradients from the likelihood and the priors without kernels\n\n Failures are handled robustly. The algorithm will try several times to\n return the gradients, and will raise the original exception if\n the objective cannot be computed.\n\n :param x: the paramet... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": "the parameters of the model.",
... |
fa4e5d34aa2de589336747975a924e104243bab9 | Imdrail/GPy | GPy/models/new_gp_heteroscedastic_regression.py | [
"BSD-3-Clause"
] | Python | _grads_with_kernels | <not_specific> | def _grads_with_kernels(self, x):
"""
Gets the gradients from the likelihood and the priors with kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed.
... |
Gets the gradients from the likelihood and the priors with kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed.
:param x: the parameters of the model.
... | Gets the gradients from the likelihood and the priors with kernels
Failures are handled robustly. The algorithm will try several times to
return the gradients, and will raise the original exception if
the objective cannot be computed. | [
"Gets",
"the",
"gradients",
"from",
"the",
"likelihood",
"and",
"the",
"priors",
"with",
"kernels",
"Failures",
"are",
"handled",
"robustly",
".",
"The",
"algorithm",
"will",
"try",
"several",
"times",
"to",
"return",
"the",
"gradients",
"and",
"will",
"raise"... | def _grads_with_kernels(self, x):
try:
self.optimizer_array = x
self.obj_grads_with_kernels = self._transform_gradients(self.objective_function_gradients_with_kernels())
self._fail_count = 0
except (LinAlgError, ZeroDivisionError, ValueError):
if self._fai... | [
"def",
"_grads_with_kernels",
"(",
"self",
",",
"x",
")",
":",
"try",
":",
"self",
".",
"optimizer_array",
"=",
"x",
"self",
".",
"obj_grads_with_kernels",
"=",
"self",
".",
"_transform_gradients",
"(",
"self",
".",
"objective_function_gradients_with_kernels",
"("... | Gets the gradients from the likelihood and the priors with kernels
Failures are handled robustly. | [
"Gets",
"the",
"gradients",
"from",
"the",
"likelihood",
"and",
"the",
"priors",
"with",
"kernels",
"Failures",
"are",
"handled",
"robustly",
"."
] | [
"\"\"\"\n Gets the gradients from the likelihood and the priors with kernels\n\n Failures are handled robustly. The algorithm will try several times to\n return the gradients, and will raise the original exception if\n the objective cannot be computed.\n\n :param x: the parameters... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": "the parameters of the model.",
... |
1cc0c0ba859f29a77141f61e2bab68ee7c8c2e9e | Imdrail/GPy | GPy/kern/_src/kern.py | [
"BSD-3-Clause"
] | Python | gradients_XX_diag | null | def gradients_XX_diag(self, dL_dKdiag, X):
"""
The diagonal of the second derivative w.r.t. X and X2
"""
raise(NotImplementedError, "This is the diagonal of the second derivative of K wrt X and X2, and not implemented for this kernel") |
The diagonal of the second derivative w.r.t. X and X2
| The diagonal of the second derivative w.r.t. X and X2 | [
"The",
"diagonal",
"of",
"the",
"second",
"derivative",
"w",
".",
"r",
".",
"t",
".",
"X",
"and",
"X2"
] | def gradients_XX_diag(self, dL_dKdiag, X):
raise(NotImplementedError, "This is the diagonal of the second derivative of K wrt X and X2, and not implemented for this kernel") | [
"def",
"gradients_XX_diag",
"(",
"self",
",",
"dL_dKdiag",
",",
"X",
")",
":",
"raise",
"(",
"NotImplementedError",
",",
"\"This is the diagonal of the second derivative of K wrt X and X2, and not implemented for this kernel\"",
")"
] | The diagonal of the second derivative w.r.t. | [
"The",
"diagonal",
"of",
"the",
"second",
"derivative",
"w",
".",
"r",
".",
"t",
"."
] | [
"\"\"\"\n The diagonal of the second derivative w.r.t. X and X2\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "dL_dKdiag",
"type": null
},
{
"param": "X",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dL_dKdiag",
"type": null,
"docstring": null,
"docstring_token... |
1cc0c0ba859f29a77141f61e2bab68ee7c8c2e9e | Imdrail/GPy | GPy/kern/_src/kern.py | [
"BSD-3-Clause"
] | Python | input_sensitivity | null | def input_sensitivity(self, summarize=True):
"""
If summize is true, we want to get the summerized view of the sensitivities,
otherwise put everything into an array with shape (#kernels, input_dim)
in the order of appearance of the kernels in the parameterized object.
"""
... |
If summize is true, we want to get the summerized view of the sensitivities,
otherwise put everything into an array with shape (#kernels, input_dim)
in the order of appearance of the kernels in the parameterized object.
| If summize is true, we want to get the summerized view of the sensitivities,
otherwise put everything into an array with shape (#kernels, input_dim)
in the order of appearance of the kernels in the parameterized object. | [
"If",
"summize",
"is",
"true",
"we",
"want",
"to",
"get",
"the",
"summerized",
"view",
"of",
"the",
"sensitivities",
"otherwise",
"put",
"everything",
"into",
"an",
"array",
"with",
"shape",
"(",
"#kernels",
"input_dim",
")",
"in",
"the",
"order",
"of",
"a... | def input_sensitivity(self, summarize=True):
raise NotImplementedError("Choose the kernel you want to get the sensitivity for. You need to override the default behaviour for getting the input sensitivity to be able to get the input sensitivity. For sum kernel it is the sum of all sensitivities, TODO: product ke... | [
"def",
"input_sensitivity",
"(",
"self",
",",
"summarize",
"=",
"True",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Choose the kernel you want to get the sensitivity for. You need to override the default behaviour for getting the input sensitivity to be able to get the input sensitiv... | If summize is true, we want to get the summerized view of the sensitivities,
otherwise put everything into an array with shape (#kernels, input_dim)
in the order of appearance of the kernels in the parameterized object. | [
"If",
"summize",
"is",
"true",
"we",
"want",
"to",
"get",
"the",
"summerized",
"view",
"of",
"the",
"sensitivities",
"otherwise",
"put",
"everything",
"into",
"an",
"array",
"with",
"shape",
"(",
"#kernels",
"input_dim",
")",
"in",
"the",
"order",
"of",
"a... | [
"\"\"\"\n If summize is true, we want to get the summerized view of the sensitivities,\n otherwise put everything into an array with shape (#kernels, input_dim)\n in the order of appearance of the kernels in the parameterized object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "summarize",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "summarize",
"type": null,
"docstring": null,
"docstring_token... |
455976289d30b075b4492ec17f72117c3579b66e | Imdrail/GPy | GPy/plotting/matplot_dep/base_plots.py | [
"BSD-3-Clause"
] | Python | align_subplots | null | def align_subplots(N,M,xlim=None, ylim=None):
"""make all of the subplots have the same limits, turn off unnecessary ticks"""
#find sensible xlim,ylim
if xlim is None:
xlim = [np.inf,-np.inf]
for i in range(N*M):
pb.subplot(N,M,i+1)
xlim[0] = min(xlim[0],pb.xlim()[0])... | make all of the subplots have the same limits, turn off unnecessary ticks | make all of the subplots have the same limits, turn off unnecessary ticks | [
"make",
"all",
"of",
"the",
"subplots",
"have",
"the",
"same",
"limits",
"turn",
"off",
"unnecessary",
"ticks"
] | def align_subplots(N,M,xlim=None, ylim=None):
if xlim is None:
xlim = [np.inf,-np.inf]
for i in range(N*M):
pb.subplot(N,M,i+1)
xlim[0] = min(xlim[0],pb.xlim()[0])
xlim[1] = max(xlim[1],pb.xlim()[1])
if ylim is None:
ylim = [np.inf,-np.inf]
for... | [
"def",
"align_subplots",
"(",
"N",
",",
"M",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
")",
":",
"if",
"xlim",
"is",
"None",
":",
"xlim",
"=",
"[",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
"]",
"for",
"i",
"in",
"range",
"(",
... | make all of the subplots have the same limits, turn off unnecessary ticks | [
"make",
"all",
"of",
"the",
"subplots",
"have",
"the",
"same",
"limits",
"turn",
"off",
"unnecessary",
"ticks"
] | [
"\"\"\"make all of the subplots have the same limits, turn off unnecessary ticks\"\"\"",
"#find sensible xlim,ylim"
] | [
{
"param": "N",
"type": null
},
{
"param": "M",
"type": null
},
{
"param": "xlim",
"type": null
},
{
"param": "ylim",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "N",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "M",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
455976289d30b075b4492ec17f72117c3579b66e | Imdrail/GPy | GPy/plotting/matplot_dep/base_plots.py | [
"BSD-3-Clause"
] | Python | align_subplot_array | null | def align_subplot_array(axes,xlim=None, ylim=None):
"""
Make all of the axes in the array hae the same limits, turn off unnecessary ticks
use pb.subplots() to get an array of axes
"""
#find sensible xlim,ylim
if xlim is None:
xlim = [np.inf,-np.inf]
for ax in axes.flatten():
... |
Make all of the axes in the array hae the same limits, turn off unnecessary ticks
use pb.subplots() to get an array of axes
| Make all of the axes in the array hae the same limits, turn off unnecessary ticks
use pb.subplots() to get an array of axes | [
"Make",
"all",
"of",
"the",
"axes",
"in",
"the",
"array",
"hae",
"the",
"same",
"limits",
"turn",
"off",
"unnecessary",
"ticks",
"use",
"pb",
".",
"subplots",
"()",
"to",
"get",
"an",
"array",
"of",
"axes"
] | def align_subplot_array(axes,xlim=None, ylim=None):
if xlim is None:
xlim = [np.inf,-np.inf]
for ax in axes.flatten():
xlim[0] = min(xlim[0],ax.get_xlim()[0])
xlim[1] = max(xlim[1],ax.get_xlim()[1])
if ylim is None:
ylim = [np.inf,-np.inf]
for ax in axes.f... | [
"def",
"align_subplot_array",
"(",
"axes",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
")",
":",
"if",
"xlim",
"is",
"None",
":",
"xlim",
"=",
"[",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
"]",
"for",
"ax",
"in",
"axes",
".",
"flat... | Make all of the axes in the array hae the same limits, turn off unnecessary ticks
use pb.subplots() to get an array of axes | [
"Make",
"all",
"of",
"the",
"axes",
"in",
"the",
"array",
"hae",
"the",
"same",
"limits",
"turn",
"off",
"unnecessary",
"ticks",
"use",
"pb",
".",
"subplots",
"()",
"to",
"get",
"an",
"array",
"of",
"axes"
] | [
"\"\"\"\n Make all of the axes in the array hae the same limits, turn off unnecessary ticks\n use pb.subplots() to get an array of axes\n \"\"\"",
"#find sensible xlim,ylim"
] | [
{
"param": "axes",
"type": null
},
{
"param": "xlim",
"type": null
},
{
"param": "ylim",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "axes",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xlim",
"type": null,
"docstring": null,
"docstring_tokens": [... |
455976289d30b075b4492ec17f72117c3579b66e | Imdrail/GPy | GPy/plotting/matplot_dep/base_plots.py | [
"BSD-3-Clause"
] | Python | x_frame1D | <not_specific> | def x_frame1D(X,plot_limits=None,resolution=None):
"""
Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits
"""
assert X.shape[1] ==1, "x_frame1D is defined for one-dimensional inputs"
if plot_limits is None:
xmin,xmax = X.min(0),... |
Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits
| Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits | [
"Internal",
"helper",
"function",
"for",
"making",
"plots",
"returns",
"a",
"set",
"of",
"input",
"values",
"to",
"plot",
"as",
"well",
"as",
"lower",
"and",
"upper",
"limits"
] | def x_frame1D(X,plot_limits=None,resolution=None):
assert X.shape[1] ==1, "x_frame1D is defined for one-dimensional inputs"
if plot_limits is None:
xmin,xmax = X.min(0),X.max(0)
xmin, xmax = xmin-0.2*(xmax-xmin), xmax+0.2*(xmax-xmin)
elif len(plot_limits)==2:
xmin, xmax = plot_limits... | [
"def",
"x_frame1D",
"(",
"X",
",",
"plot_limits",
"=",
"None",
",",
"resolution",
"=",
"None",
")",
":",
"assert",
"X",
".",
"shape",
"[",
"1",
"]",
"==",
"1",
",",
"\"x_frame1D is defined for one-dimensional inputs\"",
"if",
"plot_limits",
"is",
"None",
":"... | Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits | [
"Internal",
"helper",
"function",
"for",
"making",
"plots",
"returns",
"a",
"set",
"of",
"input",
"values",
"to",
"plot",
"as",
"well",
"as",
"lower",
"and",
"upper",
"limits"
] | [
"\"\"\"\n Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits\n \"\"\""
] | [
{
"param": "X",
"type": null
},
{
"param": "plot_limits",
"type": null
},
{
"param": "resolution",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plot_limits",
"type": null,
"docstring": null,
"docstring_tokens... |
3c6f5f2e70863eed9705da5b310c36d0abeaffbe | capgadsx/kubespawner | kubespawner/objects.py | [
"BSD-3-Clause"
] | Python | make_pod | <not_specific> | def make_pod(
name,
cmd,
port,
image_spec,
image_pull_policy,
image_pull_secret=None,
node_selector=None,
run_as_uid=None,
run_as_gid=None,
fs_gid=None,
supplemental_gids=None,
run_privileged=False,
env={},
working_dir=None,
volumes=[],
volume_mounts=[],
... |
Make a k8s pod specification for running a user notebook.
Parameters
----------
name:
Name of pod. Must be unique within the namespace the object is
going to be created in. Must be a valid DNS label.
image_spec:
Image specification - usually a image name and tag in the form... | Make a k8s pod specification for running a user notebook.
Parameters
Name of pod. Must be unique within the namespace the object is
going to be created in. Must be a valid DNS label.
image_spec:
Image specification - usually a image name and tag in the form
of image_name:tag. | [
"Make",
"a",
"k8s",
"pod",
"specification",
"for",
"running",
"a",
"user",
"notebook",
".",
"Parameters",
"Name",
"of",
"pod",
".",
"Must",
"be",
"unique",
"within",
"the",
"namespace",
"the",
"object",
"is",
"going",
"to",
"be",
"created",
"in",
".",
"M... | def make_pod(
name,
cmd,
port,
image_spec,
image_pull_policy,
image_pull_secret=None,
node_selector=None,
run_as_uid=None,
run_as_gid=None,
fs_gid=None,
supplemental_gids=None,
run_privileged=False,
env={},
working_dir=None,
volumes=[],
volume_mounts=[],
... | [
"def",
"make_pod",
"(",
"name",
",",
"cmd",
",",
"port",
",",
"image_spec",
",",
"image_pull_policy",
",",
"image_pull_secret",
"=",
"None",
",",
"node_selector",
"=",
"None",
",",
"run_as_uid",
"=",
"None",
",",
"run_as_gid",
"=",
"None",
",",
"fs_gid",
"... | Make a k8s pod specification for running a user notebook. | [
"Make",
"a",
"k8s",
"pod",
"specification",
"for",
"running",
"a",
"user",
"notebook",
"."
] | [
"\"\"\"\n Make a k8s pod specification for running a user notebook.\n\n Parameters\n ----------\n name:\n Name of pod. Must be unique within the namespace the object is\n going to be created in. Must be a valid DNS label.\n image_spec:\n Image specification - usually a image name... | [
{
"param": "name",
"type": null
},
{
"param": "cmd",
"type": null
},
{
"param": "port",
"type": null
},
{
"param": "image_spec",
"type": null
},
{
"param": "image_pull_policy",
"type": null
},
{
"param": "image_pull_secret",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cmd",
"type": null,
"docstring": null,
"docstring_tokens": []... |
3c6f5f2e70863eed9705da5b310c36d0abeaffbe | capgadsx/kubespawner | kubespawner/objects.py | [
"BSD-3-Clause"
] | Python | make_pvc | <not_specific> | def make_pvc(
name,
storage_class,
access_modes,
storage,
labels,
annotations={}
):
"""
Make a k8s pvc specification for running a user notebook.
Parameters
----------
name:
Name of persistent volume claim. Must be unique within the namespace the object is
... |
Make a k8s pvc specification for running a user notebook.
Parameters
----------
name:
Name of persistent volume claim. Must be unique within the namespace the object is
going to be created in. Must be a valid DNS label.
storage_class:
String of the name of the k8s Storage C... | Make a k8s pvc specification for running a user notebook.
Parameters
Name of persistent volume claim. Must be unique within the namespace the object is
going to be created in. Must be a valid DNS label.
storage_class:
String of the name of the k8s Storage Class to use.
access_modes:
A list of specifying what access mo... | [
"Make",
"a",
"k8s",
"pvc",
"specification",
"for",
"running",
"a",
"user",
"notebook",
".",
"Parameters",
"Name",
"of",
"persistent",
"volume",
"claim",
".",
"Must",
"be",
"unique",
"within",
"the",
"namespace",
"the",
"object",
"is",
"going",
"to",
"be",
... | def make_pvc(
name,
storage_class,
access_modes,
storage,
labels,
annotations={}
):
pvc = V1PersistentVolumeClaim()
pvc.kind = "PersistentVolumeClaim"
pvc.api_version = "v1"
pvc.metadata = V1ObjectMeta()
pvc.metadata.name = name
pvc.metadata.annotations = annotations
... | [
"def",
"make_pvc",
"(",
"name",
",",
"storage_class",
",",
"access_modes",
",",
"storage",
",",
"labels",
",",
"annotations",
"=",
"{",
"}",
")",
":",
"pvc",
"=",
"V1PersistentVolumeClaim",
"(",
")",
"pvc",
".",
"kind",
"=",
"\"PersistentVolumeClaim\"",
"pvc... | Make a k8s pvc specification for running a user notebook. | [
"Make",
"a",
"k8s",
"pvc",
"specification",
"for",
"running",
"a",
"user",
"notebook",
"."
] | [
"\"\"\"\n Make a k8s pvc specification for running a user notebook.\n\n Parameters\n ----------\n name:\n Name of persistent volume claim. Must be unique within the namespace the object is\n going to be created in. Must be a valid DNS label.\n storage_class:\n String of the name ... | [
{
"param": "name",
"type": null
},
{
"param": "storage_class",
"type": null
},
{
"param": "access_modes",
"type": null
},
{
"param": "storage",
"type": null
},
{
"param": "labels",
"type": null
},
{
"param": "annotations",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage_class",
"type": null,
"docstring": null,
"docstring_t... |
3c6f5f2e70863eed9705da5b310c36d0abeaffbe | capgadsx/kubespawner | kubespawner/objects.py | [
"BSD-3-Clause"
] | Python | make_ingress | <not_specific> | def make_ingress(
name,
routespec,
target,
data
):
"""
Returns an ingress, service, endpoint object that'll work for this service
"""
meta = V1ObjectMeta(
name=name,
annotations={
'hub.jupyter.org/proxy-data': json.dumps(data),
'hub... |
Returns an ingress, service, endpoint object that'll work for this service
| Returns an ingress, service, endpoint object that'll work for this service | [
"Returns",
"an",
"ingress",
"service",
"endpoint",
"object",
"that",
"'",
"ll",
"work",
"for",
"this",
"service"
] | def make_ingress(
name,
routespec,
target,
data
):
meta = V1ObjectMeta(
name=name,
annotations={
'hub.jupyter.org/proxy-data': json.dumps(data),
'hub.jupyter.org/proxy-routespec': routespec,
'hub.jupyter.org/proxy-target': target
... | [
"def",
"make_ingress",
"(",
"name",
",",
"routespec",
",",
"target",
",",
"data",
")",
":",
"meta",
"=",
"V1ObjectMeta",
"(",
"name",
"=",
"name",
",",
"annotations",
"=",
"{",
"'hub.jupyter.org/proxy-data'",
":",
"json",
".",
"dumps",
"(",
"data",
")",
... | Returns an ingress, service, endpoint object that'll work for this service | [
"Returns",
"an",
"ingress",
"service",
"endpoint",
"object",
"that",
"'",
"ll",
"work",
"for",
"this",
"service"
] | [
"\"\"\"\n Returns an ingress, service, endpoint object that'll work for this service\n \"\"\"",
"# Make endpoint object",
"# Make service object",
"# Make Ingress object"
] | [
{
"param": "name",
"type": null
},
{
"param": "routespec",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "routespec",
"type": null,
"docstring": null,
"docstring_token... |
27d55cd6a10f13f9e9f89dbb910ce1db07d86714 | ArturMichalak/ElasticSearch-DSL-Playground | search/conftest.py | [
"MIT"
] | Python | fixture_dummy_response | <not_specific> | def fixture_dummy_response():
"""Returns the dictionary for comparison in tests"""
return {
"_shards": {
"failed": 0,
"successful": 10,
"total": 10
},
"hits": {
"hits": [
{
"_index": "blog",
... | Returns the dictionary for comparison in tests | Returns the dictionary for comparison in tests | [
"Returns",
"the",
"dictionary",
"for",
"comparison",
"in",
"tests"
] | def fixture_dummy_response():
return {
"_shards": {
"failed": 0,
"successful": 10,
"total": 10
},
"hits": {
"hits": [
{
"_index": "blog",
"_type": "_doc",
"_id": "1",
... | [
"def",
"fixture_dummy_response",
"(",
")",
":",
"return",
"{",
"\"_shards\"",
":",
"{",
"\"failed\"",
":",
"0",
",",
"\"successful\"",
":",
"10",
",",
"\"total\"",
":",
"10",
"}",
",",
"\"hits\"",
":",
"{",
"\"hits\"",
":",
"[",
"{",
"\"_index\"",
":",
... | Returns the dictionary for comparison in tests | [
"Returns",
"the",
"dictionary",
"for",
"comparison",
"in",
"tests"
] | [
"\"\"\"Returns the dictionary for comparison in tests\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4f117eb242021bdacb6d27bcf48c0e38dc332fe0 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/IO.py | [
"MIT"
] | Python | _generate_random_vector | <not_specific> | def _generate_random_vector(self, size):
"""
Generate a random vector from a uniform distribution between
-0.1 and 0.1.
"""
return np.random.uniform(-0.1, 0.1, size) |
Generate a random vector from a uniform distribution between
-0.1 and 0.1.
| Generate a random vector from a uniform distribution between
0.1 and 0.1. | [
"Generate",
"a",
"random",
"vector",
"from",
"a",
"uniform",
"distribution",
"between",
"0",
".",
"1",
"and",
"0",
".",
"1",
"."
] | def _generate_random_vector(self, size):
return np.random.uniform(-0.1, 0.1, size) | [
"def",
"_generate_random_vector",
"(",
"self",
",",
"size",
")",
":",
"return",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"0.1",
",",
"0.1",
",",
"size",
")"
] | Generate a random vector from a uniform distribution between
0.1 and 0.1. | [
"Generate",
"a",
"random",
"vector",
"from",
"a",
"uniform",
"distribution",
"between",
"0",
".",
"1",
"and",
"0",
".",
"1",
"."
] | [
"\"\"\"\n Generate a random vector from a uniform distribution between\n -0.1 and 0.1.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": null,
"docstring": null,
"docstring_tokens": [... |
4f117eb242021bdacb6d27bcf48c0e38dc332fe0 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/IO.py | [
"MIT"
] | Python | write_extra_embeddings | null | def write_extra_embeddings(self, embeddings, dirname):
"""
Write the extra embeddings (for unknown, padding and null)
to a numpy file. They are assumed to be the first three in
the embeddings model.
"""
path = os.path.join(dirname, 'extra-embeddings.npy')
torch.sa... |
Write the extra embeddings (for unknown, padding and null)
to a numpy file. They are assumed to be the first three in
the embeddings model.
| Write the extra embeddings (for unknown, padding and null)
to a numpy file. They are assumed to be the first three in
the embeddings model. | [
"Write",
"the",
"extra",
"embeddings",
"(",
"for",
"unknown",
"padding",
"and",
"null",
")",
"to",
"a",
"numpy",
"file",
".",
"They",
"are",
"assumed",
"to",
"be",
"the",
"first",
"three",
"in",
"the",
"embeddings",
"model",
"."
] | def write_extra_embeddings(self, embeddings, dirname):
path = os.path.join(dirname, 'extra-embeddings.npy')
torch.save(embeddings[:3], path) | [
"def",
"write_extra_embeddings",
"(",
"self",
",",
"embeddings",
",",
"dirname",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"'extra-embeddings.npy'",
")",
"torch",
".",
"save",
"(",
"embeddings",
"[",
":",
"3",
"]",
",",
... | Write the extra embeddings (for unknown, padding and null)
to a numpy file. | [
"Write",
"the",
"extra",
"embeddings",
"(",
"for",
"unknown",
"padding",
"and",
"null",
")",
"to",
"a",
"numpy",
"file",
"."
] | [
"\"\"\"\n Write the extra embeddings (for unknown, padding and null)\n to a numpy file. They are assumed to be the first three in\n the embeddings model.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "embeddings",
"type": null
},
{
"param": "dirname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "embeddings",
"type": null,
"docstring": null,
"docstring_toke... |
ad2eba88fa61dc280365948f79888b88445ed234 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/Utils.py | [
"MIT"
] | Python | count_corpus_tokens | <not_specific> | def count_corpus_tokens(self, pairs):
"""
Examine all pairs ans extracts all tokens from both text
and hypothesis.
:param pairs: a list of tuples (sent1, sent2, relation) with tokenized
sentences
:return: a Counter of lowercase tokens
"""
c = Counter()... |
Examine all pairs ans extracts all tokens from both text
and hypothesis.
:param pairs: a list of tuples (sent1, sent2, relation) with tokenized
sentences
:return: a Counter of lowercase tokens
| Examine all pairs ans extracts all tokens from both text
and hypothesis. | [
"Examine",
"all",
"pairs",
"ans",
"extracts",
"all",
"tokens",
"from",
"both",
"text",
"and",
"hypothesis",
"."
] | def count_corpus_tokens(self, pairs):
c = Counter()
for sent1, sent2, _ in pairs:
c.update(t.lower() for t in sent1)
c.update(t.lower() for t in sent2)
return c | [
"def",
"count_corpus_tokens",
"(",
"self",
",",
"pairs",
")",
":",
"c",
"=",
"Counter",
"(",
")",
"for",
"sent1",
",",
"sent2",
",",
"_",
"in",
"pairs",
":",
"c",
".",
"update",
"(",
"t",
".",
"lower",
"(",
")",
"for",
"t",
"in",
"sent1",
")",
... | Examine all pairs ans extracts all tokens from both text
and hypothesis. | [
"Examine",
"all",
"pairs",
"ans",
"extracts",
"all",
"tokens",
"from",
"both",
"text",
"and",
"hypothesis",
"."
] | [
"\"\"\"\n Examine all pairs ans extracts all tokens from both text\n and hypothesis.\n :param pairs: a list of tuples (sent1, sent2, relation) with tokenized\n sentences\n :return: a Counter of lowercase tokens\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pairs",
"type": null
}
] | {
"returns": [
{
"docstring": "a Counter of lowercase tokens",
"docstring_tokens": [
"a",
"Counter",
"of",
"lowercase",
"tokens"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"doc... |
ad2eba88fa61dc280365948f79888b88445ed234 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/Utils.py | [
"MIT"
] | Python | create_label_dict | <not_specific> | def create_label_dict(self, params, pairs):
"""
Return a dictionary mapping the labels found in `pairs` to numbers
:param pairs: a list of tuples (_, _, label), with label as a string
:return: a dict
"""
labels = set(pair[2] for pair in pairs)
mapping = zip(labels... |
Return a dictionary mapping the labels found in `pairs` to numbers
:param pairs: a list of tuples (_, _, label), with label as a string
:return: a dict
| Return a dictionary mapping the labels found in `pairs` to numbers | [
"Return",
"a",
"dictionary",
"mapping",
"the",
"labels",
"found",
"in",
"`",
"pairs",
"`",
"to",
"numbers"
] | def create_label_dict(self, params, pairs):
labels = set(pair[2] for pair in pairs)
mapping = zip(labels, range(len(labels)))
params.nr_classes = len(labels)
return dict(mapping) | [
"def",
"create_label_dict",
"(",
"self",
",",
"params",
",",
"pairs",
")",
":",
"labels",
"=",
"set",
"(",
"pair",
"[",
"2",
"]",
"for",
"pair",
"in",
"pairs",
")",
"mapping",
"=",
"zip",
"(",
"labels",
",",
"range",
"(",
"len",
"(",
"labels",
")",... | Return a dictionary mapping the labels found in `pairs` to numbers | [
"Return",
"a",
"dictionary",
"mapping",
"the",
"labels",
"found",
"in",
"`",
"pairs",
"`",
"to",
"numbers"
] | [
"\"\"\"\n Return a dictionary mapping the labels found in `pairs` to numbers\n :param pairs: a list of tuples (_, _, label), with label as a string\n :return: a dict\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "pairs",
"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
... |
ad2eba88fa61dc280365948f79888b88445ed234 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/Utils.py | [
"MIT"
] | Python | convert_labels | <not_specific> | def convert_labels(self, pairs, label_map):
"""
Return a numpy array representing the labels in `pairs`
:param pairs: a list of tuples (_, _, label), with label as a string
:param label_map: dictionary mapping label strings to numbers
:return: a numpy array
"""
re... |
Return a numpy array representing the labels in `pairs`
:param pairs: a list of tuples (_, _, label), with label as a string
:param label_map: dictionary mapping label strings to numbers
:return: a numpy array
| Return a numpy array representing the labels in `pairs` | [
"Return",
"a",
"numpy",
"array",
"representing",
"the",
"labels",
"in",
"`",
"pairs",
"`"
] | def convert_labels(self, pairs, label_map):
return np.array([label_map[pair[2]] for pair in pairs], dtype=np.int32) | [
"def",
"convert_labels",
"(",
"self",
",",
"pairs",
",",
"label_map",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"label_map",
"[",
"pair",
"[",
"2",
"]",
"]",
"for",
"pair",
"in",
"pairs",
"]",
",",
"dtype",
"=",
"np",
".",
"int32",
")"
] | Return a numpy array representing the labels in `pairs` | [
"Return",
"a",
"numpy",
"array",
"representing",
"the",
"labels",
"in",
"`",
"pairs",
"`"
] | [
"\"\"\"\n Return a numpy array representing the labels in `pairs`\n :param pairs: a list of tuples (_, _, label), with label as a string\n :param label_map: dictionary mapping label strings to numbers\n :return: a numpy array\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pairs",
"type": null
},
{
"param": "label_map",
"type": null
}
] | {
"returns": [
{
"docstring": "a numpy array",
"docstring_tokens": [
"a",
"numpy",
"array"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"de... |
ad2eba88fa61dc280365948f79888b88445ed234 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/Utils.py | [
"MIT"
] | Python | create_dataset | <not_specific> | def create_dataset(self, pairs, word_dict, label_dict=None,
max_len1=None, max_len2=None):
"""
Generate and return a NLIDataset object for storing the data in numpy
format.
:param pairs: list of tokenized tuples (sent1, sent2, label)
:param word_dict: a dic... |
Generate and return a NLIDataset object for storing the data in numpy
format.
:param pairs: list of tokenized tuples (sent1, sent2, label)
:param word_dict: a dictionary mapping words to indices
:param label_dict: a dictionary mapping labels to numbers. If None,
labe... | Generate and return a NLIDataset object for storing the data in numpy
format. | [
"Generate",
"and",
"return",
"a",
"NLIDataset",
"object",
"for",
"storing",
"the",
"data",
"in",
"numpy",
"format",
"."
] | def create_dataset(self, pairs, word_dict, label_dict=None,
max_len1=None, max_len2=None):
tokens1 = [pair[0] for pair in pairs]
tokens2 = [pair[1] for pair in pairs]
sentences1, sizes1 = self._convert_pairs_to_indices(tokens1, word_dict,
... | [
"def",
"create_dataset",
"(",
"self",
",",
"pairs",
",",
"word_dict",
",",
"label_dict",
"=",
"None",
",",
"max_len1",
"=",
"None",
",",
"max_len2",
"=",
"None",
")",
":",
"tokens1",
"=",
"[",
"pair",
"[",
"0",
"]",
"for",
"pair",
"in",
"pairs",
"]",... | Generate and return a NLIDataset object for storing the data in numpy
format. | [
"Generate",
"and",
"return",
"a",
"NLIDataset",
"object",
"for",
"storing",
"the",
"data",
"in",
"numpy",
"format",
"."
] | [
"\"\"\"\n Generate and return a NLIDataset object for storing the data in numpy\n format.\n :param pairs: list of tokenized tuples (sent1, sent2, label)\n :param word_dict: a dictionary mapping words to indices\n :param label_dict: a dictionary mapping labels to numbers. If None,\... | [
{
"param": "self",
"type": null
},
{
"param": "pairs",
"type": null
},
{
"param": "word_dict",
"type": null
},
{
"param": "label_dict",
"type": null
},
{
"param": "max_len1",
"type": null
},
{
"param": "max_len2",
"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
... |
ad2eba88fa61dc280365948f79888b88445ed234 | apsdehal/nli-batch-optimizations | parikh-et-al-and-bilstm-max-pool/modules/Utils.py | [
"MIT"
] | Python | normalize_embeddings | <not_specific> | def normalize_embeddings(self, embeddings):
"""
Normalize the embeddings to have norm 1.
:param embeddings: 2-d numpy array
:return: normalized embeddings
"""
# normalize embeddings
norms = np.linalg.norm(embeddings.numpy(), axis=1).reshape((-1, 1))
embedd... |
Normalize the embeddings to have norm 1.
:param embeddings: 2-d numpy array
:return: normalized embeddings
| Normalize the embeddings to have norm 1. | [
"Normalize",
"the",
"embeddings",
"to",
"have",
"norm",
"1",
"."
] | def normalize_embeddings(self, embeddings):
norms = np.linalg.norm(embeddings.numpy(), axis=1).reshape((-1, 1))
embeddings = torch.from_numpy(embeddings.numpy() / norms)
return embeddings | [
"def",
"normalize_embeddings",
"(",
"self",
",",
"embeddings",
")",
":",
"norms",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"embeddings",
".",
"numpy",
"(",
")",
",",
"axis",
"=",
"1",
")",
".",
"reshape",
"(",
"(",
"-",
"1",
",",
"1",
")",
")"... | Normalize the embeddings to have norm 1. | [
"Normalize",
"the",
"embeddings",
"to",
"have",
"norm",
"1",
"."
] | [
"\"\"\"\n Normalize the embeddings to have norm 1.\n :param embeddings: 2-d numpy array\n :return: normalized embeddings\n \"\"\"",
"# normalize embeddings"
] | [
{
"param": "self",
"type": null
},
{
"param": "embeddings",
"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
... |
ae225fcdf9c62f3dc27a8fbd8c6bde753768102d | apsdehal/nli-batch-optimizations | esim-chen-et-al-2016/model.py | [
"MIT"
] | Python | masked_softmax | <not_specific> | def masked_softmax(self,scores, mask):
"""
Used to calculcate a softmax score with true sequence length (without padding), rather than max-sequence length.
Input shape: (batch_size, max_seq_length, hidden_dim).
mask parameter: Tensor of shape (batch_size, max_seq_length). Such a mask is ... |
Used to calculcate a softmax score with true sequence length (without padding), rather than max-sequence length.
Input shape: (batch_size, max_seq_length, hidden_dim).
mask parameter: Tensor of shape (batch_size, max_seq_length). Such a mask is given by the length() function.
| Used to calculcate a softmax score with true sequence length (without padding), rather than max-sequence length. | [
"Used",
"to",
"calculcate",
"a",
"softmax",
"score",
"with",
"true",
"sequence",
"length",
"(",
"without",
"padding",
")",
"rather",
"than",
"max",
"-",
"sequence",
"length",
"."
] | def masked_softmax(self,scores, mask):
x=torch.exp((scores - torch.max(scores, 1, keepdim=True)[0])).squeeze()
y=mask.permute(1,0)
numerator = torch.mul(x,y).unsqueeze(2)
denominator = torch.sum(numerator, 1, keepdim=True)
weights = torch.div(numerator, denominator)
retur... | [
"def",
"masked_softmax",
"(",
"self",
",",
"scores",
",",
"mask",
")",
":",
"x",
"=",
"torch",
".",
"exp",
"(",
"(",
"scores",
"-",
"torch",
".",
"max",
"(",
"scores",
",",
"1",
",",
"keepdim",
"=",
"True",
")",
"[",
"0",
"]",
")",
")",
".",
... | Used to calculcate a softmax score with true sequence length (without padding), rather than max-sequence length. | [
"Used",
"to",
"calculcate",
"a",
"softmax",
"score",
"with",
"true",
"sequence",
"length",
"(",
"without",
"padding",
")",
"rather",
"than",
"max",
"-",
"sequence",
"length",
"."
] | [
"\"\"\"\n Used to calculcate a softmax score with true sequence length (without padding), rather than max-sequence length.\n Input shape: (batch_size, max_seq_length, hidden_dim).\n mask parameter: Tensor of shape (batch_size, max_seq_length). Such a mask is given by the length() function.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "scores",
"type": null
},
{
"param": "mask",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scores",
"type": null,
"docstring": null,
"docstring_tokens":... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | naked_twins | <not_specific> | def naked_twins(values):
"""Eliminate values using the naked twins strategy.
Args:
values(dict): a dictionary of the form {'box_name': '123456789', ...}
Returns:
the values dictionary with the naked twins eliminated from peers.
"""
"""
Find all instances of naked twins
... | Eliminate values using the naked twins strategy.
Args:
values(dict): a dictionary of the form {'box_name': '123456789', ...}
Returns:
the values dictionary with the naked twins eliminated from peers.
| Eliminate values using the naked twins strategy. | [
"Eliminate",
"values",
"using",
"the",
"naked",
"twins",
"strategy",
"."
] | def naked_twins(values):
import collections
sudoku_init()
global row_units
global column_units
global square_units
global boxes
global unitlist
global dia_units
ulist = [x for x in unitlist if x not in dia_units]
units = dict((s, [u for u in ulist if s in u]) for s in boxes)
... | [
"def",
"naked_twins",
"(",
"values",
")",
":",
"\"\"\"\r\n Find all instances of naked twins\r\n Eliminate the naked twins as possibilities for their peers\r\n \"\"\"",
"import",
"collections",
"sudoku_init",
"(",
")",
"global",
"row_units",
"global",
"column_units",
"global... | Eliminate values using the naked twins strategy. | [
"Eliminate",
"values",
"using",
"the",
"naked",
"twins",
"strategy",
"."
] | [
"\"\"\"Eliminate values using the naked twins strategy.\r\n Args:\r\n values(dict): a dictionary of the form {'box_name': '123456789', ...}\r\n\r\n Returns:\r\n the values dictionary with the naked twins eliminated from peers.\r\n \"\"\"",
"\"\"\"\r\n Find all instances of naked twins\r\... | [
{
"param": "values",
"type": null
}
] | {
"returns": [
{
"docstring": "the values dictionary with the naked twins eliminated from peers.",
"docstring_tokens": [
"the",
"values",
"dictionary",
"with",
"the",
"naked",
"twins",
"eliminated",
"from",
"peers",
... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | display | <not_specific> | def display(values, boxes, rows, cols):
"""
Display the values as a 2-D grid.
Args:
values(dict): The sudoku in dictionary form
"""
width = 1+max(len(values[s]) for s in boxes)
line = '+'.join(['-'*(width*3)]*3)
for r in rows:
print(''.join(values[r+c].center(width)+... |
Display the values as a 2-D grid.
Args:
values(dict): The sudoku in dictionary form
| Display the values as a 2-D grid. | [
"Display",
"the",
"values",
"as",
"a",
"2",
"-",
"D",
"grid",
"."
] | def display(values, boxes, rows, cols):
width = 1+max(len(values[s]) for s in boxes)
line = '+'.join(['-'*(width*3)]*3)
for r in rows:
print(''.join(values[r+c].center(width)+('|' if c in '36' else '')
for c in cols))
if r in 'CF': print(line)
return | [
"def",
"display",
"(",
"values",
",",
"boxes",
",",
"rows",
",",
"cols",
")",
":",
"width",
"=",
"1",
"+",
"max",
"(",
"len",
"(",
"values",
"[",
"s",
"]",
")",
"for",
"s",
"in",
"boxes",
")",
"line",
"=",
"'+'",
".",
"join",
"(",
"[",
"'-'",... | Display the values as a 2-D grid. | [
"Display",
"the",
"values",
"as",
"a",
"2",
"-",
"D",
"grid",
"."
] | [
"\"\"\"\r\n Display the values as a 2-D grid.\r\n Args:\r\n values(dict): The sudoku in dictionary form\r\n \"\"\""
] | [
{
"param": "values",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "rows",
"type": null
},
{
"param": "cols",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "values",
"type": null,
"docstring": "The sudoku in dictionary form",
"docstring_tokens": [
"The",
"sudoku",
"in",
"dictionary",
"form"
],
"default": null,
"is_optional"... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | eliminate | <not_specific> | def eliminate(values, peers, maj_dia, min_dia, boxes, rows, cols):
"""Eliminate values from peers of each box with a single value.
Go through all the boxes, and whenever there is a box with a single value,
eliminate this value from the set of values of all its peers. For diagonal
elements, check f... | Eliminate values from peers of each box with a single value.
Go through all the boxes, and whenever there is a box with a single value,
eliminate this value from the set of values of all its peers. For diagonal
elements, check for diagonal peers and eliminate.
Args:
values: Sudoku in di... | Eliminate values from peers of each box with a single value.
Go through all the boxes, and whenever there is a box with a single value,
eliminate this value from the set of values of all its peers. For diagonal
elements, check for diagonal peers and eliminate. | [
"Eliminate",
"values",
"from",
"peers",
"of",
"each",
"box",
"with",
"a",
"single",
"value",
".",
"Go",
"through",
"all",
"the",
"boxes",
"and",
"whenever",
"there",
"is",
"a",
"box",
"with",
"a",
"single",
"value",
"eliminate",
"this",
"value",
"from",
... | def eliminate(values, peers, maj_dia, min_dia, boxes, rows, cols):
solved_boxes = [key for key in values.keys() if len(values[key]) == 1]
for box in solved_boxes:
val = values[box]
for peer in peers[box]:
values = assign_value(values, peer, values[peer].replace(val,""))
if bo... | [
"def",
"eliminate",
"(",
"values",
",",
"peers",
",",
"maj_dia",
",",
"min_dia",
",",
"boxes",
",",
"rows",
",",
"cols",
")",
":",
"solved_boxes",
"=",
"[",
"key",
"for",
"key",
"in",
"values",
".",
"keys",
"(",
")",
"if",
"len",
"(",
"values",
"["... | Eliminate values from peers of each box with a single value. | [
"Eliminate",
"values",
"from",
"peers",
"of",
"each",
"box",
"with",
"a",
"single",
"value",
"."
] | [
"\"\"\"Eliminate values from peers of each box with a single value.\r\n\r\n Go through all the boxes, and whenever there is a box with a single value,\r\n eliminate this value from the set of values of all its peers. For diagonal\r\n elements, check for diagonal peers and eliminate.\r\n\r\n Args:\r\n ... | [
{
"param": "values",
"type": null
},
{
"param": "peers",
"type": null
},
{
"param": "maj_dia",
"type": null
},
{
"param": "min_dia",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "rows",
"type": null
},
{
"param": "cols",
... | {
"returns": [
{
"docstring": "Resulting Sudoku in dictionary form after eliminating values.",
"docstring_tokens": [
"Resulting",
"Sudoku",
"in",
"dictionary",
"form",
"after",
"eliminating",
"values",
"."
],
"type": n... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | only_choice | <not_specific> | def only_choice(values, unitlist):
"""Finalize all values that are the only choice for a unit.
Go through all the units, and whenever there is a unit with a value
that only fits in one box, assign the value to this box.
Input: Sudoku in dictionary form.
Output: Resulting Sudoku in dictionar... | Finalize all values that are the only choice for a unit.
Go through all the units, and whenever there is a unit with a value
that only fits in one box, assign the value to this box.
Input: Sudoku in dictionary form.
Output: Resulting Sudoku in dictionary form after filling in only choices.
| Finalize all values that are the only choice for a unit.
Go through all the units, and whenever there is a unit with a value
that only fits in one box, assign the value to this box.
Sudoku in dictionary form.
Output: Resulting Sudoku in dictionary form after filling in only choices. | [
"Finalize",
"all",
"values",
"that",
"are",
"the",
"only",
"choice",
"for",
"a",
"unit",
".",
"Go",
"through",
"all",
"the",
"units",
"and",
"whenever",
"there",
"is",
"a",
"unit",
"with",
"a",
"value",
"that",
"only",
"fits",
"in",
"one",
"box",
"assi... | def only_choice(values, unitlist):
for unit in unitlist:
for digit in '123456789':
loc = [box for box in unit if digit in values[box]]
if len(loc) == 1:
values[loc[0]] = digit
return values | [
"def",
"only_choice",
"(",
"values",
",",
"unitlist",
")",
":",
"for",
"unit",
"in",
"unitlist",
":",
"for",
"digit",
"in",
"'123456789'",
":",
"loc",
"=",
"[",
"box",
"for",
"box",
"in",
"unit",
"if",
"digit",
"in",
"values",
"[",
"box",
"]",
"]",
... | Finalize all values that are the only choice for a unit. | [
"Finalize",
"all",
"values",
"that",
"are",
"the",
"only",
"choice",
"for",
"a",
"unit",
"."
] | [
"\"\"\"Finalize all values that are the only choice for a unit.\r\n\r\n Go through all the units, and whenever there is a unit with a value\r\n that only fits in one box, assign the value to this box.\r\n\r\n Input: Sudoku in dictionary form.\r\n Output: Resulting Sudoku in dictionary form after filling... | [
{
"param": "values",
"type": null
},
{
"param": "unitlist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "values",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unitlist",
"type": null,
"docstring": null,
"docstring_toke... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | search | <not_specific> | def search(values, boxes, peers, maj_dia, min_dia, unitlist, rows, cols):
"Using depth-first search and propagation, create a search tree and to solve the sudoku."
" First, reduce the puzzle"
values = reduce_puzzle(values, peers, maj_dia, min_dia, unitlist, rows, cols, boxes)
if values is Fals... | Using depth-first search and propagation, create a search tree and to solve the sudoku. | Using depth-first search and propagation, create a search tree and to solve the sudoku. | [
"Using",
"depth",
"-",
"first",
"search",
"and",
"propagation",
"create",
"a",
"search",
"tree",
"and",
"to",
"solve",
"the",
"sudoku",
"."
] | def search(values, boxes, peers, maj_dia, min_dia, unitlist, rows, cols):
values = reduce_puzzle(values, peers, maj_dia, min_dia, unitlist, rows, cols, boxes)
if values is False:
return False
if all(len(values[s]) == 1 for s in boxes):
return values
unsolved_dict = dict((box,len(values... | [
"def",
"search",
"(",
"values",
",",
"boxes",
",",
"peers",
",",
"maj_dia",
",",
"min_dia",
",",
"unitlist",
",",
"rows",
",",
"cols",
")",
":",
"\" First, reduce the puzzle\"",
"values",
"=",
"reduce_puzzle",
"(",
"values",
",",
"peers",
",",
"maj_dia",
"... | Using depth-first search and propagation, create a search tree and to solve the sudoku. | [
"Using",
"depth",
"-",
"first",
"search",
"and",
"propagation",
"create",
"a",
"search",
"tree",
"and",
"to",
"solve",
"the",
"sudoku",
"."
] | [
"\"Using depth-first search and propagation, create a search tree and to solve the sudoku.\"",
"\" First, reduce the puzzle\"",
"# Failed in reduce_puzzle function.\r",
"\" Choose one of the unfilled squares with the fewest possibilities\"",
"\" Create a subset dictory of boxes with length value.\"",
"###... | [
{
"param": "values",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "peers",
"type": null
},
{
"param": "maj_dia",
"type": null
},
{
"param": "min_dia",
"type": null
},
{
"param": "unitlist",
"type": null
},
{
"param": "rows... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "values",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "boxes",
"type": null,
"docstring": null,
"docstring_tokens"... |
e4d45dbf334814d8555f9b6d0cfc145f21ab5b9f | vinodkrishnabangalore/AIND-Sudoku | solution.py | [
"Unlicense"
] | Python | solve | <not_specific> | def solve(grid):
"""
Find the solution to a Sudoku grid.
Args:
grid(string): a string representing a sudoku grid.
Example: '2.............62....1....7...6..8...3...9...7...6..4...4....8....52.............3'
Returns:
The dictionary representation of the final sudoku gri... |
Find the solution to a Sudoku grid.
Args:
grid(string): a string representing a sudoku grid.
Example: '2.............62....1....7...6..8...3...9...7...6..4...4....8....52.............3'
Returns:
The dictionary representation of the final sudoku grid. False if no solution e... | Find the solution to a Sudoku grid. | [
"Find",
"the",
"solution",
"to",
"a",
"Sudoku",
"grid",
"."
] | def solve(grid):
sudoku_init()
global row_units
global column_units
global dia_units
global unitlist
global units
values = grid_values(grid, boxes)
display(values, boxes, rows, cols)
values = search(values, boxes, peers, maj_dia, min_dia, unitlist, rows, cols)
display(values, box... | [
"def",
"solve",
"(",
"grid",
")",
":",
"sudoku_init",
"(",
")",
"global",
"row_units",
"global",
"column_units",
"global",
"dia_units",
"global",
"unitlist",
"global",
"units",
"values",
"=",
"grid_values",
"(",
"grid",
",",
"boxes",
")",
"display",
"(",
"va... | Find the solution to a Sudoku grid. | [
"Find",
"the",
"solution",
"to",
"a",
"Sudoku",
"grid",
"."
] | [
"\"\"\"\r\n Find the solution to a Sudoku grid.\r\n Args:\r\n grid(string): a string representing a sudoku grid.\r\n Example: '2.............62....1....7...6..8...3...9...7...6..4...4....8....52.............3'\r\n Returns:\r\n The dictionary representation of the final sudoku grid.... | [
{
"param": "grid",
"type": null
}
] | {
"returns": [
{
"docstring": "The dictionary representation of the final sudoku grid. False if no solution exists.",
"docstring_tokens": [
"The",
"dictionary",
"representation",
"of",
"the",
"final",
"sudoku",
"grid",
".",
... |
5ab6b44d5d89264d29973abc1d23060350a0ec0c | swvanderlaan/slideToolK | python_scribbles/slideTree.py | [
"MIT"
] | Python | _run_image | null | def _run_image(self, associated=None):
"""Run a single image from self._slide."""
if associated is None:
image = self._slide
if self._with_viewer:
basename = os.path.join(self._basename, VIEWER_SLIDE_NAME)
else:
basename = self._basenam... | Run a single image from self._slide. | Run a single image from self._slide. | [
"Run",
"a",
"single",
"image",
"from",
"self",
".",
"_slide",
"."
] | def _run_image(self, associated=None):
if associated is None:
image = self._slide
if self._with_viewer:
basename = os.path.join(self._basename, VIEWER_SLIDE_NAME)
else:
basename = self._basename
else:
image = ImageSlide(self... | [
"def",
"_run_image",
"(",
"self",
",",
"associated",
"=",
"None",
")",
":",
"if",
"associated",
"is",
"None",
":",
"image",
"=",
"self",
".",
"_slide",
"if",
"self",
".",
"_with_viewer",
":",
"basename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sel... | Run a single image from self._slide. | [
"Run",
"a",
"single",
"image",
"from",
"self",
".",
"_slide",
"."
] | [
"\"\"\"Run a single image from self._slide.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "associated",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "associated",
"type": null,
"docstring": null,
"docstring_toke... |
23ba4a9ad5ae71e00baf1d5bfe8ed43518748127 | SectorLabs/django-localized-fields | tests/test_bleach_field.py | [
"MIT"
] | Python | _validate | null | def _validate(non_bleached_value, bleached_value):
"""Validates whether the specified non-bleached value ended up being
correctly bleached.
Arguments:
non_bleached_value:
The value before bleaching.
bleached_value:
The value after bleachi... | Validates whether the specified non-bleached value ended up being
correctly bleached.
Arguments:
non_bleached_value:
The value before bleaching.
bleached_value:
The value after bleaching.
| Validates whether the specified non-bleached value ended up being
correctly bleached. | [
"Validates",
"whether",
"the",
"specified",
"non",
"-",
"bleached",
"value",
"ended",
"up",
"being",
"correctly",
"bleached",
"."
] | def _validate(non_bleached_value, bleached_value):
for lang_code, _ in settings.LANGUAGES:
if not non_bleached_value.get(lang_code):
assert not bleached_value.get(lang_code)
continue
expected_value = bleach.clean(
non_bleached_value.get(lan... | [
"def",
"_validate",
"(",
"non_bleached_value",
",",
"bleached_value",
")",
":",
"for",
"lang_code",
",",
"_",
"in",
"settings",
".",
"LANGUAGES",
":",
"if",
"not",
"non_bleached_value",
".",
"get",
"(",
"lang_code",
")",
":",
"assert",
"not",
"bleached_value",... | Validates whether the specified non-bleached value ended up being
correctly bleached. | [
"Validates",
"whether",
"the",
"specified",
"non",
"-",
"bleached",
"value",
"ended",
"up",
"being",
"correctly",
"bleached",
"."
] | [
"\"\"\"Validates whether the specified non-bleached value ended up being\n correctly bleached.\n\n Arguments:\n non_bleached_value:\n The value before bleaching.\n\n bleached_value:\n The value after bleaching.\n \"\"\""
] | [
{
"param": "non_bleached_value",
"type": null
},
{
"param": "bleached_value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "non_bleached_value",
"type": null,
"docstring": "The value before bleaching.",
"docstring_tokens": [
"The",
"value",
"before",
"bleaching",
"."
],
"default": null,
"is_... |
0a484e0a1b3ff290b47fdc0a680608c9d16a40ec | SectorLabs/django-localized-fields | setup.py | [
"MIT"
] | Python | create_command | <not_specific> | def create_command(text, commands):
"""Creates a custom setup.py command."""
class CustomCommand(BaseCommand):
description = text
def run(self):
for cmd in commands:
subprocess.check_call(cmd)
return CustomCommand | Creates a custom setup.py command. | Creates a custom setup.py command. | [
"Creates",
"a",
"custom",
"setup",
".",
"py",
"command",
"."
] | def create_command(text, commands):
class CustomCommand(BaseCommand):
description = text
def run(self):
for cmd in commands:
subprocess.check_call(cmd)
return CustomCommand | [
"def",
"create_command",
"(",
"text",
",",
"commands",
")",
":",
"class",
"CustomCommand",
"(",
"BaseCommand",
")",
":",
"description",
"=",
"text",
"def",
"run",
"(",
"self",
")",
":",
"for",
"cmd",
"in",
"commands",
":",
"subprocess",
".",
"check_call",
... | Creates a custom setup.py command. | [
"Creates",
"a",
"custom",
"setup",
".",
"py",
"command",
"."
] | [
"\"\"\"Creates a custom setup.py command.\"\"\""
] | [
{
"param": "text",
"type": null
},
{
"param": "commands",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commands",
"type": null,
"docstring": null,
"docstring_tokens... |
080a0082b4ea8069b429ed21ed1efd257c0ab04f | SectorLabs/django-localized-fields | localized_fields/fields/file_field.py | [
"MIT"
] | Python | pre_save | <not_specific> | def pre_save(self, model_instance, add):
"""Returns field's value just before saving."""
value = super().pre_save(model_instance, add)
if isinstance(value, LocalizedValue):
for file in value.__dict__.values():
if file and not file._committed:
file.... | Returns field's value just before saving. | Returns field's value just before saving. | [
"Returns",
"field",
"'",
"s",
"value",
"just",
"before",
"saving",
"."
] | def pre_save(self, model_instance, add):
value = super().pre_save(model_instance, add)
if isinstance(value, LocalizedValue):
for file in value.__dict__.values():
if file and not file._committed:
file.save(file.name, file, save=False)
return value | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"value",
"=",
"super",
"(",
")",
".",
"pre_save",
"(",
"model_instance",
",",
"add",
")",
"if",
"isinstance",
"(",
"value",
",",
"LocalizedValue",
")",
":",
"for",
"file",
"in... | Returns field's value just before saving. | [
"Returns",
"field",
"'",
"s",
"value",
"just",
"before",
"saving",
"."
] | [
"\"\"\"Returns field's value just before saving.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "model_instance",
"type": null
},
{
"param": "add",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_instance",
"type": null,
"docstring": null,
"docstring_... |
18fadfe09c2a0ef772de42c8d4dce0734c311d2b | SectorLabs/django-localized-fields | localized_fields/fields/bleach_field.py | [
"MIT"
] | Python | pre_save | <not_specific> | def pre_save(self, instance, add: bool):
"""Ran just before the model is saved, allows us to built the slug.
Arguments:
instance:
The model that is being saved.
add:
Indicates whether this is a new entry
to the database or an upda... | Ran just before the model is saved, allows us to built the slug.
Arguments:
instance:
The model that is being saved.
add:
Indicates whether this is a new entry
to the database or an update.
| Ran just before the model is saved, allows us to built the slug. | [
"Ran",
"just",
"before",
"the",
"model",
"is",
"saved",
"allows",
"us",
"to",
"built",
"the",
"slug",
"."
] | def pre_save(self, instance, add: bool):
try:
import bleach
from django_bleach.utils import get_bleach_default_options
except ImportError:
raise UserWarning(
"LocalizedBleachField is not compatible with Python 3.9 yet."
)
localized_... | [
"def",
"pre_save",
"(",
"self",
",",
"instance",
",",
"add",
":",
"bool",
")",
":",
"try",
":",
"import",
"bleach",
"from",
"django_bleach",
".",
"utils",
"import",
"get_bleach_default_options",
"except",
"ImportError",
":",
"raise",
"UserWarning",
"(",
"\"Loc... | Ran just before the model is saved, allows us to built the slug. | [
"Ran",
"just",
"before",
"the",
"model",
"is",
"saved",
"allows",
"us",
"to",
"built",
"the",
"slug",
"."
] | [
"\"\"\"Ran just before the model is saved, allows us to built the slug.\n\n Arguments:\n instance:\n The model that is being saved.\n\n add:\n Indicates whether this is a new entry\n to the database or an update.\n \"\"\"",
"# the bl... | [
{
"param": "self",
"type": null
},
{
"param": "instance",
"type": null
},
{
"param": "add",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "instance",
"type": null,
"docstring": "The model that is being save... |
721f7aab57c4283b82bc6e2a91f41ce81cc268b2 | SectorLabs/django-localized-fields | localized_fields/fields/float_field.py | [
"MIT"
] | Python | to_python | LocalizedFloatValue | def to_python(
self, value: Union[Dict[str, int], int, None]
) -> LocalizedFloatValue:
"""Converts the value from a database value into a Python value."""
db_value = super().to_python(value)
return self._convert_localized_value(db_value) | Converts the value from a database value into a Python value. | Converts the value from a database value into a Python value. | [
"Converts",
"the",
"value",
"from",
"a",
"database",
"value",
"into",
"a",
"Python",
"value",
"."
] | def to_python(
self, value: Union[Dict[str, int], int, None]
) -> LocalizedFloatValue:
db_value = super().to_python(value)
return self._convert_localized_value(db_value) | [
"def",
"to_python",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"int",
"]",
",",
"int",
",",
"None",
"]",
")",
"->",
"LocalizedFloatValue",
":",
"db_value",
"=",
"super",
"(",
")",
".",
"to_python",
"(",
"value",
")",
"re... | Converts the value from a database value into a Python value. | [
"Converts",
"the",
"value",
"from",
"a",
"database",
"value",
"into",
"a",
"Python",
"value",
"."
] | [
"\"\"\"Converts the value from a database value into a Python value.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": "Union[Dict[str, int], int, None]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": "Union[Dict[str, int], int, None]",
"docstring": nu... |
721f7aab57c4283b82bc6e2a91f41ce81cc268b2 | SectorLabs/django-localized-fields | localized_fields/fields/float_field.py | [
"MIT"
] | Python | formfield | <not_specific> | def formfield(self, **kwargs):
"""Gets the form field associated with this field."""
defaults = {"form_class": LocalizedIntegerFieldForm}
defaults.update(kwargs)
return super().formfield(**defaults) | Gets the form field associated with this field. | Gets the form field associated with this field. | [
"Gets",
"the",
"form",
"field",
"associated",
"with",
"this",
"field",
"."
] | def formfield(self, **kwargs):
defaults = {"form_class": LocalizedIntegerFieldForm}
defaults.update(kwargs)
return super().formfield(**defaults) | [
"def",
"formfield",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"\"form_class\"",
":",
"LocalizedIntegerFieldForm",
"}",
"defaults",
".",
"update",
"(",
"kwargs",
")",
"return",
"super",
"(",
")",
".",
"formfield",
"(",
"**",
"default... | Gets the form field associated with this field. | [
"Gets",
"the",
"form",
"field",
"associated",
"with",
"this",
"field",
"."
] | [
"\"\"\"Gets the form field associated with this field.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
32ebd35298c461706981dafadbfb9f9d6f96d01c | SectorLabs/django-localized-fields | localized_fields/forms.py | [
"MIT"
] | Python | clean | <not_specific> | def clean(self, value, initial=None):
"""Most part of this method is a copy of
django.forms.MultiValueField.clean, with the exception of initial value
handling (this need for correct processing FileField's).
All original comments saved.
"""
if initial is None:
... | Most part of this method is a copy of
django.forms.MultiValueField.clean, with the exception of initial value
handling (this need for correct processing FileField's).
All original comments saved.
| Most part of this method is a copy of
django.forms.MultiValueField.clean, with the exception of initial value
handling (this need for correct processing FileField's).
All original comments saved. | [
"Most",
"part",
"of",
"this",
"method",
"is",
"a",
"copy",
"of",
"django",
".",
"forms",
".",
"MultiValueField",
".",
"clean",
"with",
"the",
"exception",
"of",
"initial",
"value",
"handling",
"(",
"this",
"need",
"for",
"correct",
"processing",
"FileField",... | def clean(self, value, initial=None):
if initial is None:
initial = [None for x in range(0, len(value))]
else:
if not isinstance(initial, list):
initial = self.widget.decompress(initial)
clean_data = []
errors = []
if not value or isinstanc... | [
"def",
"clean",
"(",
"self",
",",
"value",
",",
"initial",
"=",
"None",
")",
":",
"if",
"initial",
"is",
"None",
":",
"initial",
"=",
"[",
"None",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"value",
")",
")",
"]",
"else",
":",
"if",
... | Most part of this method is a copy of
django.forms.MultiValueField.clean, with the exception of initial value
handling (this need for correct processing FileField's). | [
"Most",
"part",
"of",
"this",
"method",
"is",
"a",
"copy",
"of",
"django",
".",
"forms",
".",
"MultiValueField",
".",
"clean",
"with",
"the",
"exception",
"of",
"initial",
"value",
"handling",
"(",
"this",
"need",
"for",
"correct",
"processing",
"FileField",... | [
"\"\"\"Most part of this method is a copy of\n django.forms.MultiValueField.clean, with the exception of initial value\n handling (this need for correct processing FileField's).\n\n All original comments saved.\n \"\"\"",
"# Raise a 'required' error if the MultiValueField is",
"# req... | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "initial",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
a3d4b717e50742699927ca77ee05f110f76f11c5 | SectorLabs/django-localized-fields | localized_fields/fields/uniqueslug_field.py | [
"MIT"
] | Python | deconstruct | <not_specific> | def deconstruct(self):
"""Deconstructs the field into something the database can store."""
name, path, args, kwargs = super(
LocalizedUniqueSlugField, self
).deconstruct()
kwargs["populate_from"] = self.populate_from
kwargs["include_time"] = self.include_time
... | Deconstructs the field into something the database can store. | Deconstructs the field into something the database can store. | [
"Deconstructs",
"the",
"field",
"into",
"something",
"the",
"database",
"can",
"store",
"."
] | def deconstruct(self):
name, path, args, kwargs = super(
LocalizedUniqueSlugField, self
).deconstruct()
kwargs["populate_from"] = self.populate_from
kwargs["include_time"] = self.include_time
if self.enabled is False:
kwargs["enabled"] = self.enabled
... | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"LocalizedUniqueSlugField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"kwargs",
"[",
"\"populate_from\"",
"]",
"=",
"self",
".",
"popul... | Deconstructs the field into something the database can store. | [
"Deconstructs",
"the",
"field",
"into",
"something",
"the",
"database",
"can",
"store",
"."
] | [
"\"\"\"Deconstructs the field into something the database can store.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a3d4b717e50742699927ca77ee05f110f76f11c5 | SectorLabs/django-localized-fields | localized_fields/fields/uniqueslug_field.py | [
"MIT"
] | Python | pre_save | <not_specific> | def pre_save(self, instance, add: bool):
"""Ran just before the model is saved, allows us to built the slug.
Arguments:
instance:
The model that is being saved.
add:
Indicates whether this is a new entry
to the database or an upda... | Ran just before the model is saved, allows us to built the slug.
Arguments:
instance:
The model that is being saved.
add:
Indicates whether this is a new entry
to the database or an update.
Returns:
The localized slug... | Ran just before the model is saved, allows us to built the slug. | [
"Ran",
"just",
"before",
"the",
"model",
"is",
"saved",
"allows",
"us",
"to",
"built",
"the",
"slug",
"."
] | def pre_save(self, instance, add: bool):
if not self.enabled:
return getattr(instance, self.name)
if not isinstance(instance, AtomicSlugRetryMixin):
raise ImproperlyConfigured(
(
"Model '%s' does not inherit from AtomicSlugRetryMixin. "
... | [
"def",
"pre_save",
"(",
"self",
",",
"instance",
",",
"add",
":",
"bool",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"return",
"getattr",
"(",
"instance",
",",
"self",
".",
"name",
")",
"if",
"not",
"isinstance",
"(",
"instance",
",",
"Atomi... | Ran just before the model is saved, allows us to built the slug. | [
"Ran",
"just",
"before",
"the",
"model",
"is",
"saved",
"allows",
"us",
"to",
"built",
"the",
"slug",
"."
] | [
"\"\"\"Ran just before the model is saved, allows us to built the slug.\n\n Arguments:\n instance:\n The model that is being saved.\n\n add:\n Indicates whether this is a new entry\n to the database or an update.\n\n Returns:\n ... | [
{
"param": "self",
"type": null
},
{
"param": "instance",
"type": null
},
{
"param": "add",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "The localized slug that was generated.",
"docstring_tokens": [
"The",
"localized",
"slug",
"that",
"was",
"generated",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier... |
6b47fc7d1ba7fc6d333b3f1b1286db152561329c | SectorLabs/django-localized-fields | localized_fields/value.py | [
"MIT"
] | Python | _interpret_value | null | def _interpret_value(self, value):
"""Interprets a value passed in the constructor as a
:see:LocalizedValue.
If string:
Assumes it's the default language.
If dict:
Each key is a language and the value a string
in that language.
If list:
... | Interprets a value passed in the constructor as a
:see:LocalizedValue.
If string:
Assumes it's the default language.
If dict:
Each key is a language and the value a string
in that language.
If list:
Recurse into to apply rules above.
... | Interprets a value passed in the constructor as a | [
"Interprets",
"a",
"value",
"passed",
"in",
"the",
"constructor",
"as",
"a"
] | def _interpret_value(self, value):
for lang_code, _ in settings.LANGUAGES:
self.set(lang_code, self.default_value)
if callable(value):
value = value()
if isinstance(value, str):
self.set(settings.LANGUAGE_CODE, value)
elif isinstance(value, dict):
... | [
"def",
"_interpret_value",
"(",
"self",
",",
"value",
")",
":",
"for",
"lang_code",
",",
"_",
"in",
"settings",
".",
"LANGUAGES",
":",
"self",
".",
"set",
"(",
"lang_code",
",",
"self",
".",
"default_value",
")",
"if",
"callable",
"(",
"value",
")",
":... | Interprets a value passed in the constructor as a | [
"Interprets",
"a",
"value",
"passed",
"in",
"the",
"constructor",
"as",
"a"
] | [
"\"\"\"Interprets a value passed in the constructor as a\n :see:LocalizedValue.\n\n If string:\n Assumes it's the default language.\n\n If dict:\n Each key is a language and the value a string\n in that language.\n\n If list:\n Recurse into to ... | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
6b47fc7d1ba7fc6d333b3f1b1286db152561329c | SectorLabs/django-localized-fields | localized_fields/value.py | [
"MIT"
] | Python | translate | Optional[str] | def translate(self, language: Optional[str] = None) -> Optional[str]:
"""Gets the value in the specified language (or active language).
Arguments:
language:
The language to get the value in. If not specified,
the currently active language is used.
Re... | Gets the value in the specified language (or active language).
Arguments:
language:
The language to get the value in. If not specified,
the currently active language is used.
Returns:
The value in the specified (or active) language. If no value
... | Gets the value in the specified language (or active language). | [
"Gets",
"the",
"value",
"in",
"the",
"specified",
"language",
"(",
"or",
"active",
"language",
")",
"."
] | def translate(self, language: Optional[str] = None) -> Optional[str]:
target_language = (
language or translation.get_language() or settings.LANGUAGE_CODE
)
fallback_config = getattr(settings, "LOCALIZED_FIELDS_FALLBACKS", {})
target_languages = fallback_config.get(
... | [
"def",
"translate",
"(",
"self",
",",
"language",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"target_language",
"=",
"(",
"language",
"or",
"translation",
".",
"get_language",
"(",
")",
"or",
"settings",
... | Gets the value in the specified language (or active language). | [
"Gets",
"the",
"value",
"in",
"the",
"specified",
"language",
"(",
"or",
"active",
"language",
")",
"."
] | [
"\"\"\"Gets the value in the specified language (or active language).\n\n Arguments:\n language:\n The language to get the value in. If not specified,\n the currently active language is used.\n\n Returns:\n The value in the specified (or active) lang... | [
{
"param": "self",
"type": null
},
{
"param": "language",
"type": "Optional[str]"
}
] | {
"returns": [
{
"docstring": "The value in the specified (or active) language. If no value\nis available in the specified language, the value is returned\nin one of the fallback languages.",
"docstring_tokens": [
"The",
"value",
"in",
"the",
"specified",
... |
6b47fc7d1ba7fc6d333b3f1b1286db152561329c | SectorLabs/django-localized-fields | localized_fields/value.py | [
"MIT"
] | Python | is_empty | bool | def is_empty(self) -> bool:
"""Gets whether all the languages contain the default value."""
for lang_code, _ in settings.LANGUAGES:
if self.get(lang_code) != self.default_value:
return False
return True | Gets whether all the languages contain the default value. | Gets whether all the languages contain the default value. | [
"Gets",
"whether",
"all",
"the",
"languages",
"contain",
"the",
"default",
"value",
"."
] | def is_empty(self) -> bool:
for lang_code, _ in settings.LANGUAGES:
if self.get(lang_code) != self.default_value:
return False
return True | [
"def",
"is_empty",
"(",
"self",
")",
"->",
"bool",
":",
"for",
"lang_code",
",",
"_",
"in",
"settings",
".",
"LANGUAGES",
":",
"if",
"self",
".",
"get",
"(",
"lang_code",
")",
"!=",
"self",
".",
"default_value",
":",
"return",
"False",
"return",
"True"... | Gets whether all the languages contain the default value. | [
"Gets",
"whether",
"all",
"the",
"languages",
"contain",
"the",
"default",
"value",
"."
] | [
"\"\"\"Gets whether all the languages contain the default value.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47fc7d1ba7fc6d333b3f1b1286db152561329c | SectorLabs/django-localized-fields | localized_fields/value.py | [
"MIT"
] | Python | translate | <not_specific> | def translate(self):
"""Gets the value in the current language, or in the configured
fallback language."""
value = super().translate()
if value is None or (isinstance(value, str) and value.strip() == ""):
return None
return float(value) | Gets the value in the current language, or in the configured
fallback language. | Gets the value in the current language, or in the configured
fallback language. | [
"Gets",
"the",
"value",
"in",
"the",
"current",
"language",
"or",
"in",
"the",
"configured",
"fallback",
"language",
"."
] | def translate(self):
value = super().translate()
if value is None or (isinstance(value, str) and value.strip() == ""):
return None
return float(value) | [
"def",
"translate",
"(",
"self",
")",
":",
"value",
"=",
"super",
"(",
")",
".",
"translate",
"(",
")",
"if",
"value",
"is",
"None",
"or",
"(",
"isinstance",
"(",
"value",
",",
"str",
")",
"and",
"value",
".",
"strip",
"(",
")",
"==",
"\"\"",
")"... | Gets the value in the current language, or in the configured
fallback language. | [
"Gets",
"the",
"value",
"in",
"the",
"current",
"language",
"or",
"in",
"the",
"configured",
"fallback",
"language",
"."
] | [
"\"\"\"Gets the value in the current language, or in the configured\n fallback language.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.