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/network.py | update_network | def update_network(network,
update_nodes = True,
update_links = True,
update_groups = True,
update_scenarios = True,
**kwargs):
"""
Update an entire network
"""
log.info("Updating Network %s", network.name)
user_id = kwargs.get('user_id')
#check_perm('update_network')
... | python | def update_network(network,
update_nodes = True,
update_links = True,
update_groups = True,
update_scenarios = True,
**kwargs):
"""
Update an entire network
"""
log.info("Updating Network %s", network.name)
user_id = kwargs.get('user_id')
#check_perm('update_network')
... | [
"def",
"update_network",
"(",
"network",
",",
"update_nodes",
"=",
"True",
",",
"update_links",
"=",
"True",
",",
"update_groups",
"=",
"True",
",",
"update_scenarios",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"Updating Ne... | Update an entire network | [
"Update",
"an",
"entire",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1298-L1446 |
hydraplatform/hydra-base | hydra_base/lib/network.py | set_network_status | def set_network_status(network_id,status,**kwargs):
"""
Activates a network by setting its status attribute to 'A'.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.che... | python | def set_network_status(network_id,status,**kwargs):
"""
Activates a network by setting its status attribute to 'A'.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.che... | [
"def",
"set_network_status",
"(",
"network_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'delete_network')",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"q... | Activates a network by setting its status attribute to 'A'. | [
"Activates",
"a",
"network",
"by",
"setting",
"its",
"status",
"attribute",
"to",
"A",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1477-L1490 |
hydraplatform/hydra-base | hydra_base/lib/network.py | get_network_extents | def get_network_extents(network_id,**kwargs):
"""
Given a network, return its maximum extents.
This would be the minimum x value of all nodes,
the minimum y value of all nodes,
the maximum x value of all nodes and
maximum y value of all nodes.
@returns NetworkExtents object
"""
rs =... | python | def get_network_extents(network_id,**kwargs):
"""
Given a network, return its maximum extents.
This would be the minimum x value of all nodes,
the minimum y value of all nodes,
the maximum x value of all nodes and
maximum y value of all nodes.
@returns NetworkExtents object
"""
rs =... | [
"def",
"get_network_extents",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"rs",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Node",
".",
"x",
",",
"Node",
".",
"y",
")",
".",
"filter",
"(",
"Node",
".",
"network_id",
"==",
"network_id",... | Given a network, return its maximum extents.
This would be the minimum x value of all nodes,
the minimum y value of all nodes,
the maximum x value of all nodes and
maximum y value of all nodes.
@returns NetworkExtents object | [
"Given",
"a",
"network",
"return",
"its",
"maximum",
"extents",
".",
"This",
"would",
"be",
"the",
"minimum",
"x",
"value",
"of",
"all",
"nodes",
"the",
"minimum",
"y",
"value",
"of",
"all",
"nodes",
"the",
"maximum",
"x",
"value",
"of",
"all",
"nodes",
... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1492-L1536 |
hydraplatform/hydra-base | hydra_base/lib/network.py | add_nodes | def add_nodes(network_id, nodes,**kwargs):
"""
Add nodes to network
"""
start_time = datetime.datetime.now()
names=[] # used to check uniqueness of node name
for n_i in nodes:
if n_i.name in names:
raise HydraError("Duplicate Node Name: %s"%(n_i.name))
nam... | python | def add_nodes(network_id, nodes,**kwargs):
"""
Add nodes to network
"""
start_time = datetime.datetime.now()
names=[] # used to check uniqueness of node name
for n_i in nodes:
if n_i.name in names:
raise HydraError("Duplicate Node Name: %s"%(n_i.name))
nam... | [
"def",
"add_nodes",
"(",
"network_id",
",",
"nodes",
",",
"*",
"*",
"kwargs",
")",
":",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"names",
"=",
"[",
"]",
"# used to check uniqueness of node name",
"for",
"n_i",
"in",
"nodes",
":... | Add nodes to network | [
"Add",
"nodes",
"to",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1539-L1578 |
hydraplatform/hydra-base | hydra_base/lib/network.py | add_links | def add_links(network_id, links,**kwargs):
'''
add links to network
'''
start_time = datetime.datetime.now()
user_id = kwargs.get('user_id')
names=[] # used to check uniqueness of link name before saving links to database
for l_i in links:
if l_i.name in names:
rai... | python | def add_links(network_id, links,**kwargs):
'''
add links to network
'''
start_time = datetime.datetime.now()
user_id = kwargs.get('user_id')
names=[] # used to check uniqueness of link name before saving links to database
for l_i in links:
if l_i.name in names:
rai... | [
"def",
"add_links",
"(",
"network_id",
",",
"links",
",",
"*",
"*",
"kwargs",
")",
":",
"start_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"names",
"=",
"[",
"]",
"# used... | add links to network | [
"add",
"links",
"to",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1581-L1611 |
hydraplatform/hydra-base | hydra_base/lib/network.py | update_node | def update_node(node, flush=True, **kwargs):
"""
Update a node.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
The flush argument indicates whether dbsession.flush should be called. THis
is set to False when update_node is cal... | python | def update_node(node, flush=True, **kwargs):
"""
Update a node.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
The flush argument indicates whether dbsession.flush should be called. THis
is set to False when update_node is cal... | [
"def",
"update_node",
"(",
"node",
",",
"flush",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"node_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Node",
")",
".",
... | Update a node.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
The flush argument indicates whether dbsession.flush should be called. THis
is set to False when update_node is called from another function which does
the flush. | [
"Update",
"a",
"node",
".",
"If",
"new",
"attributes",
"are",
"present",
"they",
"will",
"be",
"added",
"to",
"the",
"node",
".",
"The",
"non",
"-",
"presence",
"of",
"attributes",
"does",
"not",
"remove",
"them",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1671-L1705 |
hydraplatform/hydra-base | hydra_base/lib/network.py | update_nodes | def update_nodes(nodes,**kwargs):
"""
Update multiple nodes.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
%TODO:merge this with the 'update_nodes' functionality in the 'update_netework'
function, so we're not duplicating fun... | python | def update_nodes(nodes,**kwargs):
"""
Update multiple nodes.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
%TODO:merge this with the 'update_nodes' functionality in the 'update_netework'
function, so we're not duplicating fun... | [
"def",
"update_nodes",
"(",
"nodes",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"updated_nodes",
"=",
"[",
"]",
"for",
"n",
"in",
"nodes",
":",
"updated_node_i",
"=",
"update_node",
"(",
"n",
",",
... | Update multiple nodes.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
%TODO:merge this with the 'update_nodes' functionality in the 'update_netework'
function, so we're not duplicating functionality. D.R.Y!
returns: a list of upd... | [
"Update",
"multiple",
"nodes",
".",
"If",
"new",
"attributes",
"are",
"present",
"they",
"will",
"be",
"added",
"to",
"the",
"node",
".",
"The",
"non",
"-",
"presence",
"of",
"attributes",
"does",
"not",
"remove",
"them",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1708-L1727 |
hydraplatform/hydra-base | hydra_base/lib/network.py | set_node_status | def set_node_status(node_id, status, **kwargs):
"""
Set the status of a node to 'X'
"""
user_id = kwargs.get('user_id')
try:
node_i = db.DBSession.query(Node).filter(Node.id == node_id).one()
except NoResultFound:
raise ResourceNotFoundError("Node %s not found"%(node_id))
... | python | def set_node_status(node_id, status, **kwargs):
"""
Set the status of a node to 'X'
"""
user_id = kwargs.get('user_id')
try:
node_i = db.DBSession.query(Node).filter(Node.id == node_id).one()
except NoResultFound:
raise ResourceNotFoundError("Node %s not found"%(node_id))
... | [
"def",
"set_node_status",
"(",
"node_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"node_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Node",
")",
".",
"filter",... | Set the status of a node to 'X' | [
"Set",
"the",
"status",
"of",
"a",
"node",
"to",
"X"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1729-L1750 |
hydraplatform/hydra-base | hydra_base/lib/network.py | purge_network | def purge_network(network_id, purge_data,**kwargs):
"""
Remove a network from DB completely
Use purge_data to try to delete the data associated with only this network.
If no other resources link to this data, it will be deleted.
"""
user_id = kwargs.get('user_id')
try:
n... | python | def purge_network(network_id, purge_data,**kwargs):
"""
Remove a network from DB completely
Use purge_data to try to delete the data associated with only this network.
If no other resources link to this data, it will be deleted.
"""
user_id = kwargs.get('user_id')
try:
n... | [
"def",
"purge_network",
"(",
"network_id",
",",
"purge_data",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Network",
")",
".",
"f... | Remove a network from DB completely
Use purge_data to try to delete the data associated with only this network.
If no other resources link to this data, it will be deleted. | [
"Remove",
"a",
"network",
"from",
"DB",
"completely",
"Use",
"purge_data",
"to",
"try",
"to",
"delete",
"the",
"data",
"associated",
"with",
"only",
"this",
"network",
".",
"If",
"no",
"other",
"resources",
"link",
"to",
"this",
"data",
"it",
"will",
"be",... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1778-L1796 |
hydraplatform/hydra-base | hydra_base/lib/network.py | _purge_datasets_unique_to_resource | def _purge_datasets_unique_to_resource(ref_key, ref_id):
"""
Find the number of times a a resource and dataset combination
occurs. If this equals the number of times the dataset appears, then
we can say this dataset is unique to this resource, therefore it can be deleted
"""
count_qr... | python | def _purge_datasets_unique_to_resource(ref_key, ref_id):
"""
Find the number of times a a resource and dataset combination
occurs. If this equals the number of times the dataset appears, then
we can say this dataset is unique to this resource, therefore it can be deleted
"""
count_qr... | [
"def",
"_purge_datasets_unique_to_resource",
"(",
"ref_key",
",",
"ref_id",
")",
":",
"count_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceScenario",
".",
"dataset_id",
",",
"func",
".",
"count",
"(",
"ResourceScenario",
".",
"dataset_id",
")",
... | Find the number of times a a resource and dataset combination
occurs. If this equals the number of times the dataset appears, then
we can say this dataset is unique to this resource, therefore it can be deleted | [
"Find",
"the",
"number",
"of",
"times",
"a",
"a",
"resource",
"and",
"dataset",
"combination",
"occurs",
".",
"If",
"this",
"equals",
"the",
"number",
"of",
"times",
"the",
"dataset",
"appears",
"then",
"we",
"can",
"say",
"this",
"dataset",
"is",
"unique"... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1799-L1830 |
hydraplatform/hydra-base | hydra_base/lib/network.py | delete_node | def delete_node(node_id, purge_data,**kwargs):
"""
Remove node from DB completely
If there are attributes on the node, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
... | python | def delete_node(node_id, purge_data,**kwargs):
"""
Remove node from DB completely
If there are attributes on the node, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
... | [
"def",
"delete_node",
"(",
"node_id",
",",
"purge_data",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"node_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Node",
")",
".",
"filter",... | Remove node from DB completely
If there are attributes on the node, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted. | [
"Remove",
"node",
"from",
"DB",
"completely",
"If",
"there",
"are",
"attributes",
"on",
"the",
"node",
"use",
"purge_data",
"to",
"try",
"to",
"delete",
"the",
"data",
".",
"If",
"no",
"other",
"resources",
"link",
"to",
"this",
"data",
"it",
"will",
"be... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1832-L1859 |
hydraplatform/hydra-base | hydra_base/lib/network.py | add_link | def add_link(network_id, link,**kwargs):
"""
Add a link to a network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id)
except NoR... | python | def add_link(network_id, link,**kwargs):
"""
Add a link to a network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id)
except NoR... | [
"def",
"add_link",
"(",
"network_id",
",",
"link",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'edit_topology')",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",... | Add a link to a network | [
"Add",
"a",
"link",
"to",
"a",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1861-L1918 |
hydraplatform/hydra-base | hydra_base/lib/network.py | update_link | def update_link(link,**kwargs):
"""
Update a link.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link.id).one()
link_i.network.check_write_permission(user_id)
except NoResultFound:
... | python | def update_link(link,**kwargs):
"""
Update a link.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link.id).one()
link_i.network.check_write_permission(user_id)
except NoResultFound:
... | [
"def",
"update_link",
"(",
"link",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'edit_topology')",
"try",
":",
"link_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Link",
")",
... | Update a link. | [
"Update",
"a",
"link",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1920-L1949 |
hydraplatform/hydra-base | hydra_base/lib/network.py | set_link_status | def set_link_status(link_id, status, **kwargs):
"""
Set the status of a link
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link_id).one()
except NoResultFound:
raise ResourceNotFoundError... | python | def set_link_status(link_id, status, **kwargs):
"""
Set the status of a link
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link_id).one()
except NoResultFound:
raise ResourceNotFoundError... | [
"def",
"set_link_status",
"(",
"link_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'edit_topology')",
"try",
":",
"link_i",
"=",
"db",
".",
"DBSession",
".",
"query",... | Set the status of a link | [
"Set",
"the",
"status",
"of",
"a",
"link"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1951-L1965 |
hydraplatform/hydra-base | hydra_base/lib/network.py | delete_link | def delete_link(link_id, purge_data,**kwargs):
"""
Remove link from DB completely
If there are attributes on the link, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
l... | python | def delete_link(link_id, purge_data,**kwargs):
"""
Remove link from DB completely
If there are attributes on the link, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
l... | [
"def",
"delete_link",
"(",
"link_id",
",",
"purge_data",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"link_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Link",
")",
".",
"filter",... | Remove link from DB completely
If there are attributes on the link, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted. | [
"Remove",
"link",
"from",
"DB",
"completely",
"If",
"there",
"are",
"attributes",
"on",
"the",
"link",
"use",
"purge_data",
"to",
"try",
"to",
"delete",
"the",
"data",
".",
"If",
"no",
"other",
"resources",
"link",
"to",
"this",
"data",
"it",
"will",
"be... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1967-L1992 |
hydraplatform/hydra-base | hydra_base/lib/network.py | add_group | def add_group(network_id, group,**kwargs):
"""
Add a resourcegroup to a network
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
except NoResultFound:
rai... | python | def add_group(network_id, group,**kwargs):
"""
Add a resourcegroup to a network
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
except NoResultFound:
rai... | [
"def",
"add_group",
"(",
"network_id",
",",
"group",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Network",
")",
".",
"filter",
... | Add a resourcegroup to a network | [
"Add",
"a",
"resourcegroup",
"to",
"a",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1994-L2043 |
hydraplatform/hydra-base | hydra_base/lib/network.py | update_group | def update_group(group,**kwargs):
"""
Update a group.
If new attributes are present, they will be added to the group.
The non-presence of attributes does not remove them.
"""
user_id = kwargs.get('user_id')
try:
group_i = db.DBSession.query(ResourceGroup).filter(ResourceG... | python | def update_group(group,**kwargs):
"""
Update a group.
If new attributes are present, they will be added to the group.
The non-presence of attributes does not remove them.
"""
user_id = kwargs.get('user_id')
try:
group_i = db.DBSession.query(ResourceGroup).filter(ResourceG... | [
"def",
"update_group",
"(",
"group",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"group_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceGroup",
")",
".",
"filter",
"(",
"Res... | Update a group.
If new attributes are present, they will be added to the group.
The non-presence of attributes does not remove them. | [
"Update",
"a",
"group",
".",
"If",
"new",
"attributes",
"are",
"present",
"they",
"will",
"be",
"added",
"to",
"the",
"group",
".",
"The",
"non",
"-",
"presence",
"of",
"attributes",
"does",
"not",
"remove",
"them",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2045-L2070 |
hydraplatform/hydra-base | hydra_base/lib/network.py | set_group_status | def set_group_status(group_id, status, **kwargs):
"""
Set the status of a group to 'X'
"""
user_id = kwargs.get('user_id')
try:
group_i = db.DBSession.query(ResourceGroup).filter(ResourceGroup.id == group_id).one()
except NoResultFound:
raise ResourceNotFoundError("ResourceGr... | python | def set_group_status(group_id, status, **kwargs):
"""
Set the status of a group to 'X'
"""
user_id = kwargs.get('user_id')
try:
group_i = db.DBSession.query(ResourceGroup).filter(ResourceGroup.id == group_id).one()
except NoResultFound:
raise ResourceNotFoundError("ResourceGr... | [
"def",
"set_group_status",
"(",
"group_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"group_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceGroup",
")",
".",... | Set the status of a group to 'X' | [
"Set",
"the",
"status",
"of",
"a",
"group",
"to",
"X"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2073-L2089 |
hydraplatform/hydra-base | hydra_base/lib/network.py | delete_group | def delete_group(group_id, purge_data,**kwargs):
"""
Remove group from DB completely
If there are attributes on the group, use purge_data to try to
delete the data. If no other resources group to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
... | python | def delete_group(group_id, purge_data,**kwargs):
"""
Remove group from DB completely
If there are attributes on the group, use purge_data to try to
delete the data. If no other resources group to this data, it
will be deleted.
"""
user_id = kwargs.get('user_id')
try:
... | [
"def",
"delete_group",
"(",
"group_id",
",",
"purge_data",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"group_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceGroup",
")",
".",... | Remove group from DB completely
If there are attributes on the group, use purge_data to try to
delete the data. If no other resources group to this data, it
will be deleted. | [
"Remove",
"group",
"from",
"DB",
"completely",
"If",
"there",
"are",
"attributes",
"on",
"the",
"group",
"use",
"purge_data",
"to",
"try",
"to",
"delete",
"the",
"data",
".",
"If",
"no",
"other",
"resources",
"group",
"to",
"this",
"data",
"it",
"will",
... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2092-L2117 |
hydraplatform/hydra-base | hydra_base/lib/network.py | get_scenarios | def get_scenarios(network_id,**kwargs):
"""
Get all the scenarios in a given network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_read_permission(user_id=user_id)
except NoResultFound:
... | python | def get_scenarios(network_id,**kwargs):
"""
Get all the scenarios in a given network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_read_permission(user_id=user_id)
except NoResultFound:
... | [
"def",
"get_scenarios",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Network",
")",
".",
"filter",
"(",
"Netwo... | Get all the scenarios in a given network. | [
"Get",
"all",
"the",
"scenarios",
"in",
"a",
"given",
"network",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2119-L2131 |
hydraplatform/hydra-base | hydra_base/lib/network.py | validate_network_topology | def validate_network_topology(network_id,**kwargs):
"""
Check for the presence of orphan nodes in a network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
exce... | python | def validate_network_topology(network_id,**kwargs):
"""
Check for the presence of orphan nodes in a network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
exce... | [
"def",
"validate_network_topology",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"net_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Network",
")",
".",
"filter",
"... | Check for the presence of orphan nodes in a network. | [
"Check",
"for",
"the",
"presence",
"of",
"orphan",
"nodes",
"in",
"a",
"network",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2133-L2165 |
hydraplatform/hydra-base | hydra_base/lib/network.py | get_resources_of_type | def get_resources_of_type(network_id, type_id, **kwargs):
"""
Return the Nodes, Links and ResourceGroups which
have the type specified.
"""
nodes_with_type = db.DBSession.query(Node).join(ResourceType).filter(Node.network_id==network_id, ResourceType.type_id==type_id).all()
links_with_t... | python | def get_resources_of_type(network_id, type_id, **kwargs):
"""
Return the Nodes, Links and ResourceGroups which
have the type specified.
"""
nodes_with_type = db.DBSession.query(Node).join(ResourceType).filter(Node.network_id==network_id, ResourceType.type_id==type_id).all()
links_with_t... | [
"def",
"get_resources_of_type",
"(",
"network_id",
",",
"type_id",
",",
"*",
"*",
"kwargs",
")",
":",
"nodes_with_type",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Node",
")",
".",
"join",
"(",
"ResourceType",
")",
".",
"filter",
"(",
"Node",
".",
... | Return the Nodes, Links and ResourceGroups which
have the type specified. | [
"Return",
"the",
"Nodes",
"Links",
"and",
"ResourceGroups",
"which",
"have",
"the",
"type",
"specified",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2182-L2192 |
hydraplatform/hydra-base | hydra_base/lib/network.py | clean_up_network | def clean_up_network(network_id, **kwargs):
"""
Purge any deleted nodes, links, resourcegroups and scenarios in a given network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
log.debug("Querying Network %s", network_id)
net_i = db.DBSession.qu... | python | def clean_up_network(network_id, **kwargs):
"""
Purge any deleted nodes, links, resourcegroups and scenarios in a given network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
log.debug("Querying Network %s", network_id)
net_i = db.DBSession.qu... | [
"def",
"clean_up_network",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'delete_network')",
"try",
":",
"log",
".",
"debug",
"(",
"\"Querying Network %s\"",
",",
"network... | Purge any deleted nodes, links, resourcegroups and scenarios in a given network | [
"Purge",
"any",
"deleted",
"nodes",
"links",
"resourcegroups",
"and",
"scenarios",
"in",
"a",
"given",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2194-L2228 |
hydraplatform/hydra-base | hydra_base/lib/network.py | get_all_resource_attributes_in_network | def get_all_resource_attributes_in_network(attr_id, network_id, **kwargs):
"""
Find every resource attribute in the network matching the supplied attr_id
"""
user_id = kwargs.get('user_id')
try:
a = db.DBSession.query(Attr).filter(Attr.id == attr_id).one()
except NoResultFound:
... | python | def get_all_resource_attributes_in_network(attr_id, network_id, **kwargs):
"""
Find every resource attribute in the network matching the supplied attr_id
"""
user_id = kwargs.get('user_id')
try:
a = db.DBSession.query(Attr).filter(Attr.id == attr_id).one()
except NoResultFound:
... | [
"def",
"get_all_resource_attributes_in_network",
"(",
"attr_id",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"a",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
"... | Find every resource attribute in the network matching the supplied attr_id | [
"Find",
"every",
"resource",
"attribute",
"in",
"the",
"network",
"matching",
"the",
"supplied",
"attr_id"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2380-L2428 |
hydraplatform/hydra-base | hydra_base/lib/network.py | get_all_resource_data | def get_all_resource_data(scenario_id, include_metadata='N', page_start=None, page_end=None, **kwargs):
"""
A function which returns the data for all resources in a network.
-
"""
rs_qry = db.DBSession.query(
ResourceAttr.attr_id,
Attr.name.label('attr_name'),
... | python | def get_all_resource_data(scenario_id, include_metadata='N', page_start=None, page_end=None, **kwargs):
"""
A function which returns the data for all resources in a network.
-
"""
rs_qry = db.DBSession.query(
ResourceAttr.attr_id,
Attr.name.label('attr_name'),
... | [
"def",
"get_all_resource_data",
"(",
"scenario_id",
",",
"include_metadata",
"=",
"'N'",
",",
"page_start",
"=",
"None",
",",
"page_end",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"rs_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAtt... | A function which returns the data for all resources in a network.
- | [
"A",
"function",
"which",
"returns",
"the",
"data",
"for",
"all",
"resources",
"in",
"a",
"network",
".",
"-"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2431-L2521 |
hydraplatform/hydra-base | hydra_base/lib/network.py | clone_network | def clone_network(network_id, recipient_user_id=None, new_network_name=None, project_id=None, project_name=None, new_project=True, **kwargs):
"""
Create an exact clone of the specified network for the specified user.
If project_id is specified, put the new network in there.
Otherwise create a new ... | python | def clone_network(network_id, recipient_user_id=None, new_network_name=None, project_id=None, project_name=None, new_project=True, **kwargs):
"""
Create an exact clone of the specified network for the specified user.
If project_id is specified, put the new network in there.
Otherwise create a new ... | [
"def",
"clone_network",
"(",
"network_id",
",",
"recipient_user_id",
"=",
"None",
",",
"new_network_name",
"=",
"None",
",",
"project_id",
"=",
"None",
",",
"project_name",
"=",
"None",
",",
"new_project",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"u... | Create an exact clone of the specified network for the specified user.
If project_id is specified, put the new network in there.
Otherwise create a new project with the specified name and put it in there. | [
"Create",
"an",
"exact",
"clone",
"of",
"the",
"specified",
"network",
"for",
"the",
"specified",
"user",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L2523-L2630 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | copy_data_from_scenario | def copy_data_from_scenario(resource_attrs, source_scenario_id, target_scenario_id, **kwargs):
"""
For a given list of resource attribute IDS copy the dataset_ids from
the resource scenarios in the source scenario to those in the 'target' scenario.
"""
#Get all the resource scenarios we wis... | python | def copy_data_from_scenario(resource_attrs, source_scenario_id, target_scenario_id, **kwargs):
"""
For a given list of resource attribute IDS copy the dataset_ids from
the resource scenarios in the source scenario to those in the 'target' scenario.
"""
#Get all the resource scenarios we wis... | [
"def",
"copy_data_from_scenario",
"(",
"resource_attrs",
",",
"source_scenario_id",
",",
"target_scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"#Get all the resource scenarios we wish to update",
"target_resourcescenarios",
"=",
"db",
".",
"DBSession",
".",
"query",
"(... | For a given list of resource attribute IDS copy the dataset_ids from
the resource scenarios in the source scenario to those in the 'target' scenario. | [
"For",
"a",
"given",
"list",
"of",
"resource",
"attribute",
"IDS",
"copy",
"the",
"dataset_ids",
"from",
"the",
"resource",
"scenarios",
"in",
"the",
"source",
"scenario",
"to",
"those",
"in",
"the",
"target",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L86-L121 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_scenario | def get_scenario(scenario_id,**kwargs):
"""
Get the specified scenario
"""
user_id = kwargs.get('user_id')
scen_i = _get_scenario(scenario_id, user_id)
scen_j = JSONObject(scen_i)
rscen_rs = db.DBSession.query(ResourceScenario).filter(ResourceScenario.scenario_id==scenario_id).options... | python | def get_scenario(scenario_id,**kwargs):
"""
Get the specified scenario
"""
user_id = kwargs.get('user_id')
scen_i = _get_scenario(scenario_id, user_id)
scen_j = JSONObject(scen_i)
rscen_rs = db.DBSession.query(ResourceScenario).filter(ResourceScenario.scenario_id==scenario_id).options... | [
"def",
"get_scenario",
"(",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"scen_i",
"=",
"_get_scenario",
"(",
"scenario_id",
",",
"user_id",
")",
"scen_j",
"=",
"JSONObject",
"(",
"scen_i",
... | Get the specified scenario | [
"Get",
"the",
"specified",
"scenario"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L123-L152 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | add_scenario | def add_scenario(network_id, scenario,**kwargs):
"""
Add a scenario to a specified network.
"""
user_id = int(kwargs.get('user_id'))
log.info("Adding scenarios to network")
_check_network_ownership(network_id, user_id)
existing_scen = db.DBSession.query(Scenario).filter(Scenario.name==... | python | def add_scenario(network_id, scenario,**kwargs):
"""
Add a scenario to a specified network.
"""
user_id = int(kwargs.get('user_id'))
log.info("Adding scenarios to network")
_check_network_ownership(network_id, user_id)
existing_scen = db.DBSession.query(Scenario).filter(Scenario.name==... | [
"def",
"add_scenario",
"(",
"network_id",
",",
"scenario",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")",
"log",
".",
"info",
"(",
"\"Adding scenarios to network\"",
")",
"_check_network_owner... | Add a scenario to a specified network. | [
"Add",
"a",
"scenario",
"to",
"a",
"specified",
"network",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L154-L218 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | update_scenario | def update_scenario(scenario,update_data=True,update_groups=True,flush=True,**kwargs):
"""
Update a single scenario
as all resources already exist, there is no need to worry
about negative IDS
flush = True flushes to the DB at the end of the function.
flush = False does not ... | python | def update_scenario(scenario,update_data=True,update_groups=True,flush=True,**kwargs):
"""
Update a single scenario
as all resources already exist, there is no need to worry
about negative IDS
flush = True flushes to the DB at the end of the function.
flush = False does not ... | [
"def",
"update_scenario",
"(",
"scenario",
",",
"update_data",
"=",
"True",
",",
"update_groups",
"=",
"True",
",",
"flush",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"scen",
"=",
"_get... | Update a single scenario
as all resources already exist, there is no need to worry
about negative IDS
flush = True flushes to the DB at the end of the function.
flush = False does not flush, assuming that it will happen as part
of another process, like update_network. | [
"Update",
"a",
"single",
"scenario",
"as",
"all",
"resources",
"already",
"exist",
"there",
"is",
"no",
"need",
"to",
"worry",
"about",
"negative",
"IDS"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L220-L286 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | set_scenario_status | def set_scenario_status(scenario_id, status, **kwargs):
"""
Set the status of a scenario.
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
scenario_i = _get_scenario(scenario_id, user_id)
scenario_i.status = status
db.DBSession.flush()
... | python | def set_scenario_status(scenario_id, status, **kwargs):
"""
Set the status of a scenario.
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
scenario_i = _get_scenario(scenario_id, user_id)
scenario_i.status = status
db.DBSession.flush()
... | [
"def",
"set_scenario_status",
"(",
"scenario_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"kwargs",
"[",
"'user_id'",
"]",
")",
"scena... | Set the status of a scenario. | [
"Set",
"the",
"status",
"of",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L288-L301 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | purge_scenario | def purge_scenario(scenario_id, **kwargs):
"""
Set the status of a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
user_id = kwargs.get('user_id')
scenario_i = _get_scenario(scenario_id, user_id)
db.DBSession.delete(scenario_i)
db.DBSession.flush()
retu... | python | def purge_scenario(scenario_id, **kwargs):
"""
Set the status of a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
user_id = kwargs.get('user_id')
scenario_i = _get_scenario(scenario_id, user_id)
db.DBSession.delete(scenario_i)
db.DBSession.flush()
retu... | [
"def",
"purge_scenario",
"(",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"kwargs",
"[",
"'user_id'",
"]",
")",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"scenario_i",
"=",
"_get_s... | Set the status of a scenario. | [
"Set",
"the",
"status",
"of",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L303-L316 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | _get_as_obj | def _get_as_obj(obj_dict, name):
"""
Turn a dictionary into a named tuple so it can be
passed into the constructor of a complex model generator.
"""
if obj_dict.get('_sa_instance_state'):
del obj_dict['_sa_instance_state']
obj = namedtuple(name, tuple(obj_dict.keys()))
for k,... | python | def _get_as_obj(obj_dict, name):
"""
Turn a dictionary into a named tuple so it can be
passed into the constructor of a complex model generator.
"""
if obj_dict.get('_sa_instance_state'):
del obj_dict['_sa_instance_state']
obj = namedtuple(name, tuple(obj_dict.keys()))
for k,... | [
"def",
"_get_as_obj",
"(",
"obj_dict",
",",
"name",
")",
":",
"if",
"obj_dict",
".",
"get",
"(",
"'_sa_instance_state'",
")",
":",
"del",
"obj_dict",
"[",
"'_sa_instance_state'",
"]",
"obj",
"=",
"namedtuple",
"(",
"name",
",",
"tuple",
"(",
"obj_dict",
".... | Turn a dictionary into a named tuple so it can be
passed into the constructor of a complex model generator. | [
"Turn",
"a",
"dictionary",
"into",
"a",
"named",
"tuple",
"so",
"it",
"can",
"be",
"passed",
"into",
"the",
"constructor",
"of",
"a",
"complex",
"model",
"generator",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L434-L445 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_resource_scenario | def get_resource_scenario(resource_attr_id, scenario_id, **kwargs):
"""
Get the resource scenario object for a given resource atttribute and scenario.
This is done when you know the attribute, resource and scenario and want to get the
value associated with it.
"""
user_id = kwargs.ge... | python | def get_resource_scenario(resource_attr_id, scenario_id, **kwargs):
"""
Get the resource scenario object for a given resource atttribute and scenario.
This is done when you know the attribute, resource and scenario and want to get the
value associated with it.
"""
user_id = kwargs.ge... | [
"def",
"get_resource_scenario",
"(",
"resource_attr_id",
",",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"_get_scenario",
"(",
"scenario_id",
",",
"user_id",
")",
"try",
":",
"rs",
"=",
"d... | Get the resource scenario object for a given resource atttribute and scenario.
This is done when you know the attribute, resource and scenario and want to get the
value associated with it. | [
"Get",
"the",
"resource",
"scenario",
"object",
"for",
"a",
"given",
"resource",
"atttribute",
"and",
"scenario",
".",
"This",
"is",
"done",
"when",
"you",
"know",
"the",
"attribute",
"resource",
"and",
"scenario",
"and",
"want",
"to",
"get",
"the",
"value",... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L559-L575 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | bulk_update_resourcedata | def bulk_update_resourcedata(scenario_ids, resource_scenarios,**kwargs):
"""
Update the data associated with a list of scenarios.
"""
user_id = kwargs.get('user_id')
res = None
res = {}
net_ids = db.DBSession.query(Scenario.network_id).filter(Scenario.id.in_(scenario_ids)).all()
i... | python | def bulk_update_resourcedata(scenario_ids, resource_scenarios,**kwargs):
"""
Update the data associated with a list of scenarios.
"""
user_id = kwargs.get('user_id')
res = None
res = {}
net_ids = db.DBSession.query(Scenario.network_id).filter(Scenario.id.in_(scenario_ids)).all()
i... | [
"def",
"bulk_update_resourcedata",
"(",
"scenario_ids",
",",
"resource_scenarios",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"res",
"=",
"None",
"res",
"=",
"{",
"}",
"net_ids",
"=",
"db",
".",
"DBSes... | Update the data associated with a list of scenarios. | [
"Update",
"the",
"data",
"associated",
"with",
"a",
"list",
"of",
"scenarios",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L624-L653 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | update_resourcedata | def update_resourcedata(scenario_id, resource_scenarios,**kwargs):
"""
Update the data associated with a scenario.
Data missing from the resource scenario will not be removed
from the scenario. Use the remove_resourcedata for this task.
If the resource scenario does not exist, it wi... | python | def update_resourcedata(scenario_id, resource_scenarios,**kwargs):
"""
Update the data associated with a scenario.
Data missing from the resource scenario will not be removed
from the scenario. Use the remove_resourcedata for this task.
If the resource scenario does not exist, it wi... | [
"def",
"update_resourcedata",
"(",
"scenario_id",
",",
"resource_scenarios",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"res",
"=",
"None",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"kwargs",
"[",... | Update the data associated with a scenario.
Data missing from the resource scenario will not be removed
from the scenario. Use the remove_resourcedata for this task.
If the resource scenario does not exist, it will be created.
If the value of the resource scenario is specified as being ... | [
"Update",
"the",
"data",
"associated",
"with",
"a",
"scenario",
".",
"Data",
"missing",
"from",
"the",
"resource",
"scenario",
"will",
"not",
"be",
"removed",
"from",
"the",
"scenario",
".",
"Use",
"the",
"remove_resourcedata",
"for",
"this",
"task",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L655-L689 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | delete_resource_scenario | def delete_resource_scenario(scenario_id, resource_attr_id, quiet=False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
_delete_resourcescenario(scenario_id, resource_attr_id, suppress_error=quiet) | python | def delete_resource_scenario(scenario_id, resource_attr_id, quiet=False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
_delete_resourcescenario(scenario_id, resource_attr_id, suppress_error=quiet) | [
"def",
"delete_resource_scenario",
"(",
"scenario_id",
",",
"resource_attr_id",
",",
"quiet",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"kwargs",
"[",
"'user_id'",
"]",
")",
"_delete_resourcescenario",
"(... | Remove the data associated with a resource in a scenario. | [
"Remove",
"the",
"data",
"associated",
"with",
"a",
"resource",
"in",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L691-L697 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | delete_resourcedata | def delete_resourcedata(scenario_id, resource_scenario, quiet = False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
The 'quiet' parameter indicates whether an non-existent RS should throw
an error.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id... | python | def delete_resourcedata(scenario_id, resource_scenario, quiet = False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
The 'quiet' parameter indicates whether an non-existent RS should throw
an error.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id... | [
"def",
"delete_resourcedata",
"(",
"scenario_id",
",",
"resource_scenario",
",",
"quiet",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"kwargs",
"[",
"'user_id'",
"]",
")",
"_delete_resourcescenario",
"(",
... | Remove the data associated with a resource in a scenario.
The 'quiet' parameter indicates whether an non-existent RS should throw
an error. | [
"Remove",
"the",
"data",
"associated",
"with",
"a",
"resource",
"in",
"a",
"scenario",
".",
"The",
"quiet",
"parameter",
"indicates",
"whether",
"an",
"non",
"-",
"existent",
"RS",
"should",
"throw",
"an",
"error",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L699-L708 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | _update_resourcescenario | def _update_resourcescenario(scenario, resource_scenario, dataset=None, new=False, user_id=None, source=None):
"""
Insert or Update the value of a resource's attribute by first getting the
resource, then parsing the input data, then assigning the value.
returns a ResourceScenario object.
... | python | def _update_resourcescenario(scenario, resource_scenario, dataset=None, new=False, user_id=None, source=None):
"""
Insert or Update the value of a resource's attribute by first getting the
resource, then parsing the input data, then assigning the value.
returns a ResourceScenario object.
... | [
"def",
"_update_resourcescenario",
"(",
"scenario",
",",
"resource_scenario",
",",
"dataset",
"=",
"None",
",",
"new",
"=",
"False",
",",
"user_id",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"if",
"scenario",
"is",
"None",
":",
"scenario",
"=",
... | Insert or Update the value of a resource's attribute by first getting the
resource, then parsing the input data, then assigning the value.
returns a ResourceScenario object. | [
"Insert",
"or",
"Update",
"the",
"value",
"of",
"a",
"resource",
"s",
"attribute",
"by",
"first",
"getting",
"the",
"resource",
"then",
"parsing",
"the",
"input",
"data",
"then",
"assigning",
"the",
"value",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L725-L786 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | assign_value | def assign_value(rs, data_type, val,
unit_id, name, metadata={}, data_hash=None, user_id=None, source=None):
"""
Insert or update a piece of data in a scenario.
If the dataset is being shared by other resource scenarios, a new dataset is inserted.
If the dataset is ONLY bein... | python | def assign_value(rs, data_type, val,
unit_id, name, metadata={}, data_hash=None, user_id=None, source=None):
"""
Insert or update a piece of data in a scenario.
If the dataset is being shared by other resource scenarios, a new dataset is inserted.
If the dataset is ONLY bein... | [
"def",
"assign_value",
"(",
"rs",
",",
"data_type",
",",
"val",
",",
"unit_id",
",",
"name",
",",
"metadata",
"=",
"{",
"}",
",",
"data_hash",
"=",
"None",
",",
"user_id",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",... | Insert or update a piece of data in a scenario.
If the dataset is being shared by other resource scenarios, a new dataset is inserted.
If the dataset is ONLY being used by the resource scenario in question, the dataset
is updated to avoid unnecessary duplication. | [
"Insert",
"or",
"update",
"a",
"piece",
"of",
"data",
"in",
"a",
"scenario",
".",
"If",
"the",
"dataset",
"is",
"being",
"shared",
"by",
"other",
"resource",
"scenarios",
"a",
"new",
"dataset",
"is",
"inserted",
".",
"If",
"the",
"dataset",
"is",
"ONLY",... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L788-L846 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | add_data_to_attribute | def add_data_to_attribute(scenario_id, resource_attr_id, dataset,**kwargs):
"""
Add data to a resource scenario outside of a network update
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, user_id)
scenario_i = _get_scenario(scenario_id, user_id)
try:
... | python | def add_data_to_attribute(scenario_id, resource_attr_id, dataset,**kwargs):
"""
Add data to a resource scenario outside of a network update
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, user_id)
scenario_i = _get_scenario(scenario_id, user_id)
try:
... | [
"def",
"add_data_to_attribute",
"(",
"scenario_id",
",",
"resource_attr_id",
",",
"dataset",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"_check_can_edit_scenario",
"(",
"scenario_id",
",",
"user_id",
")",
"s... | Add data to a resource scenario outside of a network update | [
"Add",
"data",
"to",
"a",
"resource",
"scenario",
"outside",
"of",
"a",
"network",
"update"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L848-L886 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_scenario_data | def get_scenario_data(scenario_id,**kwargs):
"""
Get all the datasets from the group with the specified name
@returns a list of dictionaries
"""
user_id = kwargs.get('user_id')
scenario_data = db.DBSession.query(Dataset).filter(Dataset.id==ResourceScenario.dataset_id, ResourceScenario.s... | python | def get_scenario_data(scenario_id,**kwargs):
"""
Get all the datasets from the group with the specified name
@returns a list of dictionaries
"""
user_id = kwargs.get('user_id')
scenario_data = db.DBSession.query(Dataset).filter(Dataset.id==ResourceScenario.dataset_id, ResourceScenario.s... | [
"def",
"get_scenario_data",
"(",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"scenario_data",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Dataset",
")",
".",
"filter",
"(",
"Dataset"... | Get all the datasets from the group with the specified name
@returns a list of dictionaries | [
"Get",
"all",
"the",
"datasets",
"from",
"the",
"group",
"with",
"the",
"specified",
"name"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L888-L908 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_attribute_data | def get_attribute_data(attr_ids, node_ids, **kwargs):
"""
For a given attribute or set of attributes, return all the resources and
resource scenarios in the network
"""
node_attrs = db.DBSession.query(ResourceAttr).\
options(joinedload_all('attr')... | python | def get_attribute_data(attr_ids, node_ids, **kwargs):
"""
For a given attribute or set of attributes, return all the resources and
resource scenarios in the network
"""
node_attrs = db.DBSession.query(ResourceAttr).\
options(joinedload_all('attr')... | [
"def",
"get_attribute_data",
"(",
"attr_ids",
",",
"node_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"node_attrs",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
")",
".",
"options",
"(",
"joinedload_all",
"(",
"'attr'",
")",
")",
".",
"fil... | For a given attribute or set of attributes, return all the resources and
resource scenarios in the network | [
"For",
"a",
"given",
"attribute",
"or",
"set",
"of",
"attributes",
"return",
"all",
"the",
"resources",
"and",
"resource",
"scenarios",
"in",
"the",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L910-L936 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_resource_data | def get_resource_data(ref_key, ref_id, scenario_id, type_id=None, expunge_session=True, **kwargs):
"""
Get all the resource scenarios for a given resource
in a given scenario. If type_id is specified, only
return the resource scenarios for the attributes
within the type.
"""
... | python | def get_resource_data(ref_key, ref_id, scenario_id, type_id=None, expunge_session=True, **kwargs):
"""
Get all the resource scenarios for a given resource
in a given scenario. If type_id is specified, only
return the resource scenarios for the attributes
within the type.
"""
... | [
"def",
"get_resource_data",
"(",
"ref_key",
",",
"ref_id",
",",
"scenario_id",
",",
"type_id",
"=",
"None",
",",
"expunge_session",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"resource_data_... | Get all the resource scenarios for a given resource
in a given scenario. If type_id is specified, only
return the resource scenarios for the attributes
within the type. | [
"Get",
"all",
"the",
"resource",
"scenarios",
"for",
"a",
"given",
"resource",
"in",
"a",
"given",
"scenario",
".",
"If",
"type_id",
"is",
"specified",
"only",
"return",
"the",
"resource",
"scenarios",
"for",
"the",
"attributes",
"within",
"the",
"type",
"."... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L938-L986 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_attribute_datasets | def get_attribute_datasets(attr_id, scenario_id, **kwargs):
"""
Retrieve all the datasets in a scenario for a given attribute.
Also return the resource attributes so there is a reference to the node/link
"""
user_id = kwargs.get('user_id')
scenario_i = _get_scenario(scenario_id, user_i... | python | def get_attribute_datasets(attr_id, scenario_id, **kwargs):
"""
Retrieve all the datasets in a scenario for a given attribute.
Also return the resource attributes so there is a reference to the node/link
"""
user_id = kwargs.get('user_id')
scenario_i = _get_scenario(scenario_id, user_i... | [
"def",
"get_attribute_datasets",
"(",
"attr_id",
",",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"scenario_i",
"=",
"_get_scenario",
"(",
"scenario_id",
",",
"user_id",
")",
"try",
":",
"a... | Retrieve all the datasets in a scenario for a given attribute.
Also return the resource attributes so there is a reference to the node/link | [
"Retrieve",
"all",
"the",
"datasets",
"in",
"a",
"scenario",
"for",
"a",
"given",
"attribute",
".",
"Also",
"return",
"the",
"resource",
"attributes",
"so",
"there",
"is",
"a",
"reference",
"to",
"the",
"node",
"/",
"link"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L997-L1043 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | get_resourcegroupitems | def get_resourcegroupitems(group_id, scenario_id, **kwargs):
"""
Get all the items in a group, in a scenario. If group_id is None, return
all items across all groups in the scenario.
"""
rgi_qry = db.DBSession.query(ResourceGroupItem).\
filter(ResourceGroupItem.scenario_id=... | python | def get_resourcegroupitems(group_id, scenario_id, **kwargs):
"""
Get all the items in a group, in a scenario. If group_id is None, return
all items across all groups in the scenario.
"""
rgi_qry = db.DBSession.query(ResourceGroupItem).\
filter(ResourceGroupItem.scenario_id=... | [
"def",
"get_resourcegroupitems",
"(",
"group_id",
",",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"rgi_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceGroupItem",
")",
".",
"filter",
"(",
"ResourceGroupItem",
".",
"scenario_id",
"==",
"... | Get all the items in a group, in a scenario. If group_id is None, return
all items across all groups in the scenario. | [
"Get",
"all",
"the",
"items",
"in",
"a",
"group",
"in",
"a",
"scenario",
".",
"If",
"group_id",
"is",
"None",
"return",
"all",
"items",
"across",
"all",
"groups",
"in",
"the",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1045-L1060 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | delete_resourcegroupitems | def delete_resourcegroupitems(scenario_id, item_ids, **kwargs):
"""
Delete specified items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
for item_id in item_ids:
rgi = db.DBSession.query(Resource... | python | def delete_resourcegroupitems(scenario_id, item_ids, **kwargs):
"""
Delete specified items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
for item_id in item_ids:
rgi = db.DBSession.query(Resource... | [
"def",
"delete_resourcegroupitems",
"(",
"scenario_id",
",",
"item_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")",
"#check the scenario exists",
"_get_scenario",
"(",
"scenario_id",
",",
"u... | Delete specified items in a group, in a scenario. | [
"Delete",
"specified",
"items",
"in",
"a",
"group",
"in",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1062-L1074 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | empty_group | def empty_group(group_id, scenario_id, **kwargs):
"""
Delete all itemas in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
rgi = db.DBSession.query(ResourceGroupItem).\
filter(ResourceGroupItem.g... | python | def empty_group(group_id, scenario_id, **kwargs):
"""
Delete all itemas in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
rgi = db.DBSession.query(ResourceGroupItem).\
filter(ResourceGroupItem.g... | [
"def",
"empty_group",
"(",
"group_id",
",",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")",
"#check the scenario exists",
"_get_scenario",
"(",
"scenario_id",
",",
"user_id",
")"... | Delete all itemas in a group, in a scenario. | [
"Delete",
"all",
"itemas",
"in",
"a",
"group",
"in",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1076-L1087 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | add_resourcegroupitems | def add_resourcegroupitems(scenario_id, items, scenario=None, **kwargs):
"""
Get all the items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
if scenario is None:
scenario = _get_scenario(scenario_id, user_id)
_check_network_ownership(scenario.network_id, user... | python | def add_resourcegroupitems(scenario_id, items, scenario=None, **kwargs):
"""
Get all the items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
if scenario is None:
scenario = _get_scenario(scenario_id, user_id)
_check_network_ownership(scenario.network_id, user... | [
"def",
"add_resourcegroupitems",
"(",
"scenario_id",
",",
"items",
",",
"scenario",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")",
"if",
"scenario",
"is",
"None",
":",
"scen... | Get all the items in a group, in a scenario. | [
"Get",
"all",
"the",
"items",
"in",
"a",
"group",
"in",
"a",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1089-L1108 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | _add_resourcegroupitem | def _add_resourcegroupitem(group_item, scenario_id):
"""
Add a single resource group item (no DB flush, as it's an internal function)
"""
if group_item.id and group_item.id > 0:
try:
group_item_i = db.DBSession.query(ResourceGroupItem).filter(ResourceGroupItem.id == group_item.id... | python | def _add_resourcegroupitem(group_item, scenario_id):
"""
Add a single resource group item (no DB flush, as it's an internal function)
"""
if group_item.id and group_item.id > 0:
try:
group_item_i = db.DBSession.query(ResourceGroupItem).filter(ResourceGroupItem.id == group_item.id... | [
"def",
"_add_resourcegroupitem",
"(",
"group_item",
",",
"scenario_id",
")",
":",
"if",
"group_item",
".",
"id",
"and",
"group_item",
".",
"id",
">",
"0",
":",
"try",
":",
"group_item_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceGroupItem",
... | Add a single resource group item (no DB flush, as it's an internal function) | [
"Add",
"a",
"single",
"resource",
"group",
"item",
"(",
"no",
"DB",
"flush",
"as",
"it",
"s",
"an",
"internal",
"function",
")"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1110-L1137 |
hydraplatform/hydra-base | hydra_base/lib/scenario.py | update_value_from_mapping | def update_value_from_mapping(source_resource_attr_id, target_resource_attr_id, source_scenario_id, target_scenario_id, **kwargs):
"""
Using a resource attribute mapping, take the value from the source and apply
it to the target. Both source and target scenarios must be specified (and therefor
... | python | def update_value_from_mapping(source_resource_attr_id, target_resource_attr_id, source_scenario_id, target_scenario_id, **kwargs):
"""
Using a resource attribute mapping, take the value from the source and apply
it to the target. Both source and target scenarios must be specified (and therefor
... | [
"def",
"update_value_from_mapping",
"(",
"source_resource_attr_id",
",",
"target_resource_attr_id",
",",
"source_scenario_id",
",",
"target_scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"int",
"(",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
")... | Using a resource attribute mapping, take the value from the source and apply
it to the target. Both source and target scenarios must be specified (and therefor
must exist). | [
"Using",
"a",
"resource",
"attribute",
"mapping",
"take",
"the",
"value",
"from",
"the",
"source",
"and",
"apply",
"it",
"to",
"the",
"target",
".",
"Both",
"source",
"and",
"target",
"scenarios",
"must",
"be",
"specified",
"(",
"and",
"therefor",
"must",
... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/scenario.py#L1139-L1198 |
hydraplatform/hydra-base | hydra_base/lib/plugins.py | get_plugins | def get_plugins(**kwargs):
"""
Get all available plugins
"""
plugins = []
plugin_paths = []
#Look in directory or set of directories for
#plugins
base_plugin_dir = config.get('plugin', 'default_directory')
plugin_xsd_path = config.get('plugin', 'plugin_xsd_path')
... | python | def get_plugins(**kwargs):
"""
Get all available plugins
"""
plugins = []
plugin_paths = []
#Look in directory or set of directories for
#plugins
base_plugin_dir = config.get('plugin', 'default_directory')
plugin_xsd_path = config.get('plugin', 'plugin_xsd_path')
... | [
"def",
"get_plugins",
"(",
"*",
"*",
"kwargs",
")",
":",
"plugins",
"=",
"[",
"]",
"plugin_paths",
"=",
"[",
"]",
"#Look in directory or set of directories for",
"#plugins",
"base_plugin_dir",
"=",
"config",
".",
"get",
"(",
"'plugin'",
",",
"'default_directory'",... | Get all available plugins | [
"Get",
"all",
"available",
"plugins"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/plugins.py#L31-L95 |
hydraplatform/hydra-base | hydra_base/lib/plugins.py | run_plugin | def run_plugin(plugin,**kwargs):
"""
Run a plugin
"""
args = [sys.executable]
#Get plugin executable
home = os.path.expanduser('~')
path_to_plugin = os.path.join(home, 'svn/HYDRA/HydraPlugins', plugin.location)
args.append(path_to_plugin)
#Parse plugin arguments into a ... | python | def run_plugin(plugin,**kwargs):
"""
Run a plugin
"""
args = [sys.executable]
#Get plugin executable
home = os.path.expanduser('~')
path_to_plugin = os.path.join(home, 'svn/HYDRA/HydraPlugins', plugin.location)
args.append(path_to_plugin)
#Parse plugin arguments into a ... | [
"def",
"run_plugin",
"(",
"plugin",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"[",
"sys",
".",
"executable",
"]",
"#Get plugin executable",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"path_to_plugin",
"=",
"os",
".",
"pat... | Run a plugin | [
"Run",
"a",
"plugin"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/plugins.py#L97-L136 |
hydraplatform/hydra-base | hydra_base/config.py | load_config | def load_config():
"""Load a config file. This function looks for a config (*.ini) file in the
following order::
(1) ./*.ini
(2) ~/.config/hydra/
(3) /etc/hydra
(4) /path/to/hydra_base/*.ini
(1) will override (2) will override (3) will override (4). Parameters not
defin... | python | def load_config():
"""Load a config file. This function looks for a config (*.ini) file in the
following order::
(1) ./*.ini
(2) ~/.config/hydra/
(3) /etc/hydra
(4) /path/to/hydra_base/*.ini
(1) will override (2) will override (3) will override (4). Parameters not
defin... | [
"def",
"load_config",
"(",
")",
":",
"global",
"localfiles",
"global",
"localfile",
"global",
"repofile",
"global",
"repofiles",
"global",
"userfile",
"global",
"userfiles",
"global",
"sysfile",
"global",
"sysfiles",
"global",
"CONFIG",
"logging",
".",
"basicConfig"... | Load a config file. This function looks for a config (*.ini) file in the
following order::
(1) ./*.ini
(2) ~/.config/hydra/
(3) /etc/hydra
(4) /path/to/hydra_base/*.ini
(1) will override (2) will override (3) will override (4). Parameters not
defined in (1) will be taken fr... | [
"Load",
"a",
"config",
"file",
".",
"This",
"function",
"looks",
"for",
"a",
"config",
"(",
"*",
".",
"ini",
")",
"file",
"in",
"the",
"following",
"order",
"::"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/config.py#L42-L134 |
hydraplatform/hydra-base | hydra_base/db/__init__.py | create_mysql_db | def create_mysql_db(db_url):
"""
To simplify deployment, create the mysql DB if it's not there.
Accepts a URL with or without a DB name stated, and returns a db url
containing the db name for use in the main sqlalchemy engine.
THe formats can take the following form:
mysql+... | python | def create_mysql_db(db_url):
"""
To simplify deployment, create the mysql DB if it's not there.
Accepts a URL with or without a DB name stated, and returns a db url
containing the db name for use in the main sqlalchemy engine.
THe formats can take the following form:
mysql+... | [
"def",
"create_mysql_db",
"(",
"db_url",
")",
":",
"#Remove trailing whitespace and forwardslashes",
"db_url",
"=",
"db_url",
".",
"strip",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"#Check this is a mysql URL",
"if",
"db_url",
".",
"find",
"(",
"'mysql'",
")",
"... | To simplify deployment, create the mysql DB if it's not there.
Accepts a URL with or without a DB name stated, and returns a db url
containing the db name for use in the main sqlalchemy engine.
THe formats can take the following form:
mysql+driver://username:password@hostname
m... | [
"To",
"simplify",
"deployment",
"create",
"the",
"mysql",
"DB",
"if",
"it",
"s",
"not",
"there",
".",
"Accepts",
"a",
"URL",
"with",
"or",
"without",
"a",
"DB",
"name",
"stated",
"and",
"returns",
"a",
"db",
"url",
"containing",
"the",
"db",
"name",
"f... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/db/__init__.py#L43-L89 |
hydraplatform/hydra-base | hydra_base/lib/project.py | add_project | def add_project(project,**kwargs):
"""
Add a new project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
existing_proj = get_project_by_name(project.name,user_id=user_id)
if len(existing_proj) > 0:
raise HydraError("A Project with the name \"%s\" already ... | python | def add_project(project,**kwargs):
"""
Add a new project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
existing_proj = get_project_by_name(project.name,user_id=user_id)
if len(existing_proj) > 0:
raise HydraError("A Project with the name \"%s\" already ... | [
"def",
"add_project",
"(",
"project",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"existing_proj",
"=",
"get_project_by_name",
"(",
"project",
".",
"name",
",",
"user_id",
"=",
"user_id",
")",
"if",
"le... | Add a new project
returns a project complexmodel | [
"Add",
"a",
"new",
"project",
"returns",
"a",
"project",
"complexmodel"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L65-L93 |
hydraplatform/hydra-base | hydra_base/lib/project.py | update_project | def update_project(project,**kwargs):
"""
Update a project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'update_project')
proj_i = _get_project(project.id)
proj_i.check_write_permission(user_id)
proj_i.name = project.name
... | python | def update_project(project,**kwargs):
"""
Update a project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'update_project')
proj_i = _get_project(project.id)
proj_i.check_write_permission(user_id)
proj_i.name = project.name
... | [
"def",
"update_project",
"(",
"project",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'update_project')",
"proj_i",
"=",
"_get_project",
"(",
"project",
".",
"id",
")",
"proj_i",
".",
"... | Update a project
returns a project complexmodel | [
"Update",
"a",
"project",
"returns",
"a",
"project",
"complexmodel"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L95-L115 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_project | def get_project(project_id, include_deleted_networks=False, **kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
proj_i = _get_project(project_id)
#lazy load owners
proj_i.owners
proj_i.check_read_permission(user_id)
proj_j = JSONObject(proj_i)
pr... | python | def get_project(project_id, include_deleted_networks=False, **kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
proj_i = _get_project(project_id)
#lazy load owners
proj_i.owners
proj_i.check_read_permission(user_id)
proj_j = JSONObject(proj_i)
pr... | [
"def",
"get_project",
"(",
"project_id",
",",
"include_deleted_networks",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"proj_i",
"=",
"_get_project",
"(",
"project_id",
")",
"#lazy load owners",
... | get a project complexmodel | [
"get",
"a",
"project",
"complexmodel"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L117-L147 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_project_by_network_id | def get_project_by_network_id(network_id,**kwargs):
"""
get a project complexmodel by a network_id
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).join(Network, Project.id==Network.project_id).filter(
... | python | def get_project_by_network_id(network_id,**kwargs):
"""
get a project complexmodel by a network_id
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).join(Network, Project.id==Network.project_id).filter(
... | [
"def",
"get_project_by_network_id",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"projects_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Project",
")",
".",
"join",
"(",
"Projec... | get a project complexmodel by a network_id | [
"get",
"a",
"project",
"complexmodel",
"by",
"a",
"network_id"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L149-L166 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_project_by_name | def get_project_by_name(project_name,**kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).filter(
Project.name==project_name,
... | python | def get_project_by_name(project_name,**kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).filter(
Project.name==project_name,
... | [
"def",
"get_project_by_name",
"(",
"project_name",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"projects_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Project",
")",
".",
"join",
"(",
"ProjectOwn... | get a project complexmodel | [
"get",
"a",
"project",
"complexmodel"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L169-L187 |
hydraplatform/hydra-base | hydra_base/lib/project.py | to_named_tuple | def to_named_tuple(obj, visited_children=None, back_relationships=None, levels=None, ignore=[], extras={}):
"""
Altered from an example found on stackoverflow
http://stackoverflow.com/questions/23554119/convert-sqlalchemy-orm-result-to-dict
"""
if visited_children is None:
visited_c... | python | def to_named_tuple(obj, visited_children=None, back_relationships=None, levels=None, ignore=[], extras={}):
"""
Altered from an example found on stackoverflow
http://stackoverflow.com/questions/23554119/convert-sqlalchemy-orm-result-to-dict
"""
if visited_children is None:
visited_c... | [
"def",
"to_named_tuple",
"(",
"obj",
",",
"visited_children",
"=",
"None",
",",
"back_relationships",
"=",
"None",
",",
"levels",
"=",
"None",
",",
"ignore",
"=",
"[",
"]",
",",
"extras",
"=",
"{",
"}",
")",
":",
"if",
"visited_children",
"is",
"None",
... | Altered from an example found on stackoverflow
http://stackoverflow.com/questions/23554119/convert-sqlalchemy-orm-result-to-dict | [
"Altered",
"from",
"an",
"example",
"found",
"on",
"stackoverflow",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"23554119",
"/",
"convert",
"-",
"sqlalchemy",
"-",
"orm",
"-",
"result",
"-",
"to",
"-",
"dict"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L189-L252 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_projects | def get_projects(uid, include_shared_projects=True, projects_ids_list_filter=None, **kwargs):
"""
Get all the projects owned by the specified user.
These include projects created by the user, but also ones shared with the user.
For shared projects, only include networks in those projects whi... | python | def get_projects(uid, include_shared_projects=True, projects_ids_list_filter=None, **kwargs):
"""
Get all the projects owned by the specified user.
These include projects created by the user, but also ones shared with the user.
For shared projects, only include networks in those projects whi... | [
"def",
"get_projects",
"(",
"uid",
",",
"include_shared_projects",
"=",
"True",
",",
"projects_ids_list_filter",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"req_user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"##Don't load the project's networks. ... | Get all the projects owned by the specified user.
These include projects created by the user, but also ones shared with the user.
For shared projects, only include networks in those projects which are accessible to the user.
the include_shared_projects flag indicates whether to include projects... | [
"Get",
"all",
"the",
"projects",
"owned",
"by",
"the",
"specified",
"user",
".",
"These",
"include",
"projects",
"created",
"by",
"the",
"user",
"but",
"also",
"ones",
"shared",
"with",
"the",
"user",
".",
"For",
"shared",
"projects",
"only",
"include",
"n... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L255-L337 |
hydraplatform/hydra-base | hydra_base/lib/project.py | set_project_status | def set_project_status(project_id, status, **kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
project.status = status
db.DBSession.... | python | def set_project_status(project_id, status, **kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
project.status = status
db.DBSession.... | [
"def",
"set_project_status",
"(",
"project_id",
",",
"status",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'delete_project')",
"project",
"=",
"_get_project",
"(",
"project_id",
")",
"proj... | Set the status of a project to 'X' | [
"Set",
"the",
"status",
"of",
"a",
"project",
"to",
"X"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L340-L349 |
hydraplatform/hydra-base | hydra_base/lib/project.py | delete_project | def delete_project(project_id,**kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
db.DBSession.delete(project)
db.DBSession.flush()
... | python | def delete_project(project_id,**kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
db.DBSession.delete(project)
db.DBSession.flush()
... | [
"def",
"delete_project",
"(",
"project_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"#check_perm(user_id, 'delete_project')",
"project",
"=",
"_get_project",
"(",
"project_id",
")",
"project",
".",
"check_w... | Set the status of a project to 'X' | [
"Set",
"the",
"status",
"of",
"a",
"project",
"to",
"X"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L351-L362 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_networks | def get_networks(project_id, include_data='N', **kwargs):
"""
Get all networks in a project
Returns an array of network objects.
"""
log.info("Getting networks for project %s", project_id)
user_id = kwargs.get('user_id')
project = _get_project(project_id)
project.check_read_permi... | python | def get_networks(project_id, include_data='N', **kwargs):
"""
Get all networks in a project
Returns an array of network objects.
"""
log.info("Getting networks for project %s", project_id)
user_id = kwargs.get('user_id')
project = _get_project(project_id)
project.check_read_permi... | [
"def",
"get_networks",
"(",
"project_id",
",",
"include_data",
"=",
"'N'",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"Getting networks for project %s\"",
",",
"project_id",
")",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",... | Get all networks in a project
Returns an array of network objects. | [
"Get",
"all",
"networks",
"in",
"a",
"project",
"Returns",
"an",
"array",
"of",
"network",
"objects",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L364-L387 |
hydraplatform/hydra-base | hydra_base/lib/project.py | get_network_project | def get_network_project(network_id, **kwargs):
"""
get the project that a network is in
"""
net_proj = db.DBSession.query(Project).join(Network, and_(Project.id==Network.id, Network.id==network_id)).first()
if net_proj is None:
raise HydraError("Network %s not found"% network_id)
... | python | def get_network_project(network_id, **kwargs):
"""
get the project that a network is in
"""
net_proj = db.DBSession.query(Project).join(Network, and_(Project.id==Network.id, Network.id==network_id)).first()
if net_proj is None:
raise HydraError("Network %s not found"% network_id)
... | [
"def",
"get_network_project",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"net_proj",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Project",
")",
".",
"join",
"(",
"Network",
",",
"and_",
"(",
"Project",
".",
"id",
"==",
"Network",
".",
... | get the project that a network is in | [
"get",
"the",
"project",
"that",
"a",
"network",
"is",
"in"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/project.py#L389-L399 |
hydraplatform/hydra-base | hydra_base/util/hdb.py | add_resource_types | def add_resource_types(resource_i, types):
"""
Save a reference to the types used for this resource.
@returns a list of type_ids representing the type ids
on the resource.
"""
if types is None:
return []
existing_type_ids = []
if resource_i.types:
for t in resource_i.t... | python | def add_resource_types(resource_i, types):
"""
Save a reference to the types used for this resource.
@returns a list of type_ids representing the type ids
on the resource.
"""
if types is None:
return []
existing_type_ids = []
if resource_i.types:
for t in resource_i.t... | [
"def",
"add_resource_types",
"(",
"resource_i",
",",
"types",
")",
":",
"if",
"types",
"is",
"None",
":",
"return",
"[",
"]",
"existing_type_ids",
"=",
"[",
"]",
"if",
"resource_i",
".",
"types",
":",
"for",
"t",
"in",
"resource_i",
".",
"types",
":",
... | Save a reference to the types used for this resource.
@returns a list of type_ids representing the type ids
on the resource. | [
"Save",
"a",
"reference",
"to",
"the",
"types",
"used",
"for",
"this",
"resource",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/hdb.py#L37-L71 |
hydraplatform/hydra-base | hydra_base/util/hdb.py | create_default_users_and_perms | def create_default_users_and_perms():
"""
Adds the roles and perm to the DB. It adds only roles, perms and links between them that are not inside the db
It is possible adding new role or perm and connecting them just modifiying the following lists
"""
# perms = db.DBSession.query(Perm).all(... | python | def create_default_users_and_perms():
"""
Adds the roles and perm to the DB. It adds only roles, perms and links between them that are not inside the db
It is possible adding new role or perm and connecting them just modifiying the following lists
"""
# perms = db.DBSession.query(Perm).all(... | [
"def",
"create_default_users_and_perms",
"(",
")",
":",
"# perms = db.DBSession.query(Perm).all()",
"# if len(perms) > 0:",
"# return",
"default_perms",
"=",
"(",
"(",
"\"add_user\"",
",",
"\"Add User\"",
")",
",",
"(",
"\"edit_user\"",
",",
"\"Edit User\"",
")",
",",... | Adds the roles and perm to the DB. It adds only roles, perms and links between them that are not inside the db
It is possible adding new role or perm and connecting them just modifiying the following lists | [
"Adds",
"the",
"roles",
"and",
"perm",
"to",
"the",
"DB",
".",
"It",
"adds",
"only",
"roles",
"perms",
"and",
"links",
"between",
"them",
"that",
"are",
"not",
"inside",
"the",
"db",
"It",
"is",
"possible",
"adding",
"new",
"role",
"or",
"perm",
"and",... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/hdb.py#L169-L346 |
hydraplatform/hydra-base | hydra_base/util/hdb.py | create_default_units_and_dimensions | def create_default_units_and_dimensions():
"""
Adds the units and the dimensions reading a json file. It adds only dimensions and units that are not inside the db
It is possible adding new dimensions and units to the DB just modifiyin the json file
"""
default_units_file_location = os.path.r... | python | def create_default_units_and_dimensions():
"""
Adds the units and the dimensions reading a json file. It adds only dimensions and units that are not inside the db
It is possible adding new dimensions and units to the DB just modifiyin the json file
"""
default_units_file_location = os.path.r... | [
"def",
"create_default_units_and_dimensions",
"(",
")",
":",
"default_units_file_location",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
... | Adds the units and the dimensions reading a json file. It adds only dimensions and units that are not inside the db
It is possible adding new dimensions and units to the DB just modifiyin the json file | [
"Adds",
"the",
"units",
"and",
"the",
"dimensions",
"reading",
"a",
"json",
"file",
".",
"It",
"adds",
"only",
"dimensions",
"and",
"units",
"that",
"are",
"not",
"inside",
"the",
"db",
"It",
"is",
"possible",
"adding",
"new",
"dimensions",
"and",
"units",... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/hdb.py#L348-L416 |
hydraplatform/hydra-base | hydra_base/util/hdb.py | get_dimension_from_db_by_name | def get_dimension_from_db_by_name(dimension_name):
"""
Gets a dimension from the DB table.
"""
try:
dimension = db.DBSession.query(Dimension).filter(Dimension.name==dimension_name).one()
return JSONObject(dimension)
except NoResultFound:
raise ResourceNotFoundError("Dimen... | python | def get_dimension_from_db_by_name(dimension_name):
"""
Gets a dimension from the DB table.
"""
try:
dimension = db.DBSession.query(Dimension).filter(Dimension.name==dimension_name).one()
return JSONObject(dimension)
except NoResultFound:
raise ResourceNotFoundError("Dimen... | [
"def",
"get_dimension_from_db_by_name",
"(",
"dimension_name",
")",
":",
"try",
":",
"dimension",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Dimension",
")",
".",
"filter",
"(",
"Dimension",
".",
"name",
"==",
"dimension_name",
")",
".",
"one",
"(",
... | Gets a dimension from the DB table. | [
"Gets",
"a",
"dimension",
"from",
"the",
"DB",
"table",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/util/hdb.py#L425-L433 |
hydraplatform/hydra-base | hydra_base/lib/rules.py | get_rules | def get_rules(scenario_id, **kwargs):
"""
Get all the rules for a given scenario.
"""
rules = db.DBSession.query(Rule).filter(Rule.scenario_id==scenario_id, Rule.status=='A').all()
return rules | python | def get_rules(scenario_id, **kwargs):
"""
Get all the rules for a given scenario.
"""
rules = db.DBSession.query(Rule).filter(Rule.scenario_id==scenario_id, Rule.status=='A').all()
return rules | [
"def",
"get_rules",
"(",
"scenario_id",
",",
"*",
"*",
"kwargs",
")",
":",
"rules",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Rule",
")",
".",
"filter",
"(",
"Rule",
".",
"scenario_id",
"==",
"scenario_id",
",",
"Rule",
".",
"status",
"==",
"'... | Get all the rules for a given scenario. | [
"Get",
"all",
"the",
"rules",
"for",
"a",
"given",
"scenario",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/rules.py#L32-L38 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_attribute_by_id | def get_attribute_by_id(attr_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attr_i = db.DBSession.query(Attr).filter(Attr.id==attr_id).one()
return attr_i
except NoResultFound:
return None | python | def get_attribute_by_id(attr_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attr_i = db.DBSession.query(Attr).filter(Attr.id==attr_id).one()
return attr_i
except NoResultFound:
return None | [
"def",
"get_attribute_by_id",
"(",
"attr_id",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"attr_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"filter",
"(",
"Attr",
".",
"id",
"==",
"attr_id",
")",
".",
"one",
"(",
")",
... | Get a specific attribute by its ID. | [
"Get",
"a",
"specific",
"attribute",
"by",
"its",
"ID",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L84-L93 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_template_attributes | def get_template_attributes(template_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attrs_i = db.DBSession.query(Attr).filter(TemplateType.template_id==template_id).filter(TypeAttr.type_id==TemplateType.id).filter(Attr.id==TypeAttr.id).all()
log.debug(attrs_i)
... | python | def get_template_attributes(template_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attrs_i = db.DBSession.query(Attr).filter(TemplateType.template_id==template_id).filter(TypeAttr.type_id==TemplateType.id).filter(Attr.id==TypeAttr.id).all()
log.debug(attrs_i)
... | [
"def",
"get_template_attributes",
"(",
"template_id",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"attrs_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"filter",
"(",
"TemplateType",
".",
"template_id",
"==",
"template_id",
")",
... | Get a specific attribute by its ID. | [
"Get",
"a",
"specific",
"attribute",
"by",
"its",
"ID",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L95-L105 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_attribute_by_name_and_dimension | def get_attribute_by_name_and_dimension(name, dimension_id=None,**kwargs):
"""
Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory
"""
try:
attr_i = db.DBSession.query(Attr).filter(and_(Attr.name==name, Attr.d... | python | def get_attribute_by_name_and_dimension(name, dimension_id=None,**kwargs):
"""
Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory
"""
try:
attr_i = db.DBSession.query(Attr).filter(and_(Attr.name==name, Attr.d... | [
"def",
"get_attribute_by_name_and_dimension",
"(",
"name",
",",
"dimension_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"attr_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"filter",
"(",
"and_",
"(",
"Attr",
... | Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory | [
"Get",
"a",
"specific",
"attribute",
"by",
"its",
"name",
".",
"dimension_id",
"can",
"be",
"None",
"because",
"in",
"attribute",
"the",
"dimension_id",
"is",
"not",
"anymore",
"mandatory"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L108-L118 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | add_attribute | def add_attribute(attr,**kwargs):
"""
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
"""
log.debug("Addi... | python | def add_attribute(attr,**kwargs):
"""
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
"""
log.debug("Addi... | [
"def",
"add_attribute",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"\"Adding attribute: %s\"",
",",
"attr",
".",
"name",
")",
"try",
":",
"attr_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"filt... | Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
} | [
"Add",
"a",
"generic",
"attribute",
"which",
"can",
"then",
"be",
"used",
"in",
"creating",
"a",
"resource",
"attribute",
"and",
"put",
"into",
"a",
"type",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L120-L146 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | update_attribute | def update_attribute(attr,**kwargs):
"""
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
"""
log.debug("... | python | def update_attribute(attr,**kwargs):
"""
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
"""
log.debug("... | [
"def",
"update_attribute",
"(",
"attr",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"\"Updating attribute: %s\"",
",",
"attr",
".",
"name",
")",
"attr_i",
"=",
"_get_attr",
"(",
"attr",
".",
"id",
")",
"attr_i",
".",
"name",
"=",
"attr... | Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
} | [
"Add",
"a",
"generic",
"attribute",
"which",
"can",
"then",
"be",
"used",
"in",
"creating",
"a",
"resource",
"attribute",
"and",
"put",
"into",
"a",
"type",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L148-L173 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | add_attributes | def add_attributes(attrs,**kwargs):
"""
Add a list of generic attributes, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimen = "very big"
}
"""
#Ch... | python | def add_attributes(attrs,**kwargs):
"""
Add a list of generic attributes, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimen = "very big"
}
"""
#Ch... | [
"def",
"add_attributes",
"(",
"attrs",
",",
"*",
"*",
"kwargs",
")",
":",
"#Check to see if any of the attributs being added are already there.",
"#If they are there already, don't add a new one. If an attribute",
"#with the same name is there already but with a different dimension,",
"#ad... | Add a list of generic attributes, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimen = "very big"
} | [
"Add",
"a",
"list",
"of",
"generic",
"attributes",
"which",
"can",
"then",
"be",
"used",
"in",
"creating",
"a",
"resource",
"attribute",
"and",
"put",
"into",
"a",
"type",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L186-L238 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_attributes | def get_attributes(**kwargs):
"""
Get all attributes
"""
attrs = db.DBSession.query(Attr).order_by(Attr.name).all()
return attrs | python | def get_attributes(**kwargs):
"""
Get all attributes
"""
attrs = db.DBSession.query(Attr).order_by(Attr.name).all()
return attrs | [
"def",
"get_attributes",
"(",
"*",
"*",
"kwargs",
")",
":",
"attrs",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
"order_by",
"(",
"Attr",
".",
"name",
")",
".",
"all",
"(",
")",
"return",
"attrs"
] | Get all attributes | [
"Get",
"all",
"attributes"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L240-L247 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | update_resource_attribute | def update_resource_attribute(resource_attr_id, is_var, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == resource_attr_id).one()
except NoResultFound:
... | python | def update_resource_attribute(resource_attr_id, is_var, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == resource_attr_id).one()
except NoResultFound:
... | [
"def",
"update_resource_attribute",
"(",
"resource_attr_id",
",",
"is_var",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"ra",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
... | Deletes a resource attribute and all associated data. | [
"Deletes",
"a",
"resource",
"attribute",
"and",
"all",
"associated",
"data",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L263-L277 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | delete_resource_attribute | def delete_resource_attribute(resource_attr_id, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == resource_attr_id).one()
except NoResultFound:
raise Re... | python | def delete_resource_attribute(resource_attr_id, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == resource_attr_id).one()
except NoResultFound:
raise Re... | [
"def",
"delete_resource_attribute",
"(",
"resource_attr_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"ra",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
")",
".",
"filt... | Deletes a resource attribute and all associated data. | [
"Deletes",
"a",
"resource",
"attribute",
"and",
"all",
"associated",
"data",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L279-L292 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | add_resource_attribute | def add_resource_attribute(resource_type, resource_id, attr_id, is_var, error_on_duplicate=True, **kwargs):
"""
Add a resource attribute attribute to a resource.
attr_is_var indicates whether the attribute is a variable or not --
this is used in simulation to indicate that this value is exp... | python | def add_resource_attribute(resource_type, resource_id, attr_id, is_var, error_on_duplicate=True, **kwargs):
"""
Add a resource attribute attribute to a resource.
attr_is_var indicates whether the attribute is a variable or not --
this is used in simulation to indicate that this value is exp... | [
"def",
"add_resource_attribute",
"(",
"resource_type",
",",
"resource_id",
",",
"attr_id",
",",
"is_var",
",",
"error_on_duplicate",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"attr",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Attr",
")",
".",
... | Add a resource attribute attribute to a resource.
attr_is_var indicates whether the attribute is a variable or not --
this is used in simulation to indicate that this value is expected
to be filled in by the simulator. | [
"Add",
"a",
"resource",
"attribute",
"attribute",
"to",
"a",
"resource",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L295-L340 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | add_resource_attrs_from_type | def add_resource_attrs_from_type(type_id, resource_type, resource_id,**kwargs):
"""
adds all the attributes defined by a type to a node.
"""
type_i = _get_templatetype(type_id)
resource_i = _get_resource(resource_type, resource_id)
resourceattr_qry = db.DBSession.query(ResourceAttr).filter... | python | def add_resource_attrs_from_type(type_id, resource_type, resource_id,**kwargs):
"""
adds all the attributes defined by a type to a node.
"""
type_i = _get_templatetype(type_id)
resource_i = _get_resource(resource_type, resource_id)
resourceattr_qry = db.DBSession.query(ResourceAttr).filter... | [
"def",
"add_resource_attrs_from_type",
"(",
"type_id",
",",
"resource_type",
",",
"resource_id",
",",
"*",
"*",
"kwargs",
")",
":",
"type_i",
"=",
"_get_templatetype",
"(",
"type_id",
")",
"resource_i",
"=",
"_get_resource",
"(",
"resource_type",
",",
"resource_id... | adds all the attributes defined by a type to a node. | [
"adds",
"all",
"the",
"attributes",
"defined",
"by",
"a",
"type",
"to",
"a",
"node",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L342-L377 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_all_resource_attributes | def get_all_resource_attributes(ref_key, network_id, template_id=None, **kwargs):
"""
Get all the resource attributes for a given resource type in the network.
That includes all the resource attributes for a given type within the network.
For example, if the ref_key is 'NODE', then it will r... | python | def get_all_resource_attributes(ref_key, network_id, template_id=None, **kwargs):
"""
Get all the resource attributes for a given resource type in the network.
That includes all the resource attributes for a given type within the network.
For example, if the ref_key is 'NODE', then it will r... | [
"def",
"get_all_resource_attributes",
"(",
"ref_key",
",",
"network_id",
",",
"template_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"resource_attr_qry",
"=",
"db",
".",
"DBSession",
".",
... | Get all the resource attributes for a given resource type in the network.
That includes all the resource attributes for a given type within the network.
For example, if the ref_key is 'NODE', then it will return all the attirbutes
of all nodes in the network. This function allows a front end to ... | [
"Get",
"all",
"the",
"resource",
"attributes",
"for",
"a",
"given",
"resource",
"type",
"in",
"the",
"network",
".",
"That",
"includes",
"all",
"the",
"resource",
"attributes",
"for",
"a",
"given",
"type",
"within",
"the",
"network",
".",
"For",
"example",
... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L379-L423 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_resource_attributes | def get_resource_attributes(ref_key, ref_id, type_id=None, **kwargs):
"""
Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type.
"""
user_id = kwargs.get('user_id')
resource_attr_qry = db.DBSession.que... | python | def get_resource_attributes(ref_key, ref_id, type_id=None, **kwargs):
"""
Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type.
"""
user_id = kwargs.get('user_id')
resource_attr_qry = db.DBSession.que... | [
"def",
"get_resource_attributes",
"(",
"ref_key",
",",
"ref_id",
",",
"type_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"resource_attr_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
... | Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type. | [
"Get",
"all",
"the",
"resource",
"attributes",
"for",
"a",
"given",
"resource",
".",
"If",
"type_id",
"is",
"specified",
"only",
"return",
"the",
"resource",
"attributes",
"within",
"the",
"type",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L425-L453 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | check_attr_dimension | def check_attr_dimension(attr_id, **kwargs):
"""
Check that the dimension of the resource attribute data is consistent
with the definition of the attribute.
If the attribute says 'volume', make sure every dataset connected
with this attribute via a resource attribute also has a dimen... | python | def check_attr_dimension(attr_id, **kwargs):
"""
Check that the dimension of the resource attribute data is consistent
with the definition of the attribute.
If the attribute says 'volume', make sure every dataset connected
with this attribute via a resource attribute also has a dimen... | [
"def",
"check_attr_dimension",
"(",
"attr_id",
",",
"*",
"*",
"kwargs",
")",
":",
"attr_i",
"=",
"_get_attr",
"(",
"attr_id",
")",
"datasets",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"Dataset",
")",
".",
"filter",
"(",
"Dataset",
".",
"id",
"==... | Check that the dimension of the resource attribute data is consistent
with the definition of the attribute.
If the attribute says 'volume', make sure every dataset connected
with this attribute via a resource attribute also has a dimension
of 'volume'. | [
"Check",
"that",
"the",
"dimension",
"of",
"the",
"resource",
"attribute",
"data",
"is",
"consistent",
"with",
"the",
"definition",
"of",
"the",
"attribute",
".",
"If",
"the",
"attribute",
"says",
"volume",
"make",
"sure",
"every",
"dataset",
"connected",
"wit... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L455-L479 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_resource_attribute | def get_resource_attribute(resource_attr_id, **kwargs):
"""
Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type.
"""
resource_attr_qry = db.DBSession.query(ResourceAttr).filter(
ResourceAttr.id == resource_att... | python | def get_resource_attribute(resource_attr_id, **kwargs):
"""
Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type.
"""
resource_attr_qry = db.DBSession.query(ResourceAttr).filter(
ResourceAttr.id == resource_att... | [
"def",
"get_resource_attribute",
"(",
"resource_attr_id",
",",
"*",
"*",
"kwargs",
")",
":",
"resource_attr_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
")",
".",
"filter",
"(",
"ResourceAttr",
".",
"id",
"==",
"resource_attr_id",
",",... | Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type. | [
"Get",
"a",
"specific",
"resource",
"attribte",
"by",
"ID",
"If",
"type_id",
"is",
"Gspecified",
"only",
"return",
"the",
"resource",
"attributes",
"within",
"the",
"type",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L481-L497 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | set_attribute_mapping | def set_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = kwargs.get('user_id')
ra_1 = get_resource_attribute(resource_attr_a)
ra_2 = get_resource_attribute(r... | python | def set_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = kwargs.get('user_id')
ra_1 = get_resource_attribute(resource_attr_a)
ra_2 = get_resource_attribute(r... | [
"def",
"set_attribute_mapping",
"(",
"resource_attr_a",
",",
"resource_attr_b",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"ra_1",
"=",
"get_resource_attribute",
"(",
"resource_attr_a",
")",
"ra_2",
"=",
"ge... | Define one resource attribute from one network as being the same as
that from another network. | [
"Define",
"one",
"resource",
"attribute",
"from",
"one",
"network",
"as",
"being",
"the",
"same",
"as",
"that",
"from",
"another",
"network",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L499-L517 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | delete_attribute_mapping | def delete_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = kwargs.get('user_id')
rm = aliased(ResourceAttrMap, name='rm')
log.info("Trying to delete attri... | python | def delete_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = kwargs.get('user_id')
rm = aliased(ResourceAttrMap, name='rm')
log.info("Trying to delete attri... | [
"def",
"delete_attribute_mapping",
"(",
"resource_attr_a",
",",
"resource_attr_b",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"rm",
"=",
"aliased",
"(",
"ResourceAttrMap",
",",
"name",
"=",
"'rm'",
")",
... | Define one resource attribute from one network as being the same as
that from another network. | [
"Define",
"one",
"resource",
"attribute",
"from",
"one",
"network",
"as",
"being",
"the",
"same",
"as",
"that",
"from",
"another",
"network",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L519-L538 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | delete_mappings_in_network | def delete_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Delete all the resource attribute mappings in a network. If another network
is specified, only delete the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(or_(ResourceAttrMap.n... | python | def delete_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Delete all the resource attribute mappings in a network. If another network
is specified, only delete the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(or_(ResourceAttrMap.n... | [
"def",
"delete_mappings_in_network",
"(",
"network_id",
",",
"network_2_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"or_",
"(",
"ResourceAttrMap",
"... | Delete all the resource attribute mappings in a network. If another network
is specified, only delete the mappings between the two networks. | [
"Delete",
"all",
"the",
"resource",
"attribute",
"mappings",
"in",
"a",
"network",
".",
"If",
"another",
"network",
"is",
"specified",
"only",
"delete",
"the",
"mappings",
"between",
"the",
"two",
"networks",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L540-L556 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_mappings_in_network | def get_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(or_(ResourceAttrMap.network... | python | def get_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(or_(ResourceAttrMap.network... | [
"def",
"get_mappings_in_network",
"(",
"network_id",
",",
"network_2_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"or_",
"(",
"ResourceAttrMap",
".",... | Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks. | [
"Get",
"all",
"the",
"resource",
"attribute",
"mappings",
"in",
"a",
"network",
".",
"If",
"another",
"network",
"is",
"specified",
"only",
"return",
"the",
"mappings",
"between",
"the",
"two",
"networks",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L558-L568 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_node_mappings | def get_node_mappings(node_id, node_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(
or_(
and_(
... | python | def get_node_mappings(node_id, node_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(
or_(
and_(
... | [
"def",
"get_node_mappings",
"(",
"node_id",
",",
"node_2_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"or_",
"(",
"and_",
"(",
"ResourceAttrMap",
... | Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks. | [
"Get",
"all",
"the",
"resource",
"attribute",
"mappings",
"in",
"a",
"network",
".",
"If",
"another",
"network",
"is",
"specified",
"only",
"return",
"the",
"mappings",
"between",
"the",
"two",
"networks",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L570-L594 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_link_mappings | def get_link_mappings(link_id, link_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(
or_(
and_(
... | python | def get_link_mappings(link_id, link_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
"""
qry = db.DBSession.query(ResourceAttrMap).filter(
or_(
and_(
... | [
"def",
"get_link_mappings",
"(",
"link_id",
",",
"link_2_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"or_",
"(",
"and_",
"(",
"ResourceAttrMap",
... | Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks. | [
"Get",
"all",
"the",
"resource",
"attribute",
"mappings",
"in",
"a",
"network",
".",
"If",
"another",
"network",
"is",
"specified",
"only",
"return",
"the",
"mappings",
"between",
"the",
"two",
"networks",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L596-L620 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_network_mappings | def get_network_mappings(network_id, network_2_id=None, **kwargs):
"""
Get all the mappings of network resource attributes, NOT ALL THE MAPPINGS
WITHIN A NETWORK. For that, ``use get_mappings_in_network``. If another network
is specified, only return the mappings between the two networks.
... | python | def get_network_mappings(network_id, network_2_id=None, **kwargs):
"""
Get all the mappings of network resource attributes, NOT ALL THE MAPPINGS
WITHIN A NETWORK. For that, ``use get_mappings_in_network``. If another network
is specified, only return the mappings between the two networks.
... | [
"def",
"get_network_mappings",
"(",
"network_id",
",",
"network_2_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"or_",
"(",
"and_",
"(",
"ResourceAt... | Get all the mappings of network resource attributes, NOT ALL THE MAPPINGS
WITHIN A NETWORK. For that, ``use get_mappings_in_network``. If another network
is specified, only return the mappings between the two networks. | [
"Get",
"all",
"the",
"mappings",
"of",
"network",
"resource",
"attributes",
"NOT",
"ALL",
"THE",
"MAPPINGS",
"WITHIN",
"A",
"NETWORK",
".",
"For",
"that",
"use",
"get_mappings_in_network",
".",
"If",
"another",
"network",
"is",
"specified",
"only",
"return",
"... | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L623-L648 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | check_attribute_mapping_exists | def check_attribute_mapping_exists(resource_attr_id_source, resource_attr_id_target, **kwargs):
"""
Check whether an attribute mapping exists between a source and target resource attribute.
returns 'Y' if a mapping exists. Returns 'N' in all other cases.
"""
qry = db.DBSession.query(Resource... | python | def check_attribute_mapping_exists(resource_attr_id_source, resource_attr_id_target, **kwargs):
"""
Check whether an attribute mapping exists between a source and target resource attribute.
returns 'Y' if a mapping exists. Returns 'N' in all other cases.
"""
qry = db.DBSession.query(Resource... | [
"def",
"check_attribute_mapping_exists",
"(",
"resource_attr_id_source",
",",
"resource_attr_id_target",
",",
"*",
"*",
"kwargs",
")",
":",
"qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttrMap",
")",
".",
"filter",
"(",
"ResourceAttrMap",
".",
... | Check whether an attribute mapping exists between a source and target resource attribute.
returns 'Y' if a mapping exists. Returns 'N' in all other cases. | [
"Check",
"whether",
"an",
"attribute",
"mapping",
"exists",
"between",
"a",
"source",
"and",
"target",
"resource",
"attribute",
".",
"returns",
"Y",
"if",
"a",
"mapping",
"exists",
".",
"Returns",
"N",
"in",
"all",
"other",
"cases",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L650-L662 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_attribute_group | def get_attribute_group(group_id, **kwargs):
"""
Get a specific attribute group
"""
user_id=kwargs.get('user_id')
try:
group_i = db.DBSession.query(AttrGroup).filter(
AttrGroup.id==group_id).one()
group_i.project.check_read_permission... | python | def get_attribute_group(group_id, **kwargs):
"""
Get a specific attribute group
"""
user_id=kwargs.get('user_id')
try:
group_i = db.DBSession.query(AttrGroup).filter(
AttrGroup.id==group_id).one()
group_i.project.check_read_permission... | [
"def",
"get_attribute_group",
"(",
"group_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"try",
":",
"group_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"AttrGroup",
")",
".",
"filter",
"(",
... | Get a specific attribute group | [
"Get",
"a",
"specific",
"attribute",
"group"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L665-L679 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | add_attribute_group | def add_attribute_group(attributegroup, **kwargs):
"""
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
... | python | def add_attribute_group(attributegroup, **kwargs):
"""
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
... | [
"def",
"add_attribute_group",
"(",
"attributegroup",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"attributegroup.project_id %s\"",
",",
"attributegroup",
".",
"project_id",
")",
"# It is None while it should be valued",
"user_id",
"=",
"kwargs",
".",... | Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
an attribute group looks like:
{
'proje... | [
"Add",
"a",
"new",
"attribute",
"group",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L682-L724 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | update_attribute_group | def update_attribute_group(attributegroup, **kwargs):
"""
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
... | python | def update_attribute_group(attributegroup, **kwargs):
"""
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
... | [
"def",
"update_attribute_group",
"(",
"attributegroup",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"if",
"attributegroup",
".",
"id",
"is",
"None",
":",
"raise",
"HydraError",
"(",
"\"cannot update attribute... | Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
an attribute group looks like:
{
'proje... | [
"Add",
"a",
"new",
"attribute",
"group",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L726-L766 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | delete_attribute_group | def delete_attribute_group(group_id, **kwargs):
"""
Delete an attribute group.
"""
user_id = kwargs['user_id']
try:
group_i = db.DBSession.query(AttrGroup).filter(AttrGroup.id==group_id).one()
group_i.project.check_write_permission(user_id)
db.DBSession.delete(group_i... | python | def delete_attribute_group(group_id, **kwargs):
"""
Delete an attribute group.
"""
user_id = kwargs['user_id']
try:
group_i = db.DBSession.query(AttrGroup).filter(AttrGroup.id==group_id).one()
group_i.project.check_write_permission(user_id)
db.DBSession.delete(group_i... | [
"def",
"delete_attribute_group",
"(",
"group_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
"[",
"'user_id'",
"]",
"try",
":",
"group_i",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"AttrGroup",
")",
".",
"filter",
"(",
"AttrGroup"... | Delete an attribute group. | [
"Delete",
"an",
"attribute",
"group",
"."
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L768-L789 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_network_attributegroup_items | def get_network_attributegroup_items(network_id, **kwargs):
"""
Get all the group items in a network
"""
user_id=kwargs.get('user_id')
net_i = _get_network(network_id)
net_i.check_read_permission(user_id)
group_items_i = db.DBSession.query(AttrGroupItem).filter(
... | python | def get_network_attributegroup_items(network_id, **kwargs):
"""
Get all the group items in a network
"""
user_id=kwargs.get('user_id')
net_i = _get_network(network_id)
net_i.check_read_permission(user_id)
group_items_i = db.DBSession.query(AttrGroupItem).filter(
... | [
"def",
"get_network_attributegroup_items",
"(",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"net_i",
"=",
"_get_network",
"(",
"network_id",
")",
"net_i",
".",
"check_read_permission",
"(",
"use... | Get all the group items in a network | [
"Get",
"all",
"the",
"group",
"items",
"in",
"a",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L791-L806 |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | get_group_attributegroup_items | def get_group_attributegroup_items(network_id, group_id, **kwargs):
"""
Get all the items in a specified group, within a network
"""
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_group_attributegroup_items(network_id, group_id, **kwargs):
"""
Get all the items in a specified group, within a network
"""
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_group_attributegroup_items",
"(",
"network_id",
",",
"group_id",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"network_i",
"=",
"_get_network",
"(",
"network_id",
")",
"network_i",
".",
"check_read... | Get all the items in a specified group, within a network | [
"Get",
"all",
"the",
"items",
"in",
"a",
"specified",
"group",
"within",
"a",
"network"
] | train | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L808-L822 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.