repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
hydraplatform/hydra-base
hydra_base/lib/attributes.py
get_attribute_item_groups
def get_attribute_item_groups(network_id, attr_id, **kwargs): """ Get all the group items in a network with a given attribute_id """ user_id=kwargs.get('user_id') network_i = _get_network(network_id) network_i.check_read_permission(user_id) group_items_i = db.DBSession.query(AttrGroup...
python
def get_attribute_item_groups(network_id, attr_id, **kwargs): """ Get all the group items in a network with a given attribute_id """ user_id=kwargs.get('user_id') network_i = _get_network(network_id) network_i.check_read_permission(user_id) group_items_i = db.DBSession.query(AttrGroup...
[ "def", "get_attribute_item_groups", "(", "network_id", ",", "attr_id", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "network_i", "=", "_get_network", "(", "network_id", ")", "network_i", ".", "check_read_permi...
Get all the group items in a network with a given attribute_id
[ "Get", "all", "the", "group", "items", "in", "a", "network", "with", "a", "given", "attribute_id" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L825-L839
hydraplatform/hydra-base
hydra_base/lib/attributes.py
add_attribute_group_items
def add_attribute_group_items(attributegroupitems, **kwargs): """ Populate attribute groups with items. ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, ...
python
def add_attribute_group_items(attributegroupitems, **kwargs): """ Populate attribute groups with items. ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, ...
[ "def", "add_attribute_group_items", "(", "attributegroupitems", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "if", "not", "isinstance", "(", "attributegroupitems", ",", "list", ")", ":", "raise", "HydraError",...
Populate attribute groups with items. ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, }``` Note that this approach supports the possibility of populat...
[ "Populate", "attribute", "groups", "with", "items", ".", "**", "attributegroupitems", ":", "a", "list", "of", "items", "of", "the", "form", ":", "{", "attr_id", ":", "X", "group_id", ":", "Y", "network_id", ":", "Z", "}" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L853-L962
hydraplatform/hydra-base
hydra_base/lib/attributes.py
delete_attribute_group_items
def delete_attribute_group_items(attributegroupitems, **kwargs): """ remove attribute groups items . ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, ...
python
def delete_attribute_group_items(attributegroupitems, **kwargs): """ remove attribute groups items . ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, ...
[ "def", "delete_attribute_group_items", "(", "attributegroupitems", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "log", ".", "info", "(", "\"Deleting %s attribute group items\"", ",", "len", "(", "attributegroupite...
remove attribute groups items . ** attributegroupitems : a list of items, of the form: ```{ 'attr_id' : X, 'group_id' : Y, 'network_id' : Z, }```
[ "remove", "attribute", "groups", "items", ".", "**", "attributegroupitems", ":", "a", "list", "of", "items", "of", "the", "form", ":", "{", "attr_id", ":", "X", "group_id", ":", "Y", "network_id", ":", "Z", "}" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L964-L1010
hydraplatform/hydra-base
hydra_base/lib/sharing.py
share_network
def share_network(network_id, usernames, read_only, share,**kwargs): """ Share a network with a list of users, identified by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set to 'Y' to allow...
python
def share_network(network_id, usernames, read_only, share,**kwargs): """ Share a network with a list of users, identified by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set to 'Y' to allow...
[ "def", "share_network", "(", "network_id", ",", "usernames", ",", "read_only", ",", "share", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "net_i", "=", "_get_network", "(", "network_id", ")", "net_i", "....
Share a network with a list of users, identified by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set to 'Y' to allow the project to be shared with other users
[ "Share", "a", "network", "with", "a", "list", "of", "users", "identified", "by", "their", "usernames", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L57-L93
hydraplatform/hydra-base
hydra_base/lib/sharing.py
unshare_network
def unshare_network(network_id, usernames,**kwargs): """ Un-Share a network with a list of users, identified by their usernames. """ user_id = kwargs.get('user_id') net_i = _get_network(network_id) net_i.check_share_permission(user_id) for username in usernames: user_i = _get_u...
python
def unshare_network(network_id, usernames,**kwargs): """ Un-Share a network with a list of users, identified by their usernames. """ user_id = kwargs.get('user_id') net_i = _get_network(network_id) net_i.check_share_permission(user_id) for username in usernames: user_i = _get_u...
[ "def", "unshare_network", "(", "network_id", ",", "usernames", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "net_i", "=", "_get_network", "(", "network_id", ")", "net_i", ".", "check_share_permission", "(", ...
Un-Share a network with a list of users, identified by their usernames.
[ "Un", "-", "Share", "a", "network", "with", "a", "list", "of", "users", "identified", "by", "their", "usernames", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L95-L109
hydraplatform/hydra-base
hydra_base/lib/sharing.py
share_project
def share_project(project_id, usernames, read_only, share,**kwargs): """ Share an entire project with a list of users, identifed by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set ...
python
def share_project(project_id, usernames, read_only, share,**kwargs): """ Share an entire project with a list of users, identifed by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set ...
[ "def", "share_project", "(", "project_id", ",", "usernames", ",", "read_only", ",", "share", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "proj_i", "=", "_get_project", "(", "project_id", ")", "#Is the sha...
Share an entire project with a list of users, identifed by their usernames. The read_only flag ('Y' or 'N') must be set to 'Y' to allow write access or sharing. The share flat ('Y' or 'N') must be set to 'Y' to allow the project to be shared with other users
[ "Share", "an", "entire", "project", "with", "a", "list", "of", "users", "identifed", "by", "their", "usernames", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L111-L155
hydraplatform/hydra-base
hydra_base/lib/sharing.py
unshare_project
def unshare_project(project_id, usernames,**kwargs): """ Un-share a project with a list of users, identified by their usernames. """ user_id = kwargs.get('user_id') proj_i = _get_project(project_id) proj_i.check_share_permission(user_id) for username in usernames: user_i = _get...
python
def unshare_project(project_id, usernames,**kwargs): """ Un-share a project with a list of users, identified by their usernames. """ user_id = kwargs.get('user_id') proj_i = _get_project(project_id) proj_i.check_share_permission(user_id) for username in usernames: user_i = _get...
[ "def", "unshare_project", "(", "project_id", ",", "usernames", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "proj_i", "=", "_get_project", "(", "project_id", ")", "proj_i", ".", "check_share_permission", "("...
Un-share a project with a list of users, identified by their usernames.
[ "Un", "-", "share", "a", "project", "with", "a", "list", "of", "users", "identified", "by", "their", "usernames", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L157-L170
hydraplatform/hydra-base
hydra_base/lib/sharing.py
set_project_permission
def set_project_permission(project_id, usernames, read, write, share,**kwargs): """ Set permissions on a project to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is ...
python
def set_project_permission(project_id, usernames, read, write, share,**kwargs): """ Set permissions on a project to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is ...
[ "def", "set_project_permission", "(", "project_id", ",", "usernames", ",", "read", ",", "write", ",", "share", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "proj_i", "=", "_get_project", "(", "project_id",...
Set permissions on a project to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is automatically no write access or share access.
[ "Set", "permissions", "on", "a", "project", "to", "a", "list", "of", "users", "identifed", "by", "their", "usernames", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L172-L207
hydraplatform/hydra-base
hydra_base/lib/sharing.py
set_network_permission
def set_network_permission(network_id, usernames, read, write, share,**kwargs): """ Set permissions on a network to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is aut...
python
def set_network_permission(network_id, usernames, read, write, share,**kwargs): """ Set permissions on a network to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is aut...
[ "def", "set_network_permission", "(", "network_id", ",", "usernames", ",", "read", ",", "write", ",", "share", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "net_i", "=", "_get_network", "(", "network_id", ...
Set permissions on a network to a list of users, identifed by their usernames. The read flag ('Y' or 'N') sets read access, the write flag sets write access. If the read flag is 'N', then there is automatically no write access or share access.
[ "Set", "permissions", "on", "a", "network", "to", "a", "list", "of", "users", "identifed", "by", "their", "usernames", ".", "The", "read", "flag", "(", "Y", "or", "N", ")", "sets", "read", "access", "the", "write", "flag", "sets", "write", "access", "....
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L209-L241
hydraplatform/hydra-base
hydra_base/lib/sharing.py
hide_dataset
def hide_dataset(dataset_id, exceptions, read, write, share,**kwargs): """ Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with p...
python
def hide_dataset(dataset_id, exceptions, read, write, share,**kwargs): """ Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with p...
[ "def", "hide_dataset", "(", "dataset_id", ",", "exceptions", ",", "read", ",", "write", ",", "share", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "dataset_i", "=", "_get_dataset", "(", "dataset_id", ")"...
Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with permission to view the data read, write and share indicate whether these users c...
[ "Hide", "a", "particular", "piece", "of", "data", "so", "it", "can", "only", "be", "seen", "by", "its", "owner", ".", "Only", "an", "owner", "can", "hide", "(", "and", "unhide", ")", "data", ".", "Data", "with", "no", "owner", "cannot", "be", "hidden...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L243-L266
hydraplatform/hydra-base
hydra_base/lib/sharing.py
unhide_dataset
def unhide_dataset(dataset_id,**kwargs): """ Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with permission to view the data ...
python
def unhide_dataset(dataset_id,**kwargs): """ Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with permission to view the data ...
[ "def", "unhide_dataset", "(", "dataset_id", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "dataset_i", "=", "_get_dataset", "(", "dataset_id", ")", "#check that I can unhide the dataset", "if", "dataset_i", ".", ...
Hide a particular piece of data so it can only be seen by its owner. Only an owner can hide (and unhide) data. Data with no owner cannot be hidden. The exceptions paramater lists the usernames of those with permission to view the data read, write and share indicate whether these users c...
[ "Hide", "a", "particular", "piece", "of", "data", "so", "it", "can", "only", "be", "seen", "by", "its", "owner", ".", "Only", "an", "owner", "can", "hide", "(", "and", "unhide", ")", "data", ".", "Data", "with", "no", "owner", "cannot", "be", "hidden...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L268-L287
hydraplatform/hydra-base
hydra_base/lib/sharing.py
get_all_project_owners
def get_all_project_owners(project_ids=None, **kwargs): """ Get the project owner entries for all the requested projects. If the project_ids argument is None, return all the owner entries for ALL projects """ projowner_qry = db.DBSession.query(ProjectOwner) if project_ids is n...
python
def get_all_project_owners(project_ids=None, **kwargs): """ Get the project owner entries for all the requested projects. If the project_ids argument is None, return all the owner entries for ALL projects """ projowner_qry = db.DBSession.query(ProjectOwner) if project_ids is n...
[ "def", "get_all_project_owners", "(", "project_ids", "=", "None", ",", "*", "*", "kwargs", ")", ":", "projowner_qry", "=", "db", ".", "DBSession", ".", "query", "(", "ProjectOwner", ")", "if", "project_ids", "is", "not", "None", ":", "projowner_qry", "=", ...
Get the project owner entries for all the requested projects. If the project_ids argument is None, return all the owner entries for ALL projects
[ "Get", "the", "project", "owner", "entries", "for", "all", "the", "requested", "projects", ".", "If", "the", "project_ids", "argument", "is", "None", "return", "all", "the", "owner", "entries", "for", "ALL", "projects" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L290-L305
hydraplatform/hydra-base
hydra_base/lib/sharing.py
get_all_network_owners
def get_all_network_owners(network_ids=None, **kwargs): """ Get the network owner entries for all the requested networks. If the network_ids argument is None, return all the owner entries for ALL networks """ networkowner_qry = db.DBSession.query(NetworkOwner) if network_ids i...
python
def get_all_network_owners(network_ids=None, **kwargs): """ Get the network owner entries for all the requested networks. If the network_ids argument is None, return all the owner entries for ALL networks """ networkowner_qry = db.DBSession.query(NetworkOwner) if network_ids i...
[ "def", "get_all_network_owners", "(", "network_ids", "=", "None", ",", "*", "*", "kwargs", ")", ":", "networkowner_qry", "=", "db", ".", "DBSession", ".", "query", "(", "NetworkOwner", ")", "if", "network_ids", "is", "not", "None", ":", "networkowner_qry", "...
Get the network owner entries for all the requested networks. If the network_ids argument is None, return all the owner entries for ALL networks
[ "Get", "the", "network", "owner", "entries", "for", "all", "the", "requested", "networks", ".", "If", "the", "network_ids", "argument", "is", "None", "return", "all", "the", "owner", "entries", "for", "ALL", "networks" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L308-L323
hydraplatform/hydra-base
hydra_base/lib/sharing.py
bulk_set_project_owners
def bulk_set_project_owners(project_owners, **kwargs): """ Set the project owner of multiple projects at once. Accepts a list of JSONObjects which look like: { 'project_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'...
python
def bulk_set_project_owners(project_owners, **kwargs): """ Set the project owner of multiple projects at once. Accepts a list of JSONObjects which look like: { 'project_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'...
[ "def", "bulk_set_project_owners", "(", "project_owners", ",", "*", "*", "kwargs", ")", ":", "project_ids", "=", "[", "po", ".", "project_id", "for", "po", "in", "project_owners", "]", "existing_projowners", "=", "db", ".", "DBSession", ".", "query", "(", "Pr...
Set the project owner of multiple projects at once. Accepts a list of JSONObjects which look like: { 'project_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'/ 'N' 'share' : 'Y'/ 'N' }
[ "Set", "the", "project", "owner", "of", "multiple", "projects", "at", "once", ".", "Accepts", "a", "list", "of", "JSONObjects", "which", "look", "like", ":", "{", "project_id", ":", "XX", "user_id", ":", "YY", "view", ":", "Y", "/", "N", "edit", ":", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L326-L363
hydraplatform/hydra-base
hydra_base/lib/sharing.py
bulk_set_network_owners
def bulk_set_network_owners(network_owners, **kwargs): """ Set the network owner of multiple networks at once. Accepts a list of JSONObjects which look like: { 'network_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'...
python
def bulk_set_network_owners(network_owners, **kwargs): """ Set the network owner of multiple networks at once. Accepts a list of JSONObjects which look like: { 'network_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'...
[ "def", "bulk_set_network_owners", "(", "network_owners", ",", "*", "*", "kwargs", ")", ":", "network_ids", "=", "[", "no", ".", "network_id", "for", "no", "in", "network_owners", "]", "existing_projowners", "=", "db", ".", "DBSession", ".", "query", "(", "Ne...
Set the network owner of multiple networks at once. Accepts a list of JSONObjects which look like: { 'network_id': XX, 'user_id' : YY, 'view' : 'Y'/ 'N' 'edit' : 'Y'/ 'N' 'share' : 'Y'/ 'N' }
[ "Set", "the", "network", "owner", "of", "multiple", "networks", "at", "once", ".", "Accepts", "a", "list", "of", "JSONObjects", "which", "look", "like", ":", "{", "network_id", ":", "XX", "user_id", ":", "YY", "view", ":", "Y", "/", "N", "edit", ":", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/sharing.py#L366-L403
hydraplatform/hydra-base
hydra_base/lib/data.py
get_dataset
def get_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_id, ...
python
def get_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_id, ...
[ "def", "get_dataset", "(", "dataset_id", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "int", "(", "kwargs", ".", "get", "(", "'user_id'", ")", ")", "if", "dataset_id", "is", "None", ":", "return", "None", "try", ":", "dataset_rs", "=", "db", "....
Get a single dataset, by ID
[ "Get", "a", "single", "dataset", "by", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L63-L106
hydraplatform/hydra-base
hydra_base/lib/data.py
clone_dataset
def clone_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None dataset = db.DBSession.query(Dataset).filter( Dataset.id==dataset_id).options(joinedload_all('metadata')).first() if...
python
def clone_dataset(dataset_id,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) if dataset_id is None: return None dataset = db.DBSession.query(Dataset).filter( Dataset.id==dataset_id).options(joinedload_all('metadata')).first() if...
[ "def", "clone_dataset", "(", "dataset_id", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "int", "(", "kwargs", ".", "get", "(", "'user_id'", ")", ")", "if", "dataset_id", "is", "None", ":", "return", "None", "dataset", "=", "db", ".", "DBSession",...
Get a single dataset, by ID
[ "Get", "a", "single", "dataset", "by", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L108-L160
hydraplatform/hydra-base
hydra_base/lib/data.py
get_datasets
def get_datasets(dataset_ids,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) datasets = [] if len(dataset_ids) == 0: return [] try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_...
python
def get_datasets(dataset_ids,**kwargs): """ Get a single dataset, by ID """ user_id = int(kwargs.get('user_id')) datasets = [] if len(dataset_ids) == 0: return [] try: dataset_rs = db.DBSession.query(Dataset.id, Dataset.type, Dataset.unit_...
[ "def", "get_datasets", "(", "dataset_ids", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "int", "(", "kwargs", ".", "get", "(", "'user_id'", ")", ")", "datasets", "=", "[", "]", "if", "len", "(", "dataset_ids", ")", "==", "0", ":", "return", "...
Get a single dataset, by ID
[ "Get", "a", "single", "dataset", "by", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L162-L206
hydraplatform/hydra-base
hydra_base/lib/data.py
search_datasets
def search_datasets(dataset_id=None, dataset_name=None, collection_name=None, data_type=None, unit_id=None, scenario_id=None, metadata_key=None, metadata_val=None, attr_id = None, ...
python
def search_datasets(dataset_id=None, dataset_name=None, collection_name=None, data_type=None, unit_id=None, scenario_id=None, metadata_key=None, metadata_val=None, attr_id = None, ...
[ "def", "search_datasets", "(", "dataset_id", "=", "None", ",", "dataset_name", "=", "None", ",", "collection_name", "=", "None", ",", "data_type", "=", "None", ",", "unit_id", "=", "None", ",", "scenario_id", "=", "None", ",", "metadata_key", "=", "None", ...
Get multiple datasets, based on several filters. If all filters are set to None, all datasets in the DB (that the user is allowe to see) will be returned.
[ "Get", "multiple", "datasets", "based", "on", "several", "filters", ".", "If", "all", "filters", "are", "set", "to", "None", "all", "datasets", "in", "the", "DB", "(", "that", "the", "user", "is", "allowe", "to", "see", ")", "will", "be", "returned", "...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L210-L404
hydraplatform/hydra-base
hydra_base/lib/data.py
update_dataset
def update_dataset(dataset_id, name, data_type, val, unit_id, metadata={}, flush=True, **kwargs): """ Update an existing dataset """ if dataset_id is None: raise HydraError("Dataset must have an ID to be updated.") user_id = kwargs.get('user_id') dataset = db.DBSession.query(Datas...
python
def update_dataset(dataset_id, name, data_type, val, unit_id, metadata={}, flush=True, **kwargs): """ Update an existing dataset """ if dataset_id is None: raise HydraError("Dataset must have an ID to be updated.") user_id = kwargs.get('user_id') dataset = db.DBSession.query(Datas...
[ "def", "update_dataset", "(", "dataset_id", ",", "name", ",", "data_type", ",", "val", ",", "unit_id", ",", "metadata", "=", "{", "}", ",", "flush", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "dataset_id", "is", "None", ":", "raise", "Hydr...
Update an existing dataset
[ "Update", "an", "existing", "dataset" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L406-L462
hydraplatform/hydra-base
hydra_base/lib/data.py
add_dataset
def add_dataset(data_type, val, unit_id=None, metadata={}, name="", user_id=None, flush=False): """ Data can exist without scenarios. This is the mechanism whereby single pieces of data can be added without doing it through a scenario. A typical use of this would be for setting default valu...
python
def add_dataset(data_type, val, unit_id=None, metadata={}, name="", user_id=None, flush=False): """ Data can exist without scenarios. This is the mechanism whereby single pieces of data can be added without doing it through a scenario. A typical use of this would be for setting default valu...
[ "def", "add_dataset", "(", "data_type", ",", "val", ",", "unit_id", "=", "None", ",", "metadata", "=", "{", "}", ",", "name", "=", "\"\"", ",", "user_id", "=", "None", ",", "flush", "=", "False", ")", ":", "d", "=", "Dataset", "(", ")", "d", ".",...
Data can exist without scenarios. This is the mechanism whereby single pieces of data can be added without doing it through a scenario. A typical use of this would be for setting default values on types.
[ "Data", "can", "exist", "without", "scenarios", ".", "This", "is", "the", "mechanism", "whereby", "single", "pieces", "of", "data", "can", "be", "added", "without", "doing", "it", "through", "a", "scenario", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L465-L497
hydraplatform/hydra-base
hydra_base/lib/data.py
_bulk_insert_data
def _bulk_insert_data(bulk_data, user_id=None, source=None): """ Insert lots of datasets at once to reduce the number of DB interactions. user_id indicates the user adding the data source indicates the name of the app adding the data both user_id and source are added as metadata ...
python
def _bulk_insert_data(bulk_data, user_id=None, source=None): """ Insert lots of datasets at once to reduce the number of DB interactions. user_id indicates the user adding the data source indicates the name of the app adding the data both user_id and source are added as metadata ...
[ "def", "_bulk_insert_data", "(", "bulk_data", ",", "user_id", "=", "None", ",", "source", "=", "None", ")", ":", "get_timing", "=", "lambda", "x", ":", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "x", "start_time", "=", "datetime", ".", "da...
Insert lots of datasets at once to reduce the number of DB interactions. user_id indicates the user adding the data source indicates the name of the app adding the data both user_id and source are added as metadata
[ "Insert", "lots", "of", "datasets", "at", "once", "to", "reduce", "the", "number", "of", "DB", "interactions", ".", "user_id", "indicates", "the", "user", "adding", "the", "data", "source", "indicates", "the", "name", "of", "the", "app", "adding", "the", "...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L520-L612
hydraplatform/hydra-base
hydra_base/lib/data.py
_get_metadata
def _get_metadata(dataset_ids): """ Get all the metadata for a given list of datasets """ metadata = [] if len(dataset_ids) == 0: return [] if len(dataset_ids) > qry_in_threshold: idx = 0 extent = qry_in_threshold while idx < len(dataset_ids): log....
python
def _get_metadata(dataset_ids): """ Get all the metadata for a given list of datasets """ metadata = [] if len(dataset_ids) == 0: return [] if len(dataset_ids) > qry_in_threshold: idx = 0 extent = qry_in_threshold while idx < len(dataset_ids): log....
[ "def", "_get_metadata", "(", "dataset_ids", ")", ":", "metadata", "=", "[", "]", "if", "len", "(", "dataset_ids", ")", "==", "0", ":", "return", "[", "]", "if", "len", "(", "dataset_ids", ")", ">", "qry_in_threshold", ":", "idx", "=", "0", "extent", ...
Get all the metadata for a given list of datasets
[ "Get", "all", "the", "metadata", "for", "a", "given", "list", "of", "datasets" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L677-L702
hydraplatform/hydra-base
hydra_base/lib/data.py
_get_datasets
def _get_datasets(dataset_ids): """ Get all the datasets in a list of dataset IDS. This must be done in chunks of 999, as sqlite can only handle 'in' with < 1000 elements. """ dataset_dict = {} datasets = [] if len(dataset_ids) > qry_in_threshold: idx = 0 extent =qr...
python
def _get_datasets(dataset_ids): """ Get all the datasets in a list of dataset IDS. This must be done in chunks of 999, as sqlite can only handle 'in' with < 1000 elements. """ dataset_dict = {} datasets = [] if len(dataset_ids) > qry_in_threshold: idx = 0 extent =qr...
[ "def", "_get_datasets", "(", "dataset_ids", ")", ":", "dataset_dict", "=", "{", "}", "datasets", "=", "[", "]", "if", "len", "(", "dataset_ids", ")", ">", "qry_in_threshold", ":", "idx", "=", "0", "extent", "=", "qry_in_threshold", "while", "idx", "<", "...
Get all the datasets in a list of dataset IDS. This must be done in chunks of 999, as sqlite can only handle 'in' with < 1000 elements.
[ "Get", "all", "the", "datasets", "in", "a", "list", "of", "dataset", "IDS", ".", "This", "must", "be", "done", "in", "chunks", "of", "999", "as", "sqlite", "can", "only", "handle", "in", "with", "<", "1000", "elements", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L735-L766
hydraplatform/hydra-base
hydra_base/lib/data.py
_get_collection
def _get_collection(collection_id): """ Get a dataset collection by ID :param collection ID """ try: collection = db.DBSession.query(DatasetCollection).filter(DatasetCollection.id==collection_id).one() return collection except NoResultFound: raise ResourceNotFound...
python
def _get_collection(collection_id): """ Get a dataset collection by ID :param collection ID """ try: collection = db.DBSession.query(DatasetCollection).filter(DatasetCollection.id==collection_id).one() return collection except NoResultFound: raise ResourceNotFound...
[ "def", "_get_collection", "(", "collection_id", ")", ":", "try", ":", "collection", "=", "db", ".", "DBSession", ".", "query", "(", "DatasetCollection", ")", ".", "filter", "(", "DatasetCollection", ".", "id", "==", "collection_id", ")", ".", "one", "(", "...
Get a dataset collection by ID :param collection ID
[ "Get", "a", "dataset", "collection", "by", "ID", ":", "param", "collection", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L773-L782
hydraplatform/hydra-base
hydra_base/lib/data.py
_get_collection_item
def _get_collection_item(collection_id, dataset_id): """ Get a single dataset collection entry by collection ID and dataset ID :param collection ID :param dataset ID """ collection_item = db.DBSession.query(DatasetCollectionItem).\ filter(DatasetCollectionItem.collection_...
python
def _get_collection_item(collection_id, dataset_id): """ Get a single dataset collection entry by collection ID and dataset ID :param collection ID :param dataset ID """ collection_item = db.DBSession.query(DatasetCollectionItem).\ filter(DatasetCollectionItem.collection_...
[ "def", "_get_collection_item", "(", "collection_id", ",", "dataset_id", ")", ":", "collection_item", "=", "db", ".", "DBSession", ".", "query", "(", "DatasetCollectionItem", ")", ".", "filter", "(", "DatasetCollectionItem", ".", "collection_id", "==", "collection_id...
Get a single dataset collection entry by collection ID and dataset ID :param collection ID :param dataset ID
[ "Get", "a", "single", "dataset", "collection", "entry", "by", "collection", "ID", "and", "dataset", "ID", ":", "param", "collection", "ID", ":", "param", "dataset", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L784-L793
hydraplatform/hydra-base
hydra_base/lib/data.py
add_dataset_to_collection
def add_dataset_to_collection(dataset_id, collection_id, **kwargs): """ Add a single dataset to a dataset collection. """ collection_i = _get_collection(collection_id) collection_item = _get_collection_item(collection_id, dataset_id) if collection_item is not None: raise HydraError("...
python
def add_dataset_to_collection(dataset_id, collection_id, **kwargs): """ Add a single dataset to a dataset collection. """ collection_i = _get_collection(collection_id) collection_item = _get_collection_item(collection_id, dataset_id) if collection_item is not None: raise HydraError("...
[ "def", "add_dataset_to_collection", "(", "dataset_id", ",", "collection_id", ",", "*", "*", "kwargs", ")", ":", "collection_i", "=", "_get_collection", "(", "collection_id", ")", "collection_item", "=", "_get_collection_item", "(", "collection_id", ",", "dataset_id", ...
Add a single dataset to a dataset collection.
[ "Add", "a", "single", "dataset", "to", "a", "dataset", "collection", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L795-L812
hydraplatform/hydra-base
hydra_base/lib/data.py
remove_dataset_from_collection
def remove_dataset_from_collection(dataset_id, collection_id, **kwargs): """ Add a single dataset to a dataset collection. """ collection_i = _get_collection(collection_id) collection_item = _get_collection_item(collection_id, dataset_id) if collection_item is None: raise HydraError(...
python
def remove_dataset_from_collection(dataset_id, collection_id, **kwargs): """ Add a single dataset to a dataset collection. """ collection_i = _get_collection(collection_id) collection_item = _get_collection_item(collection_id, dataset_id) if collection_item is None: raise HydraError(...
[ "def", "remove_dataset_from_collection", "(", "dataset_id", ",", "collection_id", ",", "*", "*", "kwargs", ")", ":", "collection_i", "=", "_get_collection", "(", "collection_id", ")", "collection_item", "=", "_get_collection_item", "(", "collection_id", ",", "dataset_...
Add a single dataset to a dataset collection.
[ "Add", "a", "single", "dataset", "to", "a", "dataset", "collection", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L835-L850
hydraplatform/hydra-base
hydra_base/lib/data.py
check_dataset_in_collection
def check_dataset_in_collection(dataset_id, collection_id, **kwargs): """ Check whether a dataset is contained inside a collection :param dataset ID :param collection ID :returns 'Y' or 'N' """ _get_collection(collection_id) collection_item = _get_collection_item(collect...
python
def check_dataset_in_collection(dataset_id, collection_id, **kwargs): """ Check whether a dataset is contained inside a collection :param dataset ID :param collection ID :returns 'Y' or 'N' """ _get_collection(collection_id) collection_item = _get_collection_item(collect...
[ "def", "check_dataset_in_collection", "(", "dataset_id", ",", "collection_id", ",", "*", "*", "kwargs", ")", ":", "_get_collection", "(", "collection_id", ")", "collection_item", "=", "_get_collection_item", "(", "collection_id", ",", "dataset_id", ")", "if", "colle...
Check whether a dataset is contained inside a collection :param dataset ID :param collection ID :returns 'Y' or 'N'
[ "Check", "whether", "a", "dataset", "is", "contained", "inside", "a", "collection", ":", "param", "dataset", "ID", ":", "param", "collection", "ID", ":", "returns", "Y", "or", "N" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L853-L866
hydraplatform/hydra-base
hydra_base/lib/data.py
get_collections_like_name
def get_collections_like_name(collection_name,**kwargs): """ Get all the datasets from the collection with the specified name """ try: collections = db.DBSession.query(DatasetCollection).filter(DatasetCollection.name.like("%%%s%%"%collection_name.lower())).all() except NoResultFound: ...
python
def get_collections_like_name(collection_name,**kwargs): """ Get all the datasets from the collection with the specified name """ try: collections = db.DBSession.query(DatasetCollection).filter(DatasetCollection.name.like("%%%s%%"%collection_name.lower())).all() except NoResultFound: ...
[ "def", "get_collections_like_name", "(", "collection_name", ",", "*", "*", "kwargs", ")", ":", "try", ":", "collections", "=", "db", ".", "DBSession", ".", "query", "(", "DatasetCollection", ")", ".", "filter", "(", "DatasetCollection", ".", "name", ".", "li...
Get all the datasets from the collection with the specified name
[ "Get", "all", "the", "datasets", "from", "the", "collection", "with", "the", "specified", "name" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L907-L916
hydraplatform/hydra-base
hydra_base/lib/data.py
get_collection_datasets
def get_collection_datasets(collection_id,**kwargs): """ Get all the datasets from the collection with the specified name """ collection_datasets = db.DBSession.query(Dataset).filter(Dataset.id==DatasetCollectionItem.dataset_id, DatasetCollectionItem.collectio...
python
def get_collection_datasets(collection_id,**kwargs): """ Get all the datasets from the collection with the specified name """ collection_datasets = db.DBSession.query(Dataset).filter(Dataset.id==DatasetCollectionItem.dataset_id, DatasetCollectionItem.collectio...
[ "def", "get_collection_datasets", "(", "collection_id", ",", "*", "*", "kwargs", ")", ":", "collection_datasets", "=", "db", ".", "DBSession", ".", "query", "(", "Dataset", ")", ".", "filter", "(", "Dataset", ".", "id", "==", "DatasetCollectionItem", ".", "d...
Get all the datasets from the collection with the specified name
[ "Get", "all", "the", "datasets", "from", "the", "collection", "with", "the", "specified", "name" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L918-L925
hydraplatform/hydra-base
hydra_base/lib/data.py
get_val_at_time
def get_val_at_time(dataset_id, timestamps,**kwargs): """ Given a timestamp (or list of timestamps) and some timeseries data, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after the end of the times...
python
def get_val_at_time(dataset_id, timestamps,**kwargs): """ Given a timestamp (or list of timestamps) and some timeseries data, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after the end of the times...
[ "def", "get_val_at_time", "(", "dataset_id", ",", "timestamps", ",", "*", "*", "kwargs", ")", ":", "t", "=", "[", "]", "for", "time", "in", "timestamps", ":", "t", ".", "append", "(", "get_datetime", "(", "time", ")", ")", "dataset_i", "=", "db", "."...
Given a timestamp (or list of timestamps) and some timeseries data, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after the end of the timeseries data, return the last value.
[ "Given", "a", "timestamp", "(", "or", "list", "of", "timestamps", ")", "and", "some", "timeseries", "data", "return", "the", "values", "appropriate", "to", "the", "requested", "times", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L927-L948
hydraplatform/hydra-base
hydra_base/lib/data.py
get_multiple_vals_at_time
def get_multiple_vals_at_time(dataset_ids, timestamps,**kwargs): """ Given a timestamp (or list of timestamps) and a list of timeseries datasets, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after ...
python
def get_multiple_vals_at_time(dataset_ids, timestamps,**kwargs): """ Given a timestamp (or list of timestamps) and a list of timeseries datasets, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after ...
[ "def", "get_multiple_vals_at_time", "(", "dataset_ids", ",", "timestamps", ",", "*", "*", "kwargs", ")", ":", "datasets", "=", "_get_datasets", "(", "dataset_ids", ")", "datetimes", "=", "[", "]", "for", "time", "in", "timestamps", ":", "datetimes", ".", "ap...
Given a timestamp (or list of timestamps) and a list of timeseries datasets, return the values appropriate to the requested times. If the timestamp is before the start of the timeseries data, return None If the timestamp is after the end of the timeseries data, return the last value.
[ "Given", "a", "timestamp", "(", "or", "list", "of", "timestamps", ")", "and", "a", "list", "of", "timeseries", "datasets", "return", "the", "values", "appropriate", "to", "the", "requested", "times", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L950-L972
hydraplatform/hydra-base
hydra_base/lib/data.py
get_vals_between_times
def get_vals_between_times(dataset_id, start_time, end_time, timestep,increment,**kwargs): """ Retrive data between two specified times within a timeseries. The times need not be specified in the timeseries. This function will 'fill in the blanks'. Two types of data retrieval can be done. ...
python
def get_vals_between_times(dataset_id, start_time, end_time, timestep,increment,**kwargs): """ Retrive data between two specified times within a timeseries. The times need not be specified in the timeseries. This function will 'fill in the blanks'. Two types of data retrieval can be done. ...
[ "def", "get_vals_between_times", "(", "dataset_id", ",", "start_time", ",", "end_time", ",", "timestep", ",", "increment", ",", "*", "*", "kwargs", ")", ":", "try", ":", "server_start_time", "=", "get_datetime", "(", "start_time", ")", "server_end_time", "=", ...
Retrive data between two specified times within a timeseries. The times need not be specified in the timeseries. This function will 'fill in the blanks'. Two types of data retrieval can be done. If the timeseries is timestamp-based, then start_time and end_time must be datetimes and ti...
[ "Retrive", "data", "between", "two", "specified", "times", "within", "a", "timeseries", ".", "The", "times", "need", "not", "be", "specified", "in", "the", "timeseries", ".", "This", "function", "will", "fill", "in", "the", "blanks", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L974-L1032
hydraplatform/hydra-base
hydra_base/lib/data.py
delete_dataset
def delete_dataset(dataset_id,**kwargs): """ Removes a piece of data from the DB. CAUTION! Use with care, as this cannot be undone easily. """ try: d = db.DBSession.query(Dataset).filter(Dataset.id==dataset_id).one() except NoResultFound: raise HydraError("Dataset %s does...
python
def delete_dataset(dataset_id,**kwargs): """ Removes a piece of data from the DB. CAUTION! Use with care, as this cannot be undone easily. """ try: d = db.DBSession.query(Dataset).filter(Dataset.id==dataset_id).one() except NoResultFound: raise HydraError("Dataset %s does...
[ "def", "delete_dataset", "(", "dataset_id", ",", "*", "*", "kwargs", ")", ":", "try", ":", "d", "=", "db", ".", "DBSession", ".", "query", "(", "Dataset", ")", ".", "filter", "(", "Dataset", ".", "id", "==", "dataset_id", ")", ".", "one", "(", ")",...
Removes a piece of data from the DB. CAUTION! Use with care, as this cannot be undone easily.
[ "Removes", "a", "piece", "of", "data", "from", "the", "DB", ".", "CAUTION!", "Use", "with", "care", "as", "this", "cannot", "be", "undone", "easily", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L1034-L1053
hydraplatform/hydra-base
hydra_base/lib/notes.py
get_notes
def get_notes(ref_key, ref_id, **kwargs): """ Get all the notes for a resource, identifed by ref_key and ref_ido. Returns [] if no notes are found or if the resource doesn't exist. """ notes = db.DBSession.query(Note).filter(Note.ref_key==ref_key) if ref_key == 'NETWORK': notes =...
python
def get_notes(ref_key, ref_id, **kwargs): """ Get all the notes for a resource, identifed by ref_key and ref_ido. Returns [] if no notes are found or if the resource doesn't exist. """ notes = db.DBSession.query(Note).filter(Note.ref_key==ref_key) if ref_key == 'NETWORK': notes =...
[ "def", "get_notes", "(", "ref_key", ",", "ref_id", ",", "*", "*", "kwargs", ")", ":", "notes", "=", "db", ".", "DBSession", ".", "query", "(", "Note", ")", ".", "filter", "(", "Note", ".", "ref_key", "==", "ref_key", ")", "if", "ref_key", "==", "'N...
Get all the notes for a resource, identifed by ref_key and ref_ido. Returns [] if no notes are found or if the resource doesn't exist.
[ "Get", "all", "the", "notes", "for", "a", "resource", "identifed", "by", "ref_key", "and", "ref_ido", ".", "Returns", "[]", "if", "no", "notes", "are", "found", "or", "if", "the", "resource", "doesn", "t", "exist", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/notes.py#L32-L55
hydraplatform/hydra-base
hydra_base/lib/notes.py
add_note
def add_note(note, **kwargs): """ Add a new note """ note_i = Note() note_i.ref_key = note.ref_key note_i.set_ref(note.ref_key, note.ref_id) note_i.value = note.value note_i.created_by = kwargs.get('user_id') db.DBSession.add(note_i) db.DBSession.flush() return note_i
python
def add_note(note, **kwargs): """ Add a new note """ note_i = Note() note_i.ref_key = note.ref_key note_i.set_ref(note.ref_key, note.ref_id) note_i.value = note.value note_i.created_by = kwargs.get('user_id') db.DBSession.add(note_i) db.DBSession.flush() return note_i
[ "def", "add_note", "(", "note", ",", "*", "*", "kwargs", ")", ":", "note_i", "=", "Note", "(", ")", "note_i", ".", "ref_key", "=", "note", ".", "ref_key", "note_i", ".", "set_ref", "(", "note", ".", "ref_key", ",", "note", ".", "ref_id", ")", "note...
Add a new note
[ "Add", "a", "new", "note" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/notes.py#L64-L80
hydraplatform/hydra-base
hydra_base/lib/notes.py
update_note
def update_note(note, **kwargs): """ Update a note """ note_i = _get_note(note.id) if note.ref_key != note_i.ref_key: raise HydraError("Cannot convert a %s note to a %s note. Please create a new note instead."%(note_i.ref_key, note.ref_key)) note_i.set_ref(note.ref_key, note.ref_id) ...
python
def update_note(note, **kwargs): """ Update a note """ note_i = _get_note(note.id) if note.ref_key != note_i.ref_key: raise HydraError("Cannot convert a %s note to a %s note. Please create a new note instead."%(note_i.ref_key, note.ref_key)) note_i.set_ref(note.ref_key, note.ref_id) ...
[ "def", "update_note", "(", "note", ",", "*", "*", "kwargs", ")", ":", "note_i", "=", "_get_note", "(", "note", ".", "id", ")", "if", "note", ".", "ref_key", "!=", "note_i", ".", "ref_key", ":", "raise", "HydraError", "(", "\"Cannot convert a %s note to a %...
Update a note
[ "Update", "a", "note" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/notes.py#L82-L97
hydraplatform/hydra-base
hydra_base/lib/notes.py
purge_note
def purge_note(note_id, **kwargs): """ Remove a note from the DB permenantly """ note_i = _get_note(note_id) db.DBSession.delete(note_i) db.DBSession.flush()
python
def purge_note(note_id, **kwargs): """ Remove a note from the DB permenantly """ note_i = _get_note(note_id) db.DBSession.delete(note_i) db.DBSession.flush()
[ "def", "purge_note", "(", "note_id", ",", "*", "*", "kwargs", ")", ":", "note_i", "=", "_get_note", "(", "note_id", ")", "db", ".", "DBSession", ".", "delete", "(", "note_i", ")", "db", ".", "DBSession", ".", "flush", "(", ")" ]
Remove a note from the DB permenantly
[ "Remove", "a", "note", "from", "the", "DB", "permenantly" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/notes.py#L99-L107
hydraplatform/hydra-base
hydra_base/lib/service.py
login
def login(username, password, **kwargs): """ Login a user, returning a dict containing their user_id and session_id This does the DB login to check the credentials, and then creates a session so that requests from apps do not need to perform a login args: username (stri...
python
def login(username, password, **kwargs): """ Login a user, returning a dict containing their user_id and session_id This does the DB login to check the credentials, and then creates a session so that requests from apps do not need to perform a login args: username (stri...
[ "def", "login", "(", "username", ",", "password", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "util", ".", "hdb", ".", "login_user", "(", "username", ",", "password", ")", "hydra_session", "=", "session", ".", "Session", "(", "{", "}", ",", "#...
Login a user, returning a dict containing their user_id and session_id This does the DB login to check the credentials, and then creates a session so that requests from apps do not need to perform a login args: username (string): The user's username password(string): Th...
[ "Login", "a", "user", "returning", "a", "dict", "containing", "their", "user_id", "and", "session_id" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/service.py#L25-L54
hydraplatform/hydra-base
hydra_base/lib/service.py
logout
def logout(session_id, **kwargs): """ Logout a user, removing their cookie if it exists and returning 'OK' args: session_id (string): The session ID to identify the cookie to remove returns: 'OK' raises: HydraError if the logout fails """ ...
python
def logout(session_id, **kwargs): """ Logout a user, removing their cookie if it exists and returning 'OK' args: session_id (string): The session ID to identify the cookie to remove returns: 'OK' raises: HydraError if the logout fails """ ...
[ "def", "logout", "(", "session_id", ",", "*", "*", "kwargs", ")", ":", "hydra_session_object", "=", "session", ".", "SessionObject", "(", "{", "}", ",", "#This is normally a request object, but in this case is empty", "validate_key", "=", "config", ".", "get", "(", ...
Logout a user, removing their cookie if it exists and returning 'OK' args: session_id (string): The session ID to identify the cookie to remove returns: 'OK' raises: HydraError if the logout fails
[ "Logout", "a", "user", "removing", "their", "cookie", "if", "it", "exists", "and", "returning", "OK" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/service.py#L56-L82
hydraplatform/hydra-base
hydra_base/lib/service.py
get_session_user
def get_session_user(session_id, **kwargs): """ Given a session ID, get the user ID that it is associated with args: session_id (string): The user's ID to identify the cookie to remove returns: user_id (string) or None if the session does not exist """ hydr...
python
def get_session_user(session_id, **kwargs): """ Given a session ID, get the user ID that it is associated with args: session_id (string): The user's ID to identify the cookie to remove returns: user_id (string) or None if the session does not exist """ hydr...
[ "def", "get_session_user", "(", "session_id", ",", "*", "*", "kwargs", ")", ":", "hydra_session_object", "=", "session", ".", "SessionObject", "(", "{", "}", ",", "#This is normally a request object, but in this case is empty", "validate_key", "=", "config", ".", "get...
Given a session ID, get the user ID that it is associated with args: session_id (string): The user's ID to identify the cookie to remove returns: user_id (string) or None if the session does not exist
[ "Given", "a", "session", "ID", "get", "the", "user", "ID", "that", "it", "is", "associated", "with" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/service.py#L84-L107
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
array_dim
def array_dim(arr): """Return the size of a multidimansional array. """ dim = [] while True: try: dim.append(len(arr)) arr = arr[0] except TypeError: return dim
python
def array_dim(arr): """Return the size of a multidimansional array. """ dim = [] while True: try: dim.append(len(arr)) arr = arr[0] except TypeError: return dim
[ "def", "array_dim", "(", "arr", ")", ":", "dim", "=", "[", "]", "while", "True", ":", "try", ":", "dim", ".", "append", "(", "len", "(", "arr", ")", ")", "arr", "=", "arr", "[", "0", "]", "except", "TypeError", ":", "return", "dim" ]
Return the size of a multidimansional array.
[ "Return", "the", "size", "of", "a", "multidimansional", "array", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L33-L42
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
check_array_struct
def check_array_struct(array): """ Check to ensure arrays are symmetrical, for example: [[1, 2, 3], [1, 2]] is invalid """ #If a list is transformed into a numpy array and the sub elements #of this array are still lists, then numpy failed to fully convert #the list, meaning it is no...
python
def check_array_struct(array): """ Check to ensure arrays are symmetrical, for example: [[1, 2, 3], [1, 2]] is invalid """ #If a list is transformed into a numpy array and the sub elements #of this array are still lists, then numpy failed to fully convert #the list, meaning it is no...
[ "def", "check_array_struct", "(", "array", ")", ":", "#If a list is transformed into a numpy array and the sub elements", "#of this array are still lists, then numpy failed to fully convert", "#the list, meaning it is not symmetrical.", "try", ":", "arr", "=", "np", ".", "array", "("...
Check to ensure arrays are symmetrical, for example: [[1, 2, 3], [1, 2]] is invalid
[ "Check", "to", "ensure", "arrays", "are", "symmetrical", "for", "example", ":", "[[", "1", "2", "3", "]", "[", "1", "2", "]]", "is", "invalid" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L44-L58
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
arr_to_vector
def arr_to_vector(arr): """Reshape a multidimensional array to a vector. """ dim = array_dim(arr) tmp_arr = [] for n in range(len(dim) - 1): for inner in arr: for i in inner: tmp_arr.append(i) arr = tmp_arr tmp_arr = [] return arr
python
def arr_to_vector(arr): """Reshape a multidimensional array to a vector. """ dim = array_dim(arr) tmp_arr = [] for n in range(len(dim) - 1): for inner in arr: for i in inner: tmp_arr.append(i) arr = tmp_arr tmp_arr = [] return arr
[ "def", "arr_to_vector", "(", "arr", ")", ":", "dim", "=", "array_dim", "(", "arr", ")", "tmp_arr", "=", "[", "]", "for", "n", "in", "range", "(", "len", "(", "dim", ")", "-", "1", ")", ":", "for", "inner", "in", "arr", ":", "for", "i", "in", ...
Reshape a multidimensional array to a vector.
[ "Reshape", "a", "multidimensional", "array", "to", "a", "vector", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L61-L72
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
vector_to_arr
def vector_to_arr(vec, dim): """Reshape a vector to a multidimensional array with dimensions 'dim'. """ if len(dim) <= 1: return vec array = vec while len(dim) > 1: i = 0 outer_array = [] for m in range(reduce(mul, dim[0:-1])): inner_array = [] ...
python
def vector_to_arr(vec, dim): """Reshape a vector to a multidimensional array with dimensions 'dim'. """ if len(dim) <= 1: return vec array = vec while len(dim) > 1: i = 0 outer_array = [] for m in range(reduce(mul, dim[0:-1])): inner_array = [] ...
[ "def", "vector_to_arr", "(", "vec", ",", "dim", ")", ":", "if", "len", "(", "dim", ")", "<=", "1", ":", "return", "vec", "array", "=", "vec", "while", "len", "(", "dim", ")", ">", "1", ":", "i", "=", "0", "outer_array", "=", "[", "]", "for", ...
Reshape a vector to a multidimensional array with dimensions 'dim'.
[ "Reshape", "a", "vector", "to", "a", "multidimensional", "array", "with", "dimensions", "dim", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L75-L93
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
_get_val
def _get_val(val, full=False): """ Get the value(s) of a dataset as a single value or as 1-d list of values. In the special case of timeseries, when a check is for time-based criteria, you can return the entire timeseries. """ try: val = val.strip() except: pass ...
python
def _get_val(val, full=False): """ Get the value(s) of a dataset as a single value or as 1-d list of values. In the special case of timeseries, when a check is for time-based criteria, you can return the entire timeseries. """ try: val = val.strip() except: pass ...
[ "def", "_get_val", "(", "val", ",", "full", "=", "False", ")", ":", "try", ":", "val", "=", "val", ".", "strip", "(", ")", "except", ":", "pass", "logging", ".", "debug", "(", "\"%s, type=%s\"", ",", "val", ",", "type", "(", "val", ")", ")", "if"...
Get the value(s) of a dataset as a single value or as 1-d list of values. In the special case of timeseries, when a check is for time-based criteria, you can return the entire timeseries.
[ "Get", "the", "value", "(", "s", ")", "of", "a", "dataset", "as", "a", "single", "value", "or", "as", "1", "-", "d", "list", "of", "values", ".", "In", "the", "special", "case", "of", "timeseries", "when", "a", "check", "is", "for", "time", "-", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L95-L165
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
get_restriction_as_dict
def get_restriction_as_dict(restriction_xml): """ turn: :: <restrictions> <restriction> <type>MAXLEN</type> <value>3</value> </restriction> <restriction> <type>VALUERANGE</type> ...
python
def get_restriction_as_dict(restriction_xml): """ turn: :: <restrictions> <restriction> <type>MAXLEN</type> <value>3</value> </restriction> <restriction> <type>VALUERANGE</type> ...
[ "def", "get_restriction_as_dict", "(", "restriction_xml", ")", ":", "restriction_dict", "=", "{", "}", "if", "restriction_xml", "is", "None", ":", "return", "restriction_dict", "if", "restriction_xml", ".", "find", "(", "'restriction'", ")", "is", "not", "None", ...
turn: :: <restrictions> <restriction> <type>MAXLEN</type> <value>3</value> </restriction> <restriction> <type>VALUERANGE</type> <value><item>1</item><item>10</item></value> ...
[ "turn", ":", "::" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L167-L211
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_ENUM
def validate_ENUM(in_value, restriction): """ Test to ensure that the given value is contained in the provided list. the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the ENUM """ value = _get_val(in_value) if type...
python
def validate_ENUM(in_value, restriction): """ Test to ensure that the given value is contained in the provided list. the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the ENUM """ value = _get_val(in_value) if type...
[ "def", "validate_ENUM", "(", "in_value", ",", "restriction", ")", ":", "value", "=", "_get_val", "(", "in_value", ")", "if", "type", "(", "value", ")", "is", "list", ":", "for", "subval", "in", "value", ":", "if", "type", "(", "subval", ")", "is", "t...
Test to ensure that the given value is contained in the provided list. the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the ENUM
[ "Test", "to", "ensure", "that", "the", "given", "value", "is", "contained", "in", "the", "provided", "list", ".", "the", "value", "parameter", "must", "be", "either", "a", "single", "value", "or", "a", "1", "-", "dimensional", "list", ".", "All", "the", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L214-L228
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_NUMPLACES
def validate_NUMPLACES(in_value, restriction): """ the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the condition """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Making them a...
python
def validate_NUMPLACES(in_value, restriction): """ the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the condition """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Making them a...
[ "def", "validate_NUMPLACES", "(", "in_value", ",", "restriction", ")", ":", "#Sometimes restriction values can accidentally be put in the template <item>100</items>,", "#Making them a list, not a number. Rather than blowing up, just get value 1 from the list.", "if", "type", "(", "restrict...
the value parameter must be either a single value or a 1-dimensional list. All the values in this list must satisfy the condition
[ "the", "value", "parameter", "must", "be", "either", "a", "single", "value", "or", "a", "1", "-", "dimensional", "list", ".", "All", "the", "values", "in", "this", "list", "must", "satisfy", "the", "condition" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L275-L296
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_VALUERANGE
def validate_VALUERANGE(in_value, restriction): """ Test to ensure that a value sits between a lower and upper bound. Parameters: A Decimal value and a tuple, containing a lower and upper bound, both as Decimal values. """ if len(restriction) != 2: raise ValidationError("Temp...
python
def validate_VALUERANGE(in_value, restriction): """ Test to ensure that a value sits between a lower and upper bound. Parameters: A Decimal value and a tuple, containing a lower and upper bound, both as Decimal values. """ if len(restriction) != 2: raise ValidationError("Temp...
[ "def", "validate_VALUERANGE", "(", "in_value", ",", "restriction", ")", ":", "if", "len", "(", "restriction", ")", "!=", "2", ":", "raise", "ValidationError", "(", "\"Template ERROR: Only two values can be specified in a date range.\"", ")", "value", "=", "_get_val", ...
Test to ensure that a value sits between a lower and upper bound. Parameters: A Decimal value and a tuple, containing a lower and upper bound, both as Decimal values.
[ "Test", "to", "ensure", "that", "a", "value", "sits", "between", "a", "lower", "and", "upper", "bound", ".", "Parameters", ":", "A", "Decimal", "value", "and", "a", "tuple", "containing", "a", "lower", "and", "upper", "bound", "both", "as", "Decimal", "v...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L298-L317
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_DATERANGE
def validate_DATERANGE(value, restriction): """ Test to ensure that the times in a timeseries fall between a lower and upper bound Parameters: A timeseries in the form [(datetime, val), (datetime, val)..] and a tuple containing the lower and upper bound as datetime objects. """ if le...
python
def validate_DATERANGE(value, restriction): """ Test to ensure that the times in a timeseries fall between a lower and upper bound Parameters: A timeseries in the form [(datetime, val), (datetime, val)..] and a tuple containing the lower and upper bound as datetime objects. """ if le...
[ "def", "validate_DATERANGE", "(", "value", ",", "restriction", ")", ":", "if", "len", "(", "restriction", ")", "!=", "2", ":", "raise", "ValidationError", "(", "\"Template ERROR: Only two values can be specified in a date range.\"", ")", "if", "type", "(", "value", ...
Test to ensure that the times in a timeseries fall between a lower and upper bound Parameters: A timeseries in the form [(datetime, val), (datetime, val)..] and a tuple containing the lower and upper bound as datetime objects.
[ "Test", "to", "ensure", "that", "the", "times", "in", "a", "timeseries", "fall", "between", "a", "lower", "and", "upper", "bound", "Parameters", ":", "A", "timeseries", "in", "the", "form", "[", "(", "datetime", "val", ")", "(", "datetime", "val", ")", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L319-L341
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_MAXLEN
def validate_MAXLEN(value, restriction): """ Test to ensure that a list has the prescribed length. Parameters: A list and an integer, which defines the required length of the list. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Makin...
python
def validate_MAXLEN(value, restriction): """ Test to ensure that a list has the prescribed length. Parameters: A list and an integer, which defines the required length of the list. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Makin...
[ "def", "validate_MAXLEN", "(", "value", ",", "restriction", ")", ":", "#Sometimes restriction values can accidentally be put in the template <item>100</items>,", "#Making them a list, not a number. Rather than blowing up, just get value 1 from the list.", "if", "type", "(", "restriction", ...
Test to ensure that a list has the prescribed length. Parameters: A list and an integer, which defines the required length of the list.
[ "Test", "to", "ensure", "that", "a", "list", "has", "the", "prescribed", "length", ".", "Parameters", ":", "A", "list", "and", "an", "integer", "which", "defines", "the", "required", "length", "of", "the", "list", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L343-L357
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_LESSTHAN
def validate_LESSTHAN(in_value, restriction): """ Test to ensure that a value is less than a prescribed value. Parameter: Two values, which will be compared for the difference.. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Making them a li...
python
def validate_LESSTHAN(in_value, restriction): """ Test to ensure that a value is less than a prescribed value. Parameter: Two values, which will be compared for the difference.. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Making them a li...
[ "def", "validate_LESSTHAN", "(", "in_value", ",", "restriction", ")", ":", "#Sometimes restriction values can accidentally be put in the template <item>100</items>,", "#Making them a list, not a number. Rather than blowing up, just get value 1 from the list.", "if", "type", "(", "restricti...
Test to ensure that a value is less than a prescribed value. Parameter: Two values, which will be compared for the difference..
[ "Test", "to", "ensure", "that", "a", "value", "is", "less", "than", "a", "prescribed", "value", ".", "Parameter", ":", "Two", "values", "which", "will", "be", "compared", "for", "the", "difference", ".." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L419-L441
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_LESSTHANEQ
def validate_LESSTHANEQ(value, restriction): """ Test to ensure that a value is less than or equal to a prescribed value. Parameter: Two values, which will be compared for the difference.. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Makin...
python
def validate_LESSTHANEQ(value, restriction): """ Test to ensure that a value is less than or equal to a prescribed value. Parameter: Two values, which will be compared for the difference.. """ #Sometimes restriction values can accidentally be put in the template <item>100</items>, #Makin...
[ "def", "validate_LESSTHANEQ", "(", "value", ",", "restriction", ")", ":", "#Sometimes restriction values can accidentally be put in the template <item>100</items>,", "#Making them a list, not a number. Rather than blowing up, just get value 1 from the list.", "if", "type", "(", "restrictio...
Test to ensure that a value is less than or equal to a prescribed value. Parameter: Two values, which will be compared for the difference..
[ "Test", "to", "ensure", "that", "a", "value", "is", "less", "than", "or", "equal", "to", "a", "prescribed", "value", ".", "Parameter", ":", "Two", "values", "which", "will", "be", "compared", "for", "the", "difference", ".." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L444-L466
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_SUMTO
def validate_SUMTO(in_value, restriction): """ Test to ensure the values of a list sum to a specified value: Parameters: a list of numeric values and a target to which the values in the list must sum """ #Sometimes restriction values can accidentally be put in the template <item>100<...
python
def validate_SUMTO(in_value, restriction): """ Test to ensure the values of a list sum to a specified value: Parameters: a list of numeric values and a target to which the values in the list must sum """ #Sometimes restriction values can accidentally be put in the template <item>100<...
[ "def", "validate_SUMTO", "(", "in_value", ",", "restriction", ")", ":", "#Sometimes restriction values can accidentally be put in the template <item>100</items>,", "#Making them a list, not a number. Rather than blowing up, just get value 1 from the list.", "if", "type", "(", "restriction"...
Test to ensure the values of a list sum to a specified value: Parameters: a list of numeric values and a target to which the values in the list must sum
[ "Test", "to", "ensure", "the", "values", "of", "a", "list", "sum", "to", "a", "specified", "value", ":", "Parameters", ":", "a", "list", "of", "numeric", "values", "and", "a", "target", "to", "which", "the", "values", "in", "the", "list", "must", "sum"...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L541-L565
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_INCREASING
def validate_INCREASING(in_value, restriction): """ Test to ensure the values in a list are increasing. Parameters: a list of values and None. The none is there simply to conform with the rest of the validation routines. """ flat_list = _flatten_value(in_value) previous = None ...
python
def validate_INCREASING(in_value, restriction): """ Test to ensure the values in a list are increasing. Parameters: a list of values and None. The none is there simply to conform with the rest of the validation routines. """ flat_list = _flatten_value(in_value) previous = None ...
[ "def", "validate_INCREASING", "(", "in_value", ",", "restriction", ")", ":", "flat_list", "=", "_flatten_value", "(", "in_value", ")", "previous", "=", "None", "for", "a", "in", "flat_list", ":", "if", "previous", "is", "None", ":", "previous", "=", "a", "...
Test to ensure the values in a list are increasing. Parameters: a list of values and None. The none is there simply to conform with the rest of the validation routines.
[ "Test", "to", "ensure", "the", "values", "in", "a", "list", "are", "increasing", ".", "Parameters", ":", "a", "list", "of", "values", "and", "None", ".", "The", "none", "is", "there", "simply", "to", "conform", "with", "the", "rest", "of", "the", "vali...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L567-L586
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
validate_EQUALTIMESTEPS
def validate_EQUALTIMESTEPS(value, restriction): """ Ensure that the timesteps in a timeseries are equal. If a restriction is provided, they must be equal to the specified restriction. Value is a pandas dataframe. """ if len(value) == 0: return if type(value) == pd.Data...
python
def validate_EQUALTIMESTEPS(value, restriction): """ Ensure that the timesteps in a timeseries are equal. If a restriction is provided, they must be equal to the specified restriction. Value is a pandas dataframe. """ if len(value) == 0: return if type(value) == pd.Data...
[ "def", "validate_EQUALTIMESTEPS", "(", "value", ",", "restriction", ")", ":", "if", "len", "(", "value", ")", "==", "0", ":", "return", "if", "type", "(", "value", ")", "==", "pd", ".", "DataFrame", ":", "if", "str", "(", "value", ".", "index", "[", ...
Ensure that the timesteps in a timeseries are equal. If a restriction is provided, they must be equal to the specified restriction. Value is a pandas dataframe.
[ "Ensure", "that", "the", "timesteps", "in", "a", "timeseries", "are", "equal", ".", "If", "a", "restriction", "is", "provided", "they", "must", "be", "equal", "to", "the", "specified", "restriction", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L608-L641
hydraplatform/hydra-base
hydra_base/util/dataset_util.py
_flatten_value
def _flatten_value(value): """ 1: Turn a multi-dimensional array into a 1-dimensional array 2: Turn a timeseries of values into a single 1-dimensional array """ if type(value) == pd.DataFrame: value = value.values.tolist() if type(value) != list: raise ValidationError("...
python
def _flatten_value(value): """ 1: Turn a multi-dimensional array into a 1-dimensional array 2: Turn a timeseries of values into a single 1-dimensional array """ if type(value) == pd.DataFrame: value = value.values.tolist() if type(value) != list: raise ValidationError("...
[ "def", "_flatten_value", "(", "value", ")", ":", "if", "type", "(", "value", ")", "==", "pd", ".", "DataFrame", ":", "value", "=", "value", ".", "values", ".", "tolist", "(", ")", "if", "type", "(", "value", ")", "!=", "list", ":", "raise", "Valida...
1: Turn a multi-dimensional array into a 1-dimensional array 2: Turn a timeseries of values into a single 1-dimensional array
[ "1", ":", "Turn", "a", "multi", "-", "dimensional", "array", "into", "a", "1", "-", "dimensional", "array", "2", ":", "Turn", "a", "timeseries", "of", "values", "into", "a", "single", "1", "-", "dimensional", "array" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/dataset_util.py#L687-L704
hydraplatform/hydra-base
hydra_base/util/__init__.py
count_levels
def count_levels(value): """ Count how many levels are in a dict: scalar, list etc = 0 {} = 0 {'a':1} = 1 {'a' : {'b' : 1}} = 2 etc... """ if not isinstance(value, dict) or len(value) == 0: return 0 elif len(value) == 0: return 0 #An emptu ...
python
def count_levels(value): """ Count how many levels are in a dict: scalar, list etc = 0 {} = 0 {'a':1} = 1 {'a' : {'b' : 1}} = 2 etc... """ if not isinstance(value, dict) or len(value) == 0: return 0 elif len(value) == 0: return 0 #An emptu ...
[ "def", "count_levels", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "dict", ")", "or", "len", "(", "value", ")", "==", "0", ":", "return", "0", "elif", "len", "(", "value", ")", "==", "0", ":", "return", "0", "#An emptu dic...
Count how many levels are in a dict: scalar, list etc = 0 {} = 0 {'a':1} = 1 {'a' : {'b' : 1}} = 2 etc...
[ "Count", "how", "many", "levels", "are", "in", "a", "dict", ":", "scalar", "list", "etc", "=", "0", "{}", "=", "0", "{", "a", ":", "1", "}", "=", "1", "{", "a", ":", "{", "b", ":", "1", "}}", "=", "2", "etc", "..." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L38-L53
hydraplatform/hydra-base
hydra_base/util/__init__.py
flatten_dict
def flatten_dict(value, target_depth=1, depth=None): """ Take a hashtable with multiple nested dicts and return a dict where the keys are a concatenation of each sub-key. The depth of the returned array is dictated by target_depth, defaulting to 1 ex: {'a' : {'b':1, 'c': 2}} ==> {'...
python
def flatten_dict(value, target_depth=1, depth=None): """ Take a hashtable with multiple nested dicts and return a dict where the keys are a concatenation of each sub-key. The depth of the returned array is dictated by target_depth, defaulting to 1 ex: {'a' : {'b':1, 'c': 2}} ==> {'...
[ "def", "flatten_dict", "(", "value", ",", "target_depth", "=", "1", ",", "depth", "=", "None", ")", ":", "#failsafe in case someone specified null", "if", "target_depth", "is", "None", ":", "target_depth", "=", "1", "values", "=", "list", "(", "value", ".", ...
Take a hashtable with multiple nested dicts and return a dict where the keys are a concatenation of each sub-key. The depth of the returned array is dictated by target_depth, defaulting to 1 ex: {'a' : {'b':1, 'c': 2}} ==> {'a_b': 1, 'a_c': 2} Assumes a constant structure actoss all s...
[ "Take", "a", "hashtable", "with", "multiple", "nested", "dicts", "and", "return", "a", "dict", "where", "the", "keys", "are", "a", "concatenation", "of", "each", "sub", "-", "key", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L55-L94
hydraplatform/hydra-base
hydra_base/util/__init__.py
to_named_tuple
def to_named_tuple(keys, values): """ Convert a sqlalchemy object into a named tuple """ values = [dbobject.__dict__[key] for key in dbobject.keys()] tuple_object = namedtuple('DBObject', dbobject.keys()) tuple_instance = tuple_object._make(values) return tuple_instance
python
def to_named_tuple(keys, values): """ Convert a sqlalchemy object into a named tuple """ values = [dbobject.__dict__[key] for key in dbobject.keys()] tuple_object = namedtuple('DBObject', dbobject.keys()) tuple_instance = tuple_object._make(values) return tuple_instance
[ "def", "to_named_tuple", "(", "keys", ",", "values", ")", ":", "values", "=", "[", "dbobject", ".", "__dict__", "[", "key", "]", "for", "key", "in", "dbobject", ".", "keys", "(", ")", "]", "tuple_object", "=", "namedtuple", "(", "'DBObject'", ",", "dbo...
Convert a sqlalchemy object into a named tuple
[ "Convert", "a", "sqlalchemy", "object", "into", "a", "named", "tuple" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L96-L107
hydraplatform/hydra-base
hydra_base/util/__init__.py
get_val
def get_val(dataset, timestamp=None): """ Turn the string value of a dataset into an appropriate value, be it a decimal value, array or time series. If a timestamp is passed to this function, return the values appropriate to the requested times. If the timestamp is *before*...
python
def get_val(dataset, timestamp=None): """ Turn the string value of a dataset into an appropriate value, be it a decimal value, array or time series. If a timestamp is passed to this function, return the values appropriate to the requested times. If the timestamp is *before*...
[ "def", "get_val", "(", "dataset", ",", "timestamp", "=", "None", ")", ":", "if", "dataset", ".", "type", "==", "'array'", ":", "#TODO: design a mechansim to retrieve this data if it's stored externally", "return", "json", ".", "loads", "(", "dataset", ".", "value", ...
Turn the string value of a dataset into an appropriate value, be it a decimal value, array or time series. If a timestamp is passed to this function, return the values appropriate to the requested times. If the timestamp is *before* the start of the timeseries data, return None ...
[ "Turn", "the", "string", "value", "of", "a", "dataset", "into", "an", "appropriate", "value", "be", "it", "a", "decimal", "value", "array", "or", "time", "series", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L132-L218
hydraplatform/hydra-base
hydra_base/util/__init__.py
get_layout_as_string
def get_layout_as_string(layout): """ Take a dict or string and return a string. The dict will be json dumped. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is...
python
def get_layout_as_string(layout): """ Take a dict or string and return a string. The dict will be json dumped. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is...
[ "def", "get_layout_as_string", "(", "layout", ")", ":", "if", "isinstance", "(", "layout", ",", "dict", ")", ":", "return", "json", ".", "dumps", "(", "layout", ")", "if", "(", "isinstance", "(", "layout", ",", "six", ".", "string_types", ")", ")", ":"...
Take a dict or string and return a string. The dict will be json dumped. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is retrieved or until a non-json structure is identi...
[ "Take", "a", "dict", "or", "string", "and", "return", "a", "string", ".", "The", "dict", "will", "be", "json", "dumped", ".", "The", "string", "will", "json", "parsed", "to", "check", "for", "json", "validity", ".", "In", "order", "to", "deal", "with",...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L220-L236
hydraplatform/hydra-base
hydra_base/util/__init__.py
get_layout_as_dict
def get_layout_as_dict(layout): """ Take a dict or string and return a dict if the data is json-encoded. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is retrieved or ...
python
def get_layout_as_dict(layout): """ Take a dict or string and return a dict if the data is json-encoded. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is retrieved or ...
[ "def", "get_layout_as_dict", "(", "layout", ")", ":", "if", "isinstance", "(", "layout", ",", "dict", ")", ":", "return", "layout", "if", "(", "isinstance", "(", "layout", ",", "six", ".", "string_types", ")", ")", ":", "try", ":", "return", "get_layout_...
Take a dict or string and return a dict if the data is json-encoded. The string will json parsed to check for json validity. In order to deal with strings which have been json encoded multiple times, keep json decoding until a dict is retrieved or until a non-json structure is identified.
[ "Take", "a", "dict", "or", "string", "and", "return", "a", "dict", "if", "the", "data", "is", "json", "-", "encoded", ".", "The", "string", "will", "json", "parsed", "to", "check", "for", "json", "validity", ".", "In", "order", "to", "deal", "with", ...
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/__init__.py#L238-L253
hydraplatform/hydra-base
hydra_base/lib/users.py
get_username
def get_username(uid,**kwargs): """ Return the username of a given user_id """ rs = db.DBSession.query(User.username).filter(User.id==uid).one() if rs is None: raise ResourceNotFoundError("User with ID %s not found"%uid) return rs.username
python
def get_username(uid,**kwargs): """ Return the username of a given user_id """ rs = db.DBSession.query(User.username).filter(User.id==uid).one() if rs is None: raise ResourceNotFoundError("User with ID %s not found"%uid) return rs.username
[ "def", "get_username", "(", "uid", ",", "*", "*", "kwargs", ")", ":", "rs", "=", "db", ".", "DBSession", ".", "query", "(", "User", ".", "username", ")", ".", "filter", "(", "User", ".", "id", "==", "uid", ")", ".", "one", "(", ")", "if", "rs",...
Return the username of a given user_id
[ "Return", "the", "username", "of", "a", "given", "user_id" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L64-L73
hydraplatform/hydra-base
hydra_base/lib/users.py
get_usernames_like
def get_usernames_like(username,**kwargs): """ Return a list of usernames like the given string. """ checkname = "%%%s%%"%username rs = db.DBSession.query(User.username).filter(User.username.like(checkname)).all() return [r.username for r in rs]
python
def get_usernames_like(username,**kwargs): """ Return a list of usernames like the given string. """ checkname = "%%%s%%"%username rs = db.DBSession.query(User.username).filter(User.username.like(checkname)).all() return [r.username for r in rs]
[ "def", "get_usernames_like", "(", "username", ",", "*", "*", "kwargs", ")", ":", "checkname", "=", "\"%%%s%%\"", "%", "username", "rs", "=", "db", ".", "DBSession", ".", "query", "(", "User", ".", "username", ")", ".", "filter", "(", "User", ".", "user...
Return a list of usernames like the given string.
[ "Return", "a", "list", "of", "usernames", "like", "the", "given", "string", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L75-L81
hydraplatform/hydra-base
hydra_base/lib/users.py
add_user
def add_user(user, **kwargs): """ Add a user """ #check_perm(kwargs.get('user_id'), 'add_user') u = User() u.username = user.username u.display_name = user.display_name user_id = _get_user_id(u.username) #If the user is already there, cannot add another with #the same ...
python
def add_user(user, **kwargs): """ Add a user """ #check_perm(kwargs.get('user_id'), 'add_user') u = User() u.username = user.username u.display_name = user.display_name user_id = _get_user_id(u.username) #If the user is already there, cannot add another with #the same ...
[ "def", "add_user", "(", "user", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'add_user')", "u", "=", "User", "(", ")", "u", ".", "username", "=", "user", ".", "username", "u", ".", "display_name", "=", "user", ".", "display_name", ...
Add a user
[ "Add", "a", "user" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L84-L106
hydraplatform/hydra-base
hydra_base/lib/users.py
update_user_display_name
def update_user_display_name(user,**kwargs): """ Update a user's display name """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==user.id).one() user_i.display_name = user.display_name return user_i except NoResul...
python
def update_user_display_name(user,**kwargs): """ Update a user's display name """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==user.id).one() user_i.display_name = user.display_name return user_i except NoResul...
[ "def", "update_user_display_name", "(", "user", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_user')", "try", ":", "user_i", "=", "db", ".", "DBSession", ".", "query", "(", "User", ")", ".", "filter", "(", "User", ".", "id", "=...
Update a user's display name
[ "Update", "a", "user", "s", "display", "name" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L108-L118
hydraplatform/hydra-base
hydra_base/lib/users.py
update_user_password
def update_user_password(new_pwd_user_id, new_password,**kwargs): """ Update a user's password """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==new_pwd_user_id).one() user_i.password = bcrypt.hashpw(str(new_password).encod...
python
def update_user_password(new_pwd_user_id, new_password,**kwargs): """ Update a user's password """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==new_pwd_user_id).one() user_i.password = bcrypt.hashpw(str(new_password).encod...
[ "def", "update_user_password", "(", "new_pwd_user_id", ",", "new_password", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_user')", "try", ":", "user_i", "=", "db", ".", "DBSession", ".", "query", "(", "User", ")", ".", "filter", "(...
Update a user's password
[ "Update", "a", "user", "s", "password" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L120-L130
hydraplatform/hydra-base
hydra_base/lib/users.py
get_user
def get_user(uid, **kwargs): """ Get a user by ID """ user_id=kwargs.get('user_id') if uid is None: uid = user_id user_i = _get_user(uid) return user_i
python
def get_user(uid, **kwargs): """ Get a user by ID """ user_id=kwargs.get('user_id') if uid is None: uid = user_id user_i = _get_user(uid) return user_i
[ "def", "get_user", "(", "uid", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "if", "uid", "is", "None", ":", "uid", "=", "user_id", "user_i", "=", "_get_user", "(", "uid", ")", "return", "user_i" ]
Get a user by ID
[ "Get", "a", "user", "by", "ID" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L132-L140
hydraplatform/hydra-base
hydra_base/lib/users.py
get_user_by_name
def get_user_by_name(uname,**kwargs): """ Get a user by username """ try: user_i = db.DBSession.query(User).filter(User.username==uname).one() return user_i except NoResultFound: return None
python
def get_user_by_name(uname,**kwargs): """ Get a user by username """ try: user_i = db.DBSession.query(User).filter(User.username==uname).one() return user_i except NoResultFound: return None
[ "def", "get_user_by_name", "(", "uname", ",", "*", "*", "kwargs", ")", ":", "try", ":", "user_i", "=", "db", ".", "DBSession", ".", "query", "(", "User", ")", ".", "filter", "(", "User", ".", "username", "==", "uname", ")", ".", "one", "(", ")", ...
Get a user by username
[ "Get", "a", "user", "by", "username" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L142-L150
hydraplatform/hydra-base
hydra_base/lib/users.py
get_user_by_id
def get_user_by_id(uid,**kwargs): """ Get a user by username """ user_id = kwargs.get('user_id') try: user_i = _get_user(uid) return user_i except NoResultFound: return None
python
def get_user_by_id(uid,**kwargs): """ Get a user by username """ user_id = kwargs.get('user_id') try: user_i = _get_user(uid) return user_i except NoResultFound: return None
[ "def", "get_user_by_id", "(", "uid", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "try", ":", "user_i", "=", "_get_user", "(", "uid", ")", "return", "user_i", "except", "NoResultFound", ":", "return", ...
Get a user by username
[ "Get", "a", "user", "by", "username" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L152-L161
hydraplatform/hydra-base
hydra_base/lib/users.py
delete_user
def delete_user(deleted_user_id,**kwargs): """ Delete a user """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==deleted_user_id).one() db.DBSession.delete(user_i) except NoResultFound: raise ResourceNotFoundError...
python
def delete_user(deleted_user_id,**kwargs): """ Delete a user """ #check_perm(kwargs.get('user_id'), 'edit_user') try: user_i = db.DBSession.query(User).filter(User.id==deleted_user_id).one() db.DBSession.delete(user_i) except NoResultFound: raise ResourceNotFoundError...
[ "def", "delete_user", "(", "deleted_user_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_user')", "try", ":", "user_i", "=", "db", ".", "DBSession", ".", "query", "(", "User", ")", ".", "filter", "(", "User", ".", "id", "=="...
Delete a user
[ "Delete", "a", "user" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L163-L175
hydraplatform/hydra-base
hydra_base/lib/users.py
add_role
def add_role(role,**kwargs): """ Add a new role """ #check_perm(kwargs.get('user_id'), 'add_role') role_i = Role(name=role.name, code=role.code) db.DBSession.add(role_i) db.DBSession.flush() return role_i
python
def add_role(role,**kwargs): """ Add a new role """ #check_perm(kwargs.get('user_id'), 'add_role') role_i = Role(name=role.name, code=role.code) db.DBSession.add(role_i) db.DBSession.flush() return role_i
[ "def", "add_role", "(", "role", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'add_role')", "role_i", "=", "Role", "(", "name", "=", "role", ".", "name", ",", "code", "=", "role", ".", "code", ")", "db", ".", "DBSession", ".", "a...
Add a new role
[ "Add", "a", "new", "role" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L178-L187
hydraplatform/hydra-base
hydra_base/lib/users.py
delete_role
def delete_role(role_id,**kwargs): """ Delete a role """ #check_perm(kwargs.get('user_id'), 'edit_role') try: role_i = db.DBSession.query(Role).filter(Role.id==role_id).one() db.DBSession.delete(role_i) except InvalidRequestError: raise ResourceNotFoundError("Role (ro...
python
def delete_role(role_id,**kwargs): """ Delete a role """ #check_perm(kwargs.get('user_id'), 'edit_role') try: role_i = db.DBSession.query(Role).filter(Role.id==role_id).one() db.DBSession.delete(role_i) except InvalidRequestError: raise ResourceNotFoundError("Role (ro...
[ "def", "delete_role", "(", "role_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_role')", "try", ":", "role_i", "=", "db", ".", "DBSession", ".", "query", "(", "Role", ")", ".", "filter", "(", "Role", ".", "id", "==", "rol...
Delete a role
[ "Delete", "a", "role" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L189-L200
hydraplatform/hydra-base
hydra_base/lib/users.py
add_perm
def add_perm(perm,**kwargs): """ Add a permission """ #check_perm(kwargs.get('user_id'), 'add_perm') perm_i = Perm(name=perm.name, code=perm.code) db.DBSession.add(perm_i) db.DBSession.flush() return perm_i
python
def add_perm(perm,**kwargs): """ Add a permission """ #check_perm(kwargs.get('user_id'), 'add_perm') perm_i = Perm(name=perm.name, code=perm.code) db.DBSession.add(perm_i) db.DBSession.flush() return perm_i
[ "def", "add_perm", "(", "perm", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'add_perm')", "perm_i", "=", "Perm", "(", "name", "=", "perm", ".", "name", ",", "code", "=", "perm", ".", "code", ")", "db", ".", "DBSession", ".", "a...
Add a permission
[ "Add", "a", "permission" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L202-L211
hydraplatform/hydra-base
hydra_base/lib/users.py
delete_perm
def delete_perm(perm_id,**kwargs): """ Delete a permission """ #check_perm(kwargs.get('user_id'), 'edit_perm') try: perm_i = db.DBSession.query(Perm).filter(Perm.id==perm_id).one() db.DBSession.delete(perm_i) except InvalidRequestError: raise ResourceNotFoundError("P...
python
def delete_perm(perm_id,**kwargs): """ Delete a permission """ #check_perm(kwargs.get('user_id'), 'edit_perm') try: perm_i = db.DBSession.query(Perm).filter(Perm.id==perm_id).one() db.DBSession.delete(perm_i) except InvalidRequestError: raise ResourceNotFoundError("P...
[ "def", "delete_perm", "(", "perm_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_perm')", "try", ":", "perm_i", "=", "db", ".", "DBSession", ".", "query", "(", "Perm", ")", ".", "filter", "(", "Perm", ".", "id", "==", "per...
Delete a permission
[ "Delete", "a", "permission" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L213-L225
hydraplatform/hydra-base
hydra_base/lib/users.py
set_user_role
def set_user_role(new_user_id, role_id, **kwargs): """ Apply `role_id` to `new_user_id` Note this function returns the `Role` instance associated with `role_id` """ #check_perm(kwargs.get('user_id'), 'edit_role') try: _get_user(new_user_id) role_i = _get_role(role_id) ...
python
def set_user_role(new_user_id, role_id, **kwargs): """ Apply `role_id` to `new_user_id` Note this function returns the `Role` instance associated with `role_id` """ #check_perm(kwargs.get('user_id'), 'edit_role') try: _get_user(new_user_id) role_i = _get_role(role_id) ...
[ "def", "set_user_role", "(", "new_user_id", ",", "role_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_role')", "try", ":", "_get_user", "(", "new_user_id", ")", "role_i", "=", "_get_role", "(", "role_id", ")", "roleuser_i", "=", ...
Apply `role_id` to `new_user_id` Note this function returns the `Role` instance associated with `role_id`
[ "Apply", "role_id", "to", "new_user_id" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L228-L245
hydraplatform/hydra-base
hydra_base/lib/users.py
delete_user_role
def delete_user_role(deleted_user_id, role_id,**kwargs): """ Remove a user from a role """ #check_perm(kwargs.get('user_id'), 'edit_role') try: _get_user(deleted_user_id) _get_role(role_id) roleuser_i = db.DBSession.query(RoleUser).filter(RoleUser.user_id==deleted_user_id...
python
def delete_user_role(deleted_user_id, role_id,**kwargs): """ Remove a user from a role """ #check_perm(kwargs.get('user_id'), 'edit_role') try: _get_user(deleted_user_id) _get_role(role_id) roleuser_i = db.DBSession.query(RoleUser).filter(RoleUser.user_id==deleted_user_id...
[ "def", "delete_user_role", "(", "deleted_user_id", ",", "role_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_role')", "try", ":", "_get_user", "(", "deleted_user_id", ")", "_get_role", "(", "role_id", ")", "roleuser_i", "=", "db", ...
Remove a user from a role
[ "Remove", "a", "user", "from", "a", "role" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L247-L260
hydraplatform/hydra-base
hydra_base/lib/users.py
set_role_perm
def set_role_perm(role_id, perm_id,**kwargs): """ Insert a permission into a role """ #check_perm(kwargs.get('user_id'), 'edit_perm') _get_perm(perm_id) role_i = _get_role(role_id) roleperm_i = RolePerm(role_id=role_id, perm_id=perm_id) role_i.roleperms.append(roleperm_i) db.D...
python
def set_role_perm(role_id, perm_id,**kwargs): """ Insert a permission into a role """ #check_perm(kwargs.get('user_id'), 'edit_perm') _get_perm(perm_id) role_i = _get_role(role_id) roleperm_i = RolePerm(role_id=role_id, perm_id=perm_id) role_i.roleperms.append(roleperm_i) db.D...
[ "def", "set_role_perm", "(", "role_id", ",", "perm_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_perm')", "_get_perm", "(", "perm_id", ")", "role_i", "=", "_get_role", "(", "role_id", ")", "roleperm_i", "=", "RolePerm", "(", "...
Insert a permission into a role
[ "Insert", "a", "permission", "into", "a", "role" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L262-L276
hydraplatform/hydra-base
hydra_base/lib/users.py
delete_role_perm
def delete_role_perm(role_id, perm_id,**kwargs): """ Remove a permission from a role """ #check_perm(kwargs.get('user_id'), 'edit_perm') _get_perm(perm_id) _get_role(role_id) try: roleperm_i = db.DBSession.query(RolePerm).filter(RolePerm.role_id==role_id, RolePerm.perm_id==perm_...
python
def delete_role_perm(role_id, perm_id,**kwargs): """ Remove a permission from a role """ #check_perm(kwargs.get('user_id'), 'edit_perm') _get_perm(perm_id) _get_role(role_id) try: roleperm_i = db.DBSession.query(RolePerm).filter(RolePerm.role_id==role_id, RolePerm.perm_id==perm_...
[ "def", "delete_role_perm", "(", "role_id", ",", "perm_id", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_perm')", "_get_perm", "(", "perm_id", ")", "_get_role", "(", "role_id", ")", "try", ":", "roleperm_i", "=", "db", ".", "DBSess...
Remove a permission from a role
[ "Remove", "a", "permission", "from", "a", "role" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L278-L292
hydraplatform/hydra-base
hydra_base/lib/users.py
update_role
def update_role(role,**kwargs): """ Update the role. Used to add permissions and users to a role. """ #check_perm(kwargs.get('user_id'), 'edit_role') try: role_i = db.DBSession.query(Role).filter(Role.id==role.id).one() role_i.name = role.name role_i.code = role.c...
python
def update_role(role,**kwargs): """ Update the role. Used to add permissions and users to a role. """ #check_perm(kwargs.get('user_id'), 'edit_role') try: role_i = db.DBSession.query(Role).filter(Role.id==role.id).one() role_i.name = role.name role_i.code = role.c...
[ "def", "update_role", "(", "role", ",", "*", "*", "kwargs", ")", ":", "#check_perm(kwargs.get('user_id'), 'edit_role')", "try", ":", "role_i", "=", "db", ".", "DBSession", ".", "query", "(", "Role", ")", ".", "filter", "(", "Role", ".", "id", "==", "role",...
Update the role. Used to add permissions and users to a role.
[ "Update", "the", "role", ".", "Used", "to", "add", "permissions", "and", "users", "to", "a", "role", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L294-L324
hydraplatform/hydra-base
hydra_base/lib/users.py
get_all_users
def get_all_users(**kwargs): """ Get the username & ID of all users. Use the the filter if it has been provided The filter has to be a list of values """ users_qry = db.DBSession.query(User) filter_type = kwargs.get('filter_type') filter_value = kwargs.get('filter_value') ...
python
def get_all_users(**kwargs): """ Get the username & ID of all users. Use the the filter if it has been provided The filter has to be a list of values """ users_qry = db.DBSession.query(User) filter_type = kwargs.get('filter_type') filter_value = kwargs.get('filter_value') ...
[ "def", "get_all_users", "(", "*", "*", "kwargs", ")", ":", "users_qry", "=", "db", ".", "DBSession", ".", "query", "(", "User", ")", "filter_type", "=", "kwargs", ".", "get", "(", "'filter_type'", ")", "filter_value", "=", "kwargs", ".", "get", "(", "'...
Get the username & ID of all users. Use the the filter if it has been provided The filter has to be a list of values
[ "Get", "the", "username", "&", "ID", "of", "all", "users", ".", "Use", "the", "the", "filter", "if", "it", "has", "been", "provided", "The", "filter", "has", "to", "be", "a", "list", "of", "values" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L327-L369
hydraplatform/hydra-base
hydra_base/lib/users.py
get_role
def get_role(role_id,**kwargs): """ Get a role by its ID. """ try: role = db.DBSession.query(Role).filter(Role.id==role_id).one() return role except NoResultFound: raise HydraError("Role not found (role_id={})".format(role_id))
python
def get_role(role_id,**kwargs): """ Get a role by its ID. """ try: role = db.DBSession.query(Role).filter(Role.id==role_id).one() return role except NoResultFound: raise HydraError("Role not found (role_id={})".format(role_id))
[ "def", "get_role", "(", "role_id", ",", "*", "*", "kwargs", ")", ":", "try", ":", "role", "=", "db", ".", "DBSession", ".", "query", "(", "Role", ")", ".", "filter", "(", "Role", ".", "id", "==", "role_id", ")", ".", "one", "(", ")", "return", ...
Get a role by its ID.
[ "Get", "a", "role", "by", "its", "ID", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L385-L393
hydraplatform/hydra-base
hydra_base/lib/users.py
get_user_roles
def get_user_roles(uid,**kwargs): """ Get the roles for a user. @param user_id """ try: user_roles = db.DBSession.query(Role).filter(Role.id==RoleUser.role_id, RoleUser.user_id==uid).all() return user_roles except NoResult...
python
def get_user_roles(uid,**kwargs): """ Get the roles for a user. @param user_id """ try: user_roles = db.DBSession.query(Role).filter(Role.id==RoleUser.role_id, RoleUser.user_id==uid).all() return user_roles except NoResult...
[ "def", "get_user_roles", "(", "uid", ",", "*", "*", "kwargs", ")", ":", "try", ":", "user_roles", "=", "db", ".", "DBSession", ".", "query", "(", "Role", ")", ".", "filter", "(", "Role", ".", "id", "==", "RoleUser", ".", "role_id", ",", "RoleUser", ...
Get the roles for a user. @param user_id
[ "Get", "the", "roles", "for", "a", "user", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L395-L405
hydraplatform/hydra-base
hydra_base/lib/users.py
get_user_permissions
def get_user_permissions(uid, **kwargs): """ Get the roles for a user. @param user_id """ try: _get_user(uid) user_perms = db.DBSession.query(Perm).filter(Perm.id==RolePerm.perm_id, RolePerm.role_id==Role.id, ...
python
def get_user_permissions(uid, **kwargs): """ Get the roles for a user. @param user_id """ try: _get_user(uid) user_perms = db.DBSession.query(Perm).filter(Perm.id==RolePerm.perm_id, RolePerm.role_id==Role.id, ...
[ "def", "get_user_permissions", "(", "uid", ",", "*", "*", "kwargs", ")", ":", "try", ":", "_get_user", "(", "uid", ")", "user_perms", "=", "db", ".", "DBSession", ".", "query", "(", "Perm", ")", ".", "filter", "(", "Perm", ".", "id", "==", "RolePerm"...
Get the roles for a user. @param user_id
[ "Get", "the", "roles", "for", "a", "user", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L408-L422
hydraplatform/hydra-base
hydra_base/lib/users.py
get_role_by_code
def get_role_by_code(role_code,**kwargs): """ Get a role by its code """ try: role = db.DBSession.query(Role).filter(Role.code==role_code).one() return role except NoResultFound: raise ResourceNotFoundError("Role not found (role_code={})".format(role_code))
python
def get_role_by_code(role_code,**kwargs): """ Get a role by its code """ try: role = db.DBSession.query(Role).filter(Role.code==role_code).one() return role except NoResultFound: raise ResourceNotFoundError("Role not found (role_code={})".format(role_code))
[ "def", "get_role_by_code", "(", "role_code", ",", "*", "*", "kwargs", ")", ":", "try", ":", "role", "=", "db", ".", "DBSession", ".", "query", "(", "Role", ")", ".", "filter", "(", "Role", ".", "code", "==", "role_code", ")", ".", "one", "(", ")", ...
Get a role by its code
[ "Get", "a", "role", "by", "its", "code" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L425-L433
hydraplatform/hydra-base
hydra_base/lib/users.py
get_perm
def get_perm(perm_id,**kwargs): """ Get all permissions """ try: perm = db.DBSession.query(Perm).filter(Perm.id==perm_id).one() return perm except NoResultFound: raise ResourceNotFoundError("Permission not found (perm_id={})".format(perm_id))
python
def get_perm(perm_id,**kwargs): """ Get all permissions """ try: perm = db.DBSession.query(Perm).filter(Perm.id==perm_id).one() return perm except NoResultFound: raise ResourceNotFoundError("Permission not found (perm_id={})".format(perm_id))
[ "def", "get_perm", "(", "perm_id", ",", "*", "*", "kwargs", ")", ":", "try", ":", "perm", "=", "db", ".", "DBSession", ".", "query", "(", "Perm", ")", ".", "filter", "(", "Perm", ".", "id", "==", "perm_id", ")", ".", "one", "(", ")", "return", ...
Get all permissions
[ "Get", "all", "permissions" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L436-L445
hydraplatform/hydra-base
hydra_base/lib/users.py
get_perm_by_code
def get_perm_by_code(perm_code,**kwargs): """ Get a permission by its code """ try: perm = db.DBSession.query(Perm).filter(Perm.code==perm_code).one() return perm except NoResultFound: raise ResourceNotFoundError("Permission not found (perm_code={})".format(perm_code))
python
def get_perm_by_code(perm_code,**kwargs): """ Get a permission by its code """ try: perm = db.DBSession.query(Perm).filter(Perm.code==perm_code).one() return perm except NoResultFound: raise ResourceNotFoundError("Permission not found (perm_code={})".format(perm_code))
[ "def", "get_perm_by_code", "(", "perm_code", ",", "*", "*", "kwargs", ")", ":", "try", ":", "perm", "=", "db", ".", "DBSession", ".", "query", "(", "Perm", ")", ".", "filter", "(", "Perm", ".", "code", "==", "perm_code", ")", ".", "one", "(", ")", ...
Get a permission by its code
[ "Get", "a", "permission", "by", "its", "code" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/users.py#L447-L456
hydraplatform/hydra-base
hydra_base/lib/HydraTypes/Types.py
Dataframe._create_dataframe
def _create_dataframe(cls, value): """ Builds a dataframe from the value """ try: ordered_jo = json.loads(six.text_type(value), object_pairs_hook=collections.OrderedDict) #Pandas does not maintain the order of dicts, so we must break the dict #up...
python
def _create_dataframe(cls, value): """ Builds a dataframe from the value """ try: ordered_jo = json.loads(six.text_type(value), object_pairs_hook=collections.OrderedDict) #Pandas does not maintain the order of dicts, so we must break the dict #up...
[ "def", "_create_dataframe", "(", "cls", ",", "value", ")", ":", "try", ":", "ordered_jo", "=", "json", ".", "loads", "(", "six", ".", "text_type", "(", "value", ")", ",", "object_pairs_hook", "=", "collections", ".", "OrderedDict", ")", "#Pandas does not mai...
Builds a dataframe from the value
[ "Builds", "a", "dataframe", "from", "the", "value" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/HydraTypes/Types.py#L193-L248
hydraplatform/hydra-base
hydra_base/lib/objects.py
Dataset.parse_value
def parse_value(self): """ Turn the value of an incoming dataset into a hydra-friendly value. """ try: if self.value is None: log.warning("Cannot parse dataset. No value specified.") return None # attr_data.value is a dictionar...
python
def parse_value(self): """ Turn the value of an incoming dataset into a hydra-friendly value. """ try: if self.value is None: log.warning("Cannot parse dataset. No value specified.") return None # attr_data.value is a dictionar...
[ "def", "parse_value", "(", "self", ")", ":", "try", ":", "if", "self", ".", "value", "is", "None", ":", "log", ".", "warning", "(", "\"Cannot parse dataset. No value specified.\"", ")", "return", "None", "# attr_data.value is a dictionary but the keys have namespaces wh...
Turn the value of an incoming dataset into a hydra-friendly value.
[ "Turn", "the", "value", "of", "an", "incoming", "dataset", "into", "a", "hydra", "-", "friendly", "value", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/objects.py#L214-L236
hydraplatform/hydra-base
hydra_base/lib/objects.py
Dataset.get_metadata_as_dict
def get_metadata_as_dict(self, user_id=None, source=None): """ Convert a metadata json string into a dictionary. Args: user_id (int): Optional: Insert user_id into the metadata if specified source (string): Optional: Insert source (the name of the app typically) into the...
python
def get_metadata_as_dict(self, user_id=None, source=None): """ Convert a metadata json string into a dictionary. Args: user_id (int): Optional: Insert user_id into the metadata if specified source (string): Optional: Insert source (the name of the app typically) into the...
[ "def", "get_metadata_as_dict", "(", "self", ",", "user_id", "=", "None", ",", "source", "=", "None", ")", ":", "if", "self", ".", "metadata", "is", "None", "or", "self", ".", "metadata", "==", "\"\"", ":", "return", "{", "}", "metadata_dict", "=", "sel...
Convert a metadata json string into a dictionary. Args: user_id (int): Optional: Insert user_id into the metadata if specified source (string): Optional: Insert source (the name of the app typically) into the metadata if necessary. Returns: dict: THe metadata as a p...
[ "Convert", "a", "metadata", "json", "string", "into", "a", "dictionary", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/objects.py#L239-L264
hydraplatform/hydra-base
hydra_base/lib/groups.py
add_resourcegroup
def add_resourcegroup(group, network_id,**kwargs): """ Add a new group to a network. """ group_i = ResourceGroup() group_i.name = group.name group_i.description = group.description group_i.status = group.status group_i.network_id ...
python
def add_resourcegroup(group, network_id,**kwargs): """ Add a new group to a network. """ group_i = ResourceGroup() group_i.name = group.name group_i.description = group.description group_i.status = group.status group_i.network_id ...
[ "def", "add_resourcegroup", "(", "group", ",", "network_id", ",", "*", "*", "kwargs", ")", ":", "group_i", "=", "ResourceGroup", "(", ")", "group_i", ".", "name", "=", "group", ".", "name", "group_i", ".", "description", "=", "group", ".", "description", ...
Add a new group to a network.
[ "Add", "a", "new", "group", "to", "a", "network", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/groups.py#L43-L54
hydraplatform/hydra-base
hydra_base/lib/groups.py
delete_resourcegroup
def delete_resourcegroup(group_id,**kwargs): """ Add a new group to a scenario. """ group_i = _get_group(group_id) #This should cascaded to delete all the group items. db.DBSession.delete(group_i) db.DBSession.flush() return 'OK'
python
def delete_resourcegroup(group_id,**kwargs): """ Add a new group to a scenario. """ group_i = _get_group(group_id) #This should cascaded to delete all the group items. db.DBSession.delete(group_i) db.DBSession.flush() return 'OK'
[ "def", "delete_resourcegroup", "(", "group_id", ",", "*", "*", "kwargs", ")", ":", "group_i", "=", "_get_group", "(", "group_id", ")", "#This should cascaded to delete all the group items.", "db", ".", "DBSession", ".", "delete", "(", "group_i", ")", "db", ".", ...
Add a new group to a scenario.
[ "Add", "a", "new", "group", "to", "a", "scenario", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/groups.py#L56-L65
hydraplatform/hydra-base
hydra_base/lib/groups.py
update_resourcegroup
def update_resourcegroup(group,**kwargs): """ Add a new group to a network. """ group_i = _get_group(group.id) group_i.name = group.name group_i.description = group.description group_i.status = group.status db.DBSession.flush() return gr...
python
def update_resourcegroup(group,**kwargs): """ Add a new group to a network. """ group_i = _get_group(group.id) group_i.name = group.name group_i.description = group.description group_i.status = group.status db.DBSession.flush() return gr...
[ "def", "update_resourcegroup", "(", "group", ",", "*", "*", "kwargs", ")", ":", "group_i", "=", "_get_group", "(", "group", ".", "id", ")", "group_i", ".", "name", "=", "group", ".", "name", "group_i", ".", "description", "=", "group", ".", "description"...
Add a new group to a network.
[ "Add", "a", "new", "group", "to", "a", "network", "." ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/groups.py#L67-L79
hydraplatform/hydra-base
hydra_base/db/audit.py
create_sqlite_backup_db
def create_sqlite_backup_db(audit_tables): """ return an inspector object """ #we always want to create a whole new DB, so delete the old one first #if it exists. try: Popen("rm %s"%(config.get('sqlite', 'backup_url')), shell=True) logging.warn("Old sqlite backup DB removed")...
python
def create_sqlite_backup_db(audit_tables): """ return an inspector object """ #we always want to create a whole new DB, so delete the old one first #if it exists. try: Popen("rm %s"%(config.get('sqlite', 'backup_url')), shell=True) logging.warn("Old sqlite backup DB removed")...
[ "def", "create_sqlite_backup_db", "(", "audit_tables", ")", ":", "#we always want to create a whole new DB, so delete the old one first", "#if it exists.", "try", ":", "Popen", "(", "\"rm %s\"", "%", "(", "config", ".", "get", "(", "'sqlite'", ",", "'backup_url'", ")", ...
return an inspector object
[ "return", "an", "inspector", "object" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/audit.py#L49-L89
hydraplatform/hydra-base
hydra_base/db/model.py
_is_admin
def _is_admin(user_id): """ Is the specified user an admin """ user = get_session().query(User).filter(User.id==user_id).one() if user.is_admin(): return True else: return False
python
def _is_admin(user_id): """ Is the specified user an admin """ user = get_session().query(User).filter(User.id==user_id).one() if user.is_admin(): return True else: return False
[ "def", "_is_admin", "(", "user_id", ")", ":", "user", "=", "get_session", "(", ")", ".", "query", "(", "User", ")", ".", "filter", "(", "User", ".", "id", "==", "user_id", ")", ".", "one", "(", ")", "if", "user", ".", "is_admin", "(", ")", ":", ...
Is the specified user an admin
[ "Is", "the", "specified", "user", "an", "admin" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/model.py#L80-L89
hydraplatform/hydra-base
hydra_base/db/model.py
Dataset.set_metadata
def set_metadata(self, metadata_dict): """ Set the metadata on a dataset **metadata_dict**: A dictionary of metadata key-vals. Transforms this dict into an array of metadata objects for storage in the DB. """ if metadata_dict is None: ...
python
def set_metadata(self, metadata_dict): """ Set the metadata on a dataset **metadata_dict**: A dictionary of metadata key-vals. Transforms this dict into an array of metadata objects for storage in the DB. """ if metadata_dict is None: ...
[ "def", "set_metadata", "(", "self", ",", "metadata_dict", ")", ":", "if", "metadata_dict", "is", "None", ":", "return", "existing_metadata", "=", "[", "]", "for", "m", "in", "self", ".", "metadata", ":", "existing_metadata", ".", "append", "(", "m", ".", ...
Set the metadata on a dataset **metadata_dict**: A dictionary of metadata key-vals. Transforms this dict into an array of metadata objects for storage in the DB.
[ "Set", "the", "metadata", "on", "a", "dataset" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/model.py#L126-L153
hydraplatform/hydra-base
hydra_base/db/model.py
Dataset.check_user
def check_user(self, user_id): """ Check whether this user can read this dataset """ if self.hidden == 'N': return True for owner in self.owners: if int(owner.user_id) == int(user_id): if owner.view == 'Y': return ...
python
def check_user(self, user_id): """ Check whether this user can read this dataset """ if self.hidden == 'N': return True for owner in self.owners: if int(owner.user_id) == int(user_id): if owner.view == 'Y': return ...
[ "def", "check_user", "(", "self", ",", "user_id", ")", ":", "if", "self", ".", "hidden", "==", "'N'", ":", "return", "True", "for", "owner", "in", "self", ".", "owners", ":", "if", "int", "(", "owner", ".", "user_id", ")", "==", "int", "(", "user_i...
Check whether this user can read this dataset
[ "Check", "whether", "this", "user", "can", "read", "this", "dataset" ]
train
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/model.py#L254-L266