query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
__member_ordinals__ reflects ordinal lookup | def test_member_ordinals():
yield (tools.eq_,
BlogPostStatus.__member_ordinals__,
{'draft': 0, 'published': 1, 'archived': 2})
for element in BlogPostStatus.__member_ordinals__:
yield (tools.assert_is_instance, element, BlogPostStatus) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordinal(self):\n return self._ordinals",
"def toordinal(self, *args, **kwargs): # real signature unknown\r\n pass",
"def getOrdinal(self):\n hint = self['Ordinal Number']\n return (hint, 'Ordinal%d'% hint) # microsoft-convention",
"def test_inheritance_ordinals():\n # Subc... | [
"0.7271314",
"0.6435264",
"0.6100394",
"0.60346293",
"0.59317726",
"0.5743826",
"0.5736204",
"0.5736204",
"0.5727123",
"0.57096446",
"0.5602847",
"0.55285996",
"0.55253315",
"0.55253315",
"0.55080736",
"0.5360293",
"0.5338237",
"0.53306854",
"0.5175937",
"0.51702523",
"0.5142... | 0.69002086 | 1 |
next returns the following enum member | def test_next():
members = tuple(BlogPostStatus)
for (number, member) in enumerate(members[:-1], 1):
yield (tools.eq_, member.next, members[number])
yield (tools.assert_is_none, members[-1].next) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __next__(self):\n return self.next()",
"def __next__(self):\n return self.next()",
"def __next__(self):\n return self.next()",
"def next():",
"def next():",
"def __next__(self):\n\t\treturn next()",
"def next(self):\n return type(self).__next__(self)",
"def next(se... | [
"0.6808574",
"0.6808574",
"0.6808574",
"0.66670024",
"0.66670024",
"0.6666213",
"0.64870065",
"0.6471161",
"0.647044",
"0.64554185",
"0.64554185",
"0.64554185",
"0.64554185",
"0.6440213",
"0.64380914",
"0.6434304",
"0.6426825",
"0.6380982",
"0.6380982",
"0.6380982",
"0.638098... | 0.7005289 | 0 |
Enums are free to define lookup aliases without affecting ordinals | def test_enum_aliases():
class RedundantStatus(OrderedStrEnum):
draft = 'draft'
unpublished = 'draft'
published = 'published'
archived = 'archived'
__order__ = 'draft, unpublished, published, archived'
yield (tools.eq_, RedundantStatus.draft.ordinal, RedundantStatus.un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enum(**enums):\n reverse = dict((value, key) for key, value in iteritems(enums))\n enums['reverse_mapping'] = reverse\n return type('Enum', (), enums)",
"def def_enum(dct, name):\n return type(name, (Enum,), dct)",
"def enum(*sequential, **named):\n enums = dict(zip(sequential, range(len... | [
"0.6203421",
"0.60342056",
"0.5994104",
"0.59861314",
"0.5675047",
"0.5674497",
"0.5598634",
"0.5574608",
"0.55520844",
"0.55295527",
"0.55142015",
"0.54847926",
"0.54748595",
"0.54748595",
"0.54748595",
"0.54748595",
"0.5431163",
"0.5431163",
"0.54305714",
"0.54216623",
"0.5... | 0.65101475 | 0 |
Sets the last_executed of this WorkflowExecutionStatisticReport. | def last_executed(self, last_executed):
self._last_executed = last_executed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_updated(self, last_updated):\n\n self._last_updated = last_updated",
"def last_updated(self, last_updated):\n\n self._last_updated = last_updated",
"def last_updated(self, last_updated):\n\n self._last_updated = last_updated",
"def last_updated(self, last_updated):\n\n se... | [
"0.5983626",
"0.5983626",
"0.5983626",
"0.5983626",
"0.59450394",
"0.5855105",
"0.5755604",
"0.56860083",
"0.5578798",
"0.55777425",
"0.5558356",
"0.5523428",
"0.5496051",
"0.5484417",
"0.54533756",
"0.54533756",
"0.54142714",
"0.53915215",
"0.5369135",
"0.5348507",
"0.532085... | 0.8134434 | 0 |
Sets the failed of this WorkflowExecutionStatisticReport. | def failed(self, failed):
self._failed = failed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_test_failed(self):\n self.set_result(Status.FAILED)",
"def failed(self):\n output = self.__call__()\n return output.failed",
"def set_failed(self, exception):\n self.logger.info(\"status: FAILED\")\n self._callback('on_failed', exception)\n return self.update_r... | [
"0.71660244",
"0.6612995",
"0.6606375",
"0.6396377",
"0.63795894",
"0.6259075",
"0.6240197",
"0.6143424",
"0.6119114",
"0.6118082",
"0.605444",
"0.605444",
"0.6034703",
"0.6011051",
"0.5917028",
"0.59084046",
"0.5890428",
"0.58812815",
"0.5794807",
"0.5791306",
"0.57878953",
... | 0.7499917 | 1 |
Collects all products in catalogue as items in the data list and then prints them using tabulate | def show_all_products():
data = cur.execute("""SELECT productid, productname, unitcost, stock FROM catalogue""").fetchall()
print(tabulate(data, headers=["Product ID", "Name", "Cost", "Stock"])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_catalogue(self):\n\n data = cur.execute(\"\"\"SELECT productid, productname, unitcost, stock, location \n FROM catalogue WHERE vendorname = ?\"\"\", (self.vendorname,)).fetchall()\n print(tabulate(data, headers=[\"Product ID\", \"Name\", \"Unit Cost\", \"Stock\... | [
"0.69635266",
"0.65769345",
"0.65536064",
"0.6303999",
"0.61612076",
"0.6101772",
"0.6083178",
"0.6081311",
"0.6048891",
"0.601895",
"0.59888464",
"0.59713143",
"0.59652126",
"0.59339434",
"0.591657",
"0.58679086",
"0.5850156",
"0.58045226",
"0.57906497",
"0.5789158",
"0.5773... | 0.7582993 | 0 |
Collects all products with name that match the search term as items in data list, then prints them using tabulate. | def search_catalogue(search_term):
data = cur.execute("""SELECT productid, productname, unitcost, stock FROM catalogue WHERE productname = ?""",
(search_term, )).fetchall()
print(tabulate(data, headers=["Product ID", "Name", "Cost", "Stock"])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_product(self):\n cat = []\n product = open_products()\n radio = self.radiobutton_check()\n search = self.lineEdit_search.text()\n _translate = QtCore.QCoreApplication.translate\n __sortingEnabled = self.tableWidget.isSortingEnabled()\n self.tableWidget.se... | [
"0.6624192",
"0.6382159",
"0.62515086",
"0.62011975",
"0.6075247",
"0.6001596",
"0.592976",
"0.5885058",
"0.5860876",
"0.5841331",
"0.5827597",
"0.58263576",
"0.5795338",
"0.57659525",
"0.5741616",
"0.5719327",
"0.5712938",
"0.5685778",
"0.5684683",
"0.56811684",
"0.56586045"... | 0.7228379 | 0 |
Return whether the value of this value tracker evaluates as true. | def __bool__(self):
return bool(self.get_value()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __bool__(self):\n return bool(self._value)",
"def is_true(value):\n \n return (value is True)",
"def __bool__(self) -> bool:\n\n nonzeroes = np.absolute(self.value) > _eps\n\n if nonzeroes.any():\n return True\n else:\n return False",
"def __bool__(... | [
"0.78621286",
"0.74152863",
"0.7303703",
"0.6971203",
"0.6906327",
"0.68923014",
"0.6872506",
"0.685994",
"0.67889863",
"0.674437",
"0.6665957",
"0.66386956",
"0.66019756",
"0.6597526",
"0.6555683",
"0.6555683",
"0.6549986",
"0.65490645",
"0.64746803",
"0.64746803",
"0.647328... | 0.7650049 | 1 |
Set the value of this value tracker to the floor division of the current value by ``d_value``. | def __ifloordiv__(self, d_value: float):
self.set_value(self.get_value() // d_value)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __imod__(self, d_value: float):\n self.set_value(self.get_value() % d_value)\n return self",
"def __itruediv__(self, d_value: float):\n self.set_value(self.get_value() / d_value)\n return self",
"def increment_value(self, d_value: float):\n self.set_value(self.get_value()... | [
"0.69387853",
"0.68022716",
"0.65712684",
"0.6133387",
"0.60288185",
"0.58072555",
"0.577952",
"0.5767218",
"0.57614446",
"0.57614446",
"0.56966454",
"0.56944656",
"0.5654499",
"0.5637143",
"0.56271964",
"0.5625746",
"0.55546635",
"0.5553291",
"0.5553291",
"0.5546953",
"0.554... | 0.75101304 | 0 |
Set the value of this value tracker to the current value modulo ``d_value``. | def __imod__(self, d_value: float):
self.set_value(self.get_value() % d_value)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_value(self, d_value: float):\n self.set_value(self.get_value() + d_value)\n return self",
"def update( self, dval ):\n self.val[:] += dval[:]\n return",
"def __itruediv__(self, d_value: float):\n self.set_value(self.get_value() / d_value)\n return self",
... | [
"0.6974386",
"0.6383232",
"0.62796813",
"0.62210476",
"0.61323863",
"0.5939189",
"0.5939189",
"0.5923567",
"0.58471316",
"0.5816539",
"0.5800461",
"0.5800116",
"0.5767023",
"0.57560366",
"0.5723446",
"0.5695607",
"0.56850725",
"0.5669766",
"0.564745",
"0.564745",
"0.5641324",... | 0.82289565 | 0 |
Set the value of this value tracker to the current value raised to the power of ``d_value``. | def __ipow__(self, d_value: float):
self.set_value(self.get_value() ** d_value)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_value(self, d_value: float):\n self.set_value(self.get_value() + d_value)\n return self",
"def power(self, value: int):\n self._power = value",
"def position_d_gain(self, value):\n self._write(MX_POSITION_D_GAIN, value)",
"def __imod__(self, d_value: float):\n ... | [
"0.6994471",
"0.6503605",
"0.6233567",
"0.6164042",
"0.6153874",
"0.6065865",
"0.59215724",
"0.5909356",
"0.5909356",
"0.5867096",
"0.5865763",
"0.5852381",
"0.5849424",
"0.5788131",
"0.56891364",
"0.56591105",
"0.56591105",
"0.5625114",
"0.55733997",
"0.5561557",
"0.55568665... | 0.6994912 | 0 |
Sets the value of this value tracker to the current value divided by ``d_value``. | def __itruediv__(self, d_value: float):
self.set_value(self.get_value() / d_value)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __imod__(self, d_value: float):\n self.set_value(self.get_value() % d_value)\n return self",
"def increment_value(self, d_value: float):\n self.set_value(self.get_value() + d_value)\n return self",
"def __ifloordiv__(self, d_value: float):\n self.set_value(self.get_value(... | [
"0.71095574",
"0.6847036",
"0.67902476",
"0.6253411",
"0.612804",
"0.6105571",
"0.61030036",
"0.61028653",
"0.6070293",
"0.6070293",
"0.60655737",
"0.5993464",
"0.5960814",
"0.5957619",
"0.5957619",
"0.5911276",
"0.5884761",
"0.5870716",
"0.5858601",
"0.5856141",
"0.5849313",... | 0.7247975 | 0 |
Turns self into an interpolation between mobject1 and mobject2. | def interpolate(self, mobject1, mobject2, alpha, path_func=straight_path()):
self.set_points(path_func(mobject1.points, mobject2.points, alpha))
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolated(self, Any, Any_1, p_float): # real signature unknown; restored from __doc__\n pass",
"def interpolate_setpoints(base_setpoint, other_setpoint, parameter):\n time = parameter * base_setpoint.time + (1 - parameter) * other_setpoint.time\n position = parameter * base_setpoint.p... | [
"0.5637158",
"0.56121135",
"0.55211383",
"0.54388994",
"0.5420061",
"0.5412576",
"0.5393414",
"0.5391021",
"0.53756833",
"0.5330356",
"0.5275087",
"0.5265244",
"0.5210796",
"0.52021253",
"0.5196188",
"0.5194092",
"0.51779884",
"0.51377857",
"0.5119724",
"0.511718",
"0.5115093... | 0.7194471 | 0 |
Get the current value of this value tracker as a complex number. The value is internally stored as a points array [a, b, 0]. This can be accessed directly to represent the value geometrically, see the usage example. | def get_value(self):
return complex(*self.points[0, :2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complex_value(self) -> global___Expression.ComplexValue:",
"def __complex__(self):\n return complex(self.q[0], self.q[1])",
"def __complex__(self) -> complex:\n return self._translate_in_type(complex, self.integer, self.float_num)",
"def to_float_complex(self):\r\n return eval(str(se... | [
"0.77918947",
"0.7129402",
"0.6880464",
"0.67992586",
"0.6789384",
"0.6770688",
"0.6641613",
"0.6238777",
"0.61929226",
"0.6183072",
"0.61674166",
"0.6130009",
"0.610403",
"0.60831475",
"0.59552103",
"0.57989806",
"0.5794303",
"0.5755895",
"0.5750102",
"0.5727452",
"0.5707540... | 0.8395976 | 0 |
Sets a new complex value to the ComplexValueTracker | def set_value(self, z):
z = complex(z)
self.points[0, :2] = (z.real, z.imag)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complex_value(self) -> global___Expression.ComplexValue:",
"def set_antecedent(self, complex_antecedent):\n self.complex_antecedent = complex_antecedent",
"def fill(self, value: complex) -> None:\n self.coeff.fill(value)",
"def test_op_fill_complex(self):\n\n device = pymic.devices[0... | [
"0.60866123",
"0.6015263",
"0.56112033",
"0.5476745",
"0.53537047",
"0.53005815",
"0.5210709",
"0.5188414",
"0.5162805",
"0.5132051",
"0.5130909",
"0.5122889",
"0.51014954",
"0.5096021",
"0.5091293",
"0.5080647",
"0.50669086",
"0.5060398",
"0.50584745",
"0.5054229",
"0.501476... | 0.6494745 | 0 |
Add a single NF node to the NFFG. | def add_nf (self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_add_node(self, line=''):\n self.fibbing.add_node()",
"def add_node_field(self,name,data,on_exists='fail'):\n if name in np.dtype(self.node_dtype).names:\n if on_exists == 'fail':\n raise GridException(\"Node field %s already exists\"%name)\n elif on_exist... | [
"0.64854616",
"0.64695007",
"0.64363354",
"0.63351053",
"0.6084574",
"0.6078953",
"0.5977999",
"0.5908975",
"0.5886608",
"0.5883126",
"0.5881237",
"0.584639",
"0.58098894",
"0.5794461",
"0.5787169",
"0.57756376",
"0.573636",
"0.573636",
"0.57199055",
"0.5696408",
"0.5689903",... | 0.6807476 | 0 |
Add a single SAP node to the NFFG. | def add_sap (self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_sap (self, sap_obj=None, id=None, name=None, binding=None, sap=None,\n technology=None, delay=None, bandwidth=None, cost=None,\n controller=None, orchestrator=None, l2=None, l4=None,\n metadata=None):\n if sap_obj is None:\n sap_obj = NodeSAP(id=id, name=na... | [
"0.740126",
"0.63043034",
"0.61606264",
"0.60282236",
"0.5997619",
"0.59379315",
"0.5924839",
"0.59226537",
"0.58989286",
"0.5832174",
"0.58309996",
"0.5828573",
"0.5828573",
"0.5823414",
"0.581727",
"0.5807381",
"0.5758947",
"0.57376915",
"0.57246983",
"0.5723331",
"0.571309... | 0.6567397 | 1 |
Add a single infrastructure node to the NFFG. | def add_infra (self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node (self, node):\n raise NotImplementedError",
"def add_node (self, node):\n self.network.add_node(node.id)\n self.network.node[node.id] = node",
"def add_node(self, node):",
"def add_node(self, node):\n self.nodes.append(node)",
"def add_node(self, node):\n self.nodes.add(... | [
"0.66082346",
"0.6431363",
"0.63603705",
"0.63308394",
"0.63138115",
"0.6310152",
"0.6203879",
"0.6186647",
"0.6186647",
"0.6186028",
"0.6146868",
"0.6103",
"0.61014926",
"0.6084863",
"0.6077213",
"0.6047773",
"0.60177296",
"0.6007605",
"0.6003408",
"0.5934797",
"0.5932385",
... | 0.6502441 | 1 |
Add an SG link to the NFFG. | def add_sglink (self, src, dst):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_sglink (self, src_port, dst_port, hop=None, id=None, flowclass=None,\n tag_info=None, delay=None, bandwidth=None):\n if hop is None:\n hop = EdgeSGLink(src=src_port, dst=dst_port, id=id, flowclass=flowclass,\n tag_info=tag_info, bandwidth=bandwidth, delay=dela... | [
"0.69035697",
"0.6829564",
"0.65847814",
"0.6293755",
"0.6279665",
"0.61193115",
"0.60831815",
"0.60012156",
"0.5972088",
"0.5913553",
"0.5906214",
"0.58134747",
"0.58134747",
"0.58134747",
"0.58134747",
"0.58134747",
"0.58134747",
"0.58134747",
"0.57928044",
"0.5747562",
"0.... | 0.7715433 | 0 |
Add a SG next hop edge to the structure. | def add_sglink (self, src_port, dst_port, hop=None, id=None, flowclass=None,
tag_info=None, delay=None, bandwidth=None):
if hop is None:
hop = EdgeSGLink(src=src_port, dst=dst_port, id=id, flowclass=flowclass,
tag_info=tag_info, bandwidth=bandwidth, delay=delay)
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, s, e):\n self.graph[s].append(e)",
"def add_edge (self, src, dst, link):\n raise NotImplementedError",
"def add_edge(self, edge):\n src = edge.get_source()\n dest = edge.get_destination()\n #weightEdge = WeightedEdge(src, dest, edge.get_total_distance(), edge.g... | [
"0.6597976",
"0.64962125",
"0.639478",
"0.63723767",
"0.62884015",
"0.60910493",
"0.60387135",
"0.6010863",
"0.58828616",
"0.5856282",
"0.58502895",
"0.58032566",
"0.57992053",
"0.578013",
"0.5772589",
"0.57614195",
"0.57073647",
"0.5705662",
"0.5695479",
"0.5695238",
"0.5641... | 0.7028286 | 0 |
Add metadata with the given `name`. | def add_metadata (self, name, value):
self.metadata[name] = value
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_metadata(self, name, val: str = None):\n if isinstance(name, Metadata):\n self._metadata.append(name)\n if isinstance(name, str):\n self._metadata.append(Metadata(name, val))\n if isinstance(name, dict):\n for name, value in name.items():\n ... | [
"0.7946815",
"0.72172326",
"0.7015767",
"0.6782553",
"0.6773775",
"0.67626476",
"0.649861",
"0.6457686",
"0.6445789",
"0.64201254",
"0.6380916",
"0.6224936",
"0.6183738",
"0.6164278",
"0.6135796",
"0.6135796",
"0.61084515",
"0.6075935",
"0.60616446",
"0.606114",
"0.6057372",
... | 0.82813424 | 0 |
Convert the NFFG structure to a NFFGModel format and return the plain text representation. | def dump (self):
# Create the model
nffg = NFFGModel(id=self.id, name=self.name, service_id=self.service_id,
version=self.version, mode=self.mode,
metadata=self.metadata)
# Load Infras
for infra in self.infras:
nffg.node_infras.append(infra)
# Load SAP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__ (self):\n return \"NFFG(id=%s name=%s, version=%s)\" % (\n self.id, self.name, self.version)",
"def parse (cls, raw_data):\n # Parse text\n model = NFFGModel.parse(raw_data)\n # Create new NFFG\n nffg = NFFG(id=model.id, name=model.name, service_id=model.service_id,\n ... | [
"0.55937463",
"0.55243444",
"0.54208857",
"0.5300594",
"0.52428144",
"0.52225006",
"0.52089894",
"0.5205388",
"0.5196772",
"0.5178014",
"0.51759773",
"0.51552975",
"0.5142514",
"0.5139313",
"0.51335967",
"0.51180154",
"0.5085834",
"0.5083426",
"0.5054441",
"0.50415677",
"0.50... | 0.58666736 | 0 |
Parse NFFG from file given by the path. | def parse_from_file (path):
with open(path) as f:
return NFFG.parse(f.read()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(path, n_channels):\n # TODO: infer the number of channels by the number of lines\n extension = path.split('.')[-1]\n\n if extension == 'txt':\n geom = _parse_txt(path, n_channels)\n elif extension == 'npy':\n geom = np.load(path)\n else:\n raise ValueError('Invalid fil... | [
"0.63917583",
"0.63917583",
"0.6377528",
"0.6370021",
"0.62458134",
"0.62072283",
"0.6089861",
"0.60844254",
"0.6023072",
"0.5898325",
"0.5893773",
"0.5804288",
"0.5796841",
"0.5715716",
"0.56956524",
"0.5677724",
"0.56727785",
"0.558817",
"0.5586826",
"0.55694413",
"0.556081... | 0.8716653 | 0 |
Return True if the NFFG is an infrastructure view with Infrastructure nodes. | def is_infrastructure (self):
return sum([1 for i in self.infras]) != 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_w5_infrastructure(self, subj: URIRef) -> bool:\n return subj in w5_infrastructure_categories or \\\n bool(set(self.graph.transitive_objects(subj, RDFS.subClassOf)).intersection(w5_infrastructure_categories))",
"def check_infrastructure(infrastructure, data):\n if infrastructure == 'wa... | [
"0.6539021",
"0.65380067",
"0.61785614",
"0.5650283",
"0.55871004",
"0.5580826",
"0.5513682",
"0.55113745",
"0.5456774",
"0.5449252",
"0.5418488",
"0.53829515",
"0.5347815",
"0.52714795",
"0.5265002",
"0.5257124",
"0.5254371",
"0.5245468",
"0.52417386",
"0.5221561",
"0.521703... | 0.65583783 | 0 |
Return True if the topology does not contain any NF or flowrules need to install or remap. | def is_bare (self):
# If there is no VNF
if len([v for v in self.nfs]) == 0:
fr_sum = sum([sum(1 for fr in i.ports.flowrules) for i in self.infras])
# And there is no flowrule in the ports
if fr_sum == 0:
sg_sum = len([sg for sg in self.sg_hops])
# And there is not SG hop
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_remap(self):\n return self.mapping1 is not None or self.mapping2 is not None",
"def check_topology(self, ninputs: \"int\", noutputs: \"int\") -> \"bool\":\n return _beamforming_swig.beamformer_sptr_check_topology(self, ninputs, noutputs)",
"def check_nodes(self) -> bool:\n # check ... | [
"0.60574776",
"0.598162",
"0.5918374",
"0.5905532",
"0.5818316",
"0.58074284",
"0.5774021",
"0.57633144",
"0.5722792",
"0.5719835",
"0.5710215",
"0.5689669",
"0.5687855",
"0.56869996",
"0.56773084",
"0.56760776",
"0.5673487",
"0.5671983",
"0.56698",
"0.5642993",
"0.5639439",
... | 0.631738 | 0 |
Return True if the topology contains at least one virtualized BiSBiS node. | def is_virtualized (self):
return len([i for i in self.infras if
i.infra_type not in (self.TYPE_INFRA_SDN_SW, self.TYPE_INFRA_EE,
self.TYPE_INFRA_STATIC_EE)]) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_simple(self):\n if not self.is_compact(): return False\n\n for v in self.vertex_generator():\n adj = [a for a in v.neighbors()]\n if len(adj) != self.dim():\n return False\n\n return True",
"def is_empty(self):\n return len(self.__nodes) == ... | [
"0.6359739",
"0.6328011",
"0.62154627",
"0.6125948",
"0.6109798",
"0.60948336",
"0.6050756",
"0.60355914",
"0.5943596",
"0.59430504",
"0.5938376",
"0.5894489",
"0.58836687",
"0.58680516",
"0.5837452",
"0.580779",
"0.5789113",
"0.5785227",
"0.5779352",
"0.57781434",
"0.5772642... | 0.6560199 | 0 |
Return with an iterator over the out edge data of the given Node not counting the SG and E2E requirement links. | def real_out_edges_iter (self, node):
return (data for data in self.network.out_edges_iter(node, data=True)
if data[2].type in (self.TYPE_LINK_STATIC, self.TYPE_LINK_DYNAMIC)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOutEdges(self):\n edges = []\n for edict in mm.G[self].values():\n for k in edict.keys():\n edges.append(edict.get(k).get(\"edge\"))\n \n return edges",
"def get_exiting_edges(self,node):\n exit_edge_pattern=re.compile('edge_{0}_(?P<end_node>\\w... | [
"0.6725397",
"0.65968525",
"0.6412617",
"0.6262366",
"0.6239152",
"0.6162448",
"0.609624",
"0.6082465",
"0.6073894",
"0.6064645",
"0.6028592",
"0.597637",
"0.59500694",
"0.5948367",
"0.5874288",
"0.58547795",
"0.58342546",
"0.5785526",
"0.5784581",
"0.5773501",
"0.5766765",
... | 0.72563714 | 0 |
Extend the NFFG model with backward links for STATIC links to fit for the orchestration algorithm. | def duplicate_static_links (self):
# Create backward links
backwards = [EdgeLink(src=link.dst, dst=link.src, id=str(link.id) + "-back",
backward=True, delay=link.delay,
bandwidth=link.bandwidth) for u, v, link in
self.network.edges_iter(data=T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def defreeze_model(self):\n # defreeze all parameters\n for param in self.parameters():\n param.requires_grad = True\n # make the whole network trainable\n self.train()",
"def backward_G(self):\n # Calculate regularzation loss to make transformed feature and target i... | [
"0.60501057",
"0.5749679",
"0.5731722",
"0.56426895",
"0.5640265",
"0.560745",
"0.5574974",
"0.554553",
"0.5511958",
"0.5509033",
"0.55079335",
"0.54605407",
"0.54233426",
"0.54182506",
"0.54031235",
"0.5384128",
"0.5383527",
"0.53647226",
"0.5349116",
"0.5346506",
"0.5337936... | 0.58788097 | 1 |
Detect duplicated STATIC links which both are connected to the same Port/Node and have switched source/destination direction to fit for the simplified NFFG dumping. Only leaves one of the links, but that's not defined which one. | def merge_duplicated_links (self):
# Collect backward links
backwards = [(src, dst, key) for src, dst, key, link in
self.network.edges_iter(keys=True, data=True) if (
link.type == Link.STATIC or link.type == Link.DYNAMIC) and
link.backward is True]
# Dele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_static_links (self):\n # Create backward links\n backwards = [EdgeLink(src=link.dst, dst=link.src, id=str(link.id) + \"-back\",\n backward=True, delay=link.delay,\n bandwidth=link.bandwidth) for u, v, link in\n self.network.edges... | [
"0.70373696",
"0.57783526",
"0.56992656",
"0.567812",
"0.55691844",
"0.54686385",
"0.5460457",
"0.5345617",
"0.53257793",
"0.52517647",
"0.52400166",
"0.5223792",
"0.51999927",
"0.50963116",
"0.50762844",
"0.5051021",
"0.5036633",
"0.5035841",
"0.50322276",
"0.50227106",
"0.5... | 0.6376797 | 1 |
Returns a list with the outbound or inbound SGHops from an NF. | def adjacent_sghops (self, nf_id):
return [sg for sg in self.sg_hops if sg.src.node.id == nf_id or \
sg.dst.node.id == nf_id] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_ins_fips(self):\n fip_lst = list()\n for srv_grp in self.srv_grp_lst:\n grp_fip_lst = list()\n for srv in srv_grp:\n fip_pt_name = srv['name'] + '_%s' % self.fip_port\n fip = list(\n self.conn.network.ips(port_id=fip_pt_n... | [
"0.5907204",
"0.581558",
"0.5703894",
"0.5697123",
"0.55592453",
"0.5291448",
"0.52210426",
"0.5209753",
"0.5132565",
"0.5121866",
"0.51103795",
"0.50825274",
"0.5066234",
"0.50126487",
"0.5008399",
"0.50068444",
"0.49716848",
"0.49656987",
"0.4936092",
"0.4896822",
"0.487104... | 0.63801295 | 0 |
Return an iterator for the NodeNFs which are mapped to the given Infra node. | def running_nfs (self, infra_id):
return (self.network.node[id] for id in
self.network.neighbors_iter(infra_id) if
self.network.node[id].type == Node.NF) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infra_neighbors (self, node_id):\n return (self.network.node[id] for id in self.network.neighbors_iter(node_id)\n if self.network.node[id].type == Node.INFRA)",
"def neighbors_iter(node, topology):\n return topology[node]",
"def infras (self):\n return (node for id, node in self.network... | [
"0.6471772",
"0.6200912",
"0.6075931",
"0.58026713",
"0.5711703",
"0.56624573",
"0.56142956",
"0.5581208",
"0.5508736",
"0.54386574",
"0.5407855",
"0.54075235",
"0.5402591",
"0.54003584",
"0.5335363",
"0.5302775",
"0.5279831",
"0.5246688",
"0.5235311",
"0.51343364",
"0.513128... | 0.66097915 | 0 |
Remove every specific Link from the NFFG defined by given ``type``. | def clear_links (self, link_type):
return self.network.remove_edges_from(
[(u, v, link.id) for u, v, link in self.network.edges_iter(data=True) if
link.type == link_type]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_nodes (self, node_type):\n return self.network.remove_nodes_from(\n [id for id, node in self.network.nodes_iter(data=True) if\n node.type == node_type])",
"def del_objects_by_type(self, type_):\n [o.del_object_from_parent() for o in self.get_objects_by_type(type_)]",
"def remove_... | [
"0.6603936",
"0.6357903",
"0.6172821",
"0.5995849",
"0.5929985",
"0.58419454",
"0.57417136",
"0.57147884",
"0.5664573",
"0.5593423",
"0.55136305",
"0.55134106",
"0.5491581",
"0.5487299",
"0.54475117",
"0.5351751",
"0.53516906",
"0.5321873",
"0.53179085",
"0.5275849",
"0.52735... | 0.8084758 | 0 |
Remove every specific Node from the NFFG defined by given ``type``. | def clear_nodes (self, node_type):
return self.network.remove_nodes_from(
[id for id, node in self.network.nodes_iter(data=True) if
node.type == node_type]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def del_objects_by_type(self, type_):\n [o.del_object_from_parent() for o in self.get_objects_by_type(type_)]",
"def clear_links (self, link_type):\n return self.network.remove_edges_from(\n [(u, v, link.id) for u, v, link in self.network.edges_iter(data=True) if\n link.type == link_type])",... | [
"0.6512583",
"0.6466888",
"0.62632704",
"0.60153896",
"0.5894578",
"0.58712524",
"0.58369315",
"0.5816205",
"0.57938826",
"0.5790411",
"0.57367533",
"0.5712486",
"0.57042867",
"0.56945354",
"0.5675354",
"0.56621206",
"0.5647158",
"0.5643425",
"0.5582952",
"0.5546813",
"0.5532... | 0.8019849 | 0 |
Return the deep copy of the NFFG object. | def copy (self):
copy = NFFG(id=self.id, name=self.name, version=self.version,
mode=self.mode, metadata=self.metadata.copy(),
status=self.status)
copy.network = self.network.copy()
return copy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_copy_of_graph(self):\r\n return deepcopy(self)",
"def deepcopy(self):\n return self.copy()",
"def deepcopy(self):\n return copymod.deepcopy(self)",
"def copy(self):\n \n \n G = DiGraph()\n G.node_set = copy.deepcopy(self.node_set)\n G.prefix = c... | [
"0.7335322",
"0.72988623",
"0.72484994",
"0.7229129",
"0.7148504",
"0.71093065",
"0.71093065",
"0.71093065",
"0.71093065",
"0.7091151",
"0.70776975",
"0.7059019",
"0.69759387",
"0.69453484",
"0.69453484",
"0.69453484",
"0.69453484",
"0.69453484",
"0.69453484",
"0.69453484",
"... | 0.8241045 | 0 |
Calculates available bandwidth on all the infrastructure links. Stores them in 'availbandwidth' field of the link objects. Modifies the NFFG instance. | def calculate_available_link_res (self, sg_hops_to_be_ignored, mode=MODE_ADD):
# set availbandwidth to the maximal value
for i, j, k, d in self.network.edges_iter(data=True, keys=True):
if d.type == 'STATIC':
setattr(self.network[i][j][k], 'availbandwidth', d.bandwidth)
# subtract the reserved... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_links_capacity(self):\n\n links_capacity = {}\n # Iterates all the edges in the topology formed by switches\n for src, dst in self.topo.keep_only_p4switches().edges:\n bw = self.topo.edges[(src, dst)]['bw']\n # add both directions\n links_capacity[(sr... | [
"0.5871045",
"0.5767752",
"0.57570285",
"0.5268679",
"0.5218068",
"0.51853895",
"0.5159055",
"0.5135974",
"0.512185",
"0.4990857",
"0.4984779",
"0.49785995",
"0.4936895",
"0.48840082",
"0.48823157",
"0.48750702",
"0.48672506",
"0.4828551",
"0.47911093",
"0.47893062",
"0.47765... | 0.68978274 | 0 |
Calculates available computation and networking resources of the nodes of NFFG. Creates a NodeResource instance for each NodeInfra to store the available resources in the 'availres' attribute added by this fucntion. | def calculate_available_node_res (self, vnfs_to_be_left_in_place={},
mode=MODE_ADD):
# add available res attribute to all Infras and subtract the running
# NFs` resources from the given max res
for n in self.infras:
setattr(self.network.node[n.id], 'availres',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_available_resource(self, nodename):\n curent_time = time.time()\n if curent_time - self.cleanup_time > CONF.azure.cleanup_span:\n self.cleanup_time = curent_time\n self._cleanup_deleted_os_disks()\n self._cleanup_deleted_nics()\n usage_family = 'basicAF... | [
"0.6334263",
"0.632154",
"0.6148349",
"0.6050394",
"0.5951743",
"0.59090984",
"0.59032845",
"0.5869504",
"0.5822084",
"0.5756045",
"0.5743844",
"0.55827713",
"0.5515002",
"0.5495628",
"0.5488245",
"0.5382409",
"0.531669",
"0.5313082",
"0.52796626",
"0.5244018",
"0.5240481",
... | 0.6322726 | 1 |
Deletes all flowrules, which belong to a given SGHop ID. Compares based on Flowrule.ID and SGHop.ID they should be identical only for the corresponding Flowrules. | def del_flowrules_of_SGHop (self, hop_id_to_del):
for n in self.infras:
for p in n.ports:
for fr in p.flowrules:
if fr.id == hop_id_to_del:
p.del_flowrule(id=fr.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_flows(self, datapath, table_id):\n parser = datapath.ofproto_parser\n ofproto = datapath.ofproto\n empty_match = parser.OFPMatch()\n instructions = []\n flow_mod = self.remove_table_flows(datapath, table_id,\n empty_match, instruc... | [
"0.6729904",
"0.6621421",
"0.6430987",
"0.62688047",
"0.6118565",
"0.6089295",
"0.607425",
"0.60695034",
"0.6044651",
"0.5886559",
"0.5774169",
"0.57198316",
"0.563073",
"0.5610008",
"0.55014557",
"0.5470932",
"0.543596",
"0.5389442",
"0.53854465",
"0.537824",
"0.53218853",
... | 0.80643237 | 0 |
Return with the set of detected domains in the given ``nffg``. | def detect_domains (nffg):
return {infra.domain for infra in nffg.infras} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_of_domains(fc):\r\n # need to find root database (GDB or SDE)\r\n db_root = os.path.dirname(fc)\r\n while db_root[-4:].lower() != '.gdb' and db_root[-4:].lower() != '.sde':\r\n old_db_root = db_root # protect against infinite loop\r\n db_root = os.path.dirname(db_root)\r\n i... | [
"0.5715548",
"0.5416049",
"0.52760077",
"0.5181182",
"0.51308227",
"0.5115451",
"0.50817317",
"0.5076662",
"0.506168",
"0.49432272",
"0.49424198",
"0.4927534",
"0.49068516",
"0.48634955",
"0.4863474",
"0.48519802",
"0.48281175",
"0.48183325",
"0.4810689",
"0.48017603",
"0.479... | 0.8074619 | 0 |
Search for possible interdomain ports examining ports' metadata and recreate associated SAPs. | def recreate_inter_domain_SAPs (nffg, log=logging.getLogger("SAP-recreate")):
for infra in nffg.infras:
for port in infra.ports:
# Check ports of remained Infra's for SAP ports
if port.get_property("type") == "inter-domain":
# Found inter-domain SAP port
log.debug("Found in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_ports(self):\n \n # fetch only those ports having\n # VID:PID == a valid (VID, PID) pair in target_vid_pid\n ports = []\n\n for valid_pair in self.target_vid_pid:\n vid_pid = valid_pair[0] + ':' + valid_pair[1]\n ports = ports + [p for p in list_... | [
"0.5992215",
"0.5894644",
"0.5889498",
"0.58664644",
"0.5771846",
"0.5741196",
"0.56310797",
"0.5609413",
"0.55756277",
"0.5460572",
"0.5395904",
"0.5379044",
"0.5376819",
"0.53758365",
"0.5336504",
"0.5240627",
"0.52163196",
"0.5202257",
"0.51975137",
"0.5190538",
"0.5164131... | 0.72157174 | 0 |
Merge the given ``nffg`` into the ``base`` NFFG using the given domain name. | def merge_new_domain (cls, base, nffg, log=logging.getLogger("MERGE")):
# Get new domain name
domain = cls.detect_domains(nffg=nffg)
if len(domain) == 0:
log.error("No domain detected in new %s!" % nffg)
return
if len(domain) > 1:
log.warning("Multiple domain name detected in new %s!" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_domain (cls, base, updated, log):\n # Get new domain name\n domain = cls.detect_domains(nffg=updated)\n if len(domain) == 0:\n log.error(\"No domain detected in new %s!\" % updated)\n return\n if len(domain) > 1:\n log.warning(\"Multiple domain name detected in new %s!\" % upd... | [
"0.59408814",
"0.5408137",
"0.53850424",
"0.52775776",
"0.5049973",
"0.49689803",
"0.48926353",
"0.47978577",
"0.47261178",
"0.46813732",
"0.46550885",
"0.45752043",
"0.44109502",
"0.43892962",
"0.43634245",
"0.43413514",
"0.43399385",
"0.43283433",
"0.43159375",
"0.43020532",
... | 0.7497955 | 0 |
Recreate TAGs for flowrules forwarding traffic from a different domain. In case there is a hop in the service request mapped as a collocated link it might break down to multiple links/flowrules in a lower layer where the links are placed into different domains therefore the match/action field are created without tags b... | def recreate_missing_match_TAGs (cls, nffg, log=logging.getLogger("TAG")):
log.debug("Recreate missing TAG matching fields...")
for infra in nffg.infras:
# Iterate over flowrules of the infra
for flowrule in infra.flowrules():
# Get the source in_port of the flowrule from match field
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rewrite_interdomain_tags (cls, slices,\n log=logging.getLogger(\"adaptation.TAG\")):\n log.debug(\"Calculating inter-domain tags...\")\n\n for nffg in slices:\n log.debug(\"Processing domain %s\" % nffg[0])\n # collect SAP ports of infra nodes\n sap_ports = [... | [
"0.5236256",
"0.5180711",
"0.49311906",
"0.49208695",
"0.49144864",
"0.48281172",
"0.47609824",
"0.47451013",
"0.4646913",
"0.46388808",
"0.46364954",
"0.46134508",
"0.45853937",
"0.45487234",
"0.45398515",
"0.45370334",
"0.45352852",
"0.4526474",
"0.4495758",
"0.4430548",
"0... | 0.6440691 | 0 |
Calculate and rewrite interdomain tags. Interdomain connections via interdomain SAPs are harmonized here. The abstract tags in flowrules are rewritten to technology specific ones based on the information retrieved from interdomain SAPs. | def rewrite_interdomain_tags (cls, slices,
log=logging.getLogger("adaptation.TAG")):
log.debug("Calculating inter-domain tags...")
for nffg in slices:
log.debug("Processing domain %s" % nffg[0])
# collect SAP ports of infra nodes
sap_ports = []
for sap in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_inter_domain_SAPs (nffg, log=logging.getLogger(\"SAP-recreate\")):\n for infra in nffg.infras:\n for port in infra.ports:\n # Check ports of remained Infra's for SAP ports\n if port.get_property(\"type\") == \"inter-domain\":\n # Found inter-domain SAP port\n lo... | [
"0.5405681",
"0.52059686",
"0.5128725",
"0.5093692",
"0.49278158",
"0.48995486",
"0.48758203",
"0.48604518",
"0.48008776",
"0.47956112",
"0.47857237",
"0.47310656",
"0.4682615",
"0.4649645",
"0.46413955",
"0.46413955",
"0.46077332",
"0.45998052",
"0.4584066",
"0.4549003",
"0.... | 0.7564336 | 0 |
Search for splitted requirement links in the NFFG. If a link connects interdomain SAPs rebind the link as an e2e requirement link. | def rebind_e2e_req_links (nffg, log=logging.getLogger("REBIND")):
log.debug(
"Search for requirement link fragments to rebind as e2e requirement...")
req_cache = []
def __detect_connected_sap (port):
"""
Detect if the given port is connected to a SAP.
:param port: port object
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse(fln, start):\n #stop when link is repeated or dead link\n links_traversed = []\n try:\n fl = correct_cap(fln[start])\n except KeyError:\n return \"broken link\" \n i = 0\n while fl not in links_traversed and fl !=\"\":\n #maybe add clicks here?\n i += 1\n ... | [
"0.5492125",
"0.53492194",
"0.52525395",
"0.52372617",
"0.5168263",
"0.5090885",
"0.4952377",
"0.49471262",
"0.49302143",
"0.4912148",
"0.49042922",
"0.49017203",
"0.48870632",
"0.4869679",
"0.48350626",
"0.48342505",
"0.4826854",
"0.48213518",
"0.4803608",
"0.4800865",
"0.47... | 0.6965367 | 0 |
Detect if the given port is connected to a SAP. | def __detect_connected_sap (port):
connected_port = [l.dst for u, v, l in
nffg.real_out_edges_iter(port.node.id)
if str(l.src.id) == str(port.id)]
# If the number of detected nodes is unexpected continue to the next req
if len(connected_port) < 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_port(self):\r\n\t\treturn(self.connect.is_open)",
"def is_port_open(port):\n with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:\n return sock.connect_ex(('127.0.0.1', port)) == 0",
"def port_is_open(port):\n sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n ... | [
"0.70647216",
"0.68524176",
"0.68175215",
"0.6814829",
"0.66565543",
"0.66276073",
"0.6614682",
"0.65460545",
"0.6506952",
"0.64480054",
"0.6359871",
"0.63555664",
"0.6349075",
"0.6255833",
"0.62338245",
"0.6196579",
"0.6193484",
"0.619177",
"0.6190956",
"0.6143069",
"0.61191... | 0.7196281 | 0 |
Generate the trivial virtual topology a.k.a one BisBis or Single BisBis representation with calculated resources and transferred NF and SAP nodes. | def generate_SBB_representation (nffg, add_sg_hops=False,
log=logging.getLogger("SBB")):
if nffg is None:
log.error("Missing global resource info! Skip OneBisBis generation!")
return None
# Create Single BiSBiS NFFG
log.debug("Generate trivial SingleBiSBiS NFFG... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateTopology():\n switches = {}\n interfaces = {}\n links = {}\n return (switches,links)",
"def build_topology(self):\n# errstr = \"build_topology() is not implemented.\\n\"\n# errstr += textwrap.dedent(self.build_topology.__doc__)\n# raise NotImplementedE... | [
"0.6106451",
"0.5710382",
"0.5708182",
"0.5629753",
"0.56108606",
"0.55606157",
"0.55536723",
"0.554405",
"0.5535137",
"0.54171604",
"0.5369607",
"0.531302",
"0.53012824",
"0.5280494",
"0.5278735",
"0.5202594",
"0.5190665",
"0.5153272",
"0.5128179",
"0.512428",
"0.512428",
... | 0.6038997 | 1 |
Clean domain by removing initiated NFs and flowrules related to BiSBiS nodes of the given domain | def clear_domain (cls, base, domain, log=logging.getLogger("CLEAN")):
base_domain = cls.detect_domains(nffg=base)
if domain not in base_domain:
log.warning("No node was found in %s with domain: %s for cleanup! "
"Leave NFFG unchanged..." % (base, domain))
return base
for infra ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune(self,domains,constraint):\n left_var = constraint.left[0]\n left_const_mult = constraint.left[1]\n left_val = constraint.left[2]\n\n right_var = constraint.right[0]\n right_const_mult = constraint.right[1]\n right_val = constraint.right[2]\n\n new_domains ... | [
"0.5818017",
"0.56803447",
"0.56279546",
"0.56248057",
"0.54941326",
"0.5333138",
"0.5273646",
"0.5255682",
"0.5253652",
"0.52512664",
"0.52415764",
"0.5237314",
"0.5206676",
"0.51992273",
"0.5195336",
"0.51805794",
"0.5138387",
"0.5116038",
"0.51012516",
"0.50965875",
"0.508... | 0.76836884 | 0 |
Update the mapped elements of given nffg with given status. | def update_status_info (cls, nffg, status,
log=logging.getLogger("UPDATE-STATUS")):
log.debug("Add %s status for NFs and Flowrules..." % status)
for nf in nffg.nfs:
nf.status = status
for infra in nffg.infras:
for flowrule in infra.flowrules():
flowrule.status =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_nffg_by_status (cls, base, updated,\n log=logging.getLogger(\"UPDATE-DOMAIN-STATUS\")):\n # Update NF status\n base_nfs = {nf.id for nf in base.nfs}\n updated_nfs = {nf.id for nf in updated.nfs}\n log.debug(\"Update status of NF nodes: %s\" % updated_nfs)\n for... | [
"0.6808637",
"0.631988",
"0.631508",
"0.6194839",
"0.6061564",
"0.6031278",
"0.59473747",
"0.58671206",
"0.5796069",
"0.5775325",
"0.57561815",
"0.5726916",
"0.5720198",
"0.57128835",
"0.57065976",
"0.55265665",
"0.55248284",
"0.5501515",
"0.5435542",
"0.54303557",
"0.5384748... | 0.75115687 | 0 |
Update status of the elements of the given ``base`` nffg based on the given ``updated`` nffg. | def update_nffg_by_status (cls, base, updated,
log=logging.getLogger("UPDATE-DOMAIN-STATUS")):
# Update NF status
base_nfs = {nf.id for nf in base.nfs}
updated_nfs = {nf.id for nf in updated.nfs}
log.debug("Update status of NF nodes: %s" % updated_nfs)
for nf in base_nfs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_status_info (cls, nffg, status,\n log=logging.getLogger(\"UPDATE-STATUS\")):\n log.debug(\"Add %s status for NFs and Flowrules...\" % status)\n for nf in nffg.nfs:\n nf.status = status\n for infra in nffg.infras:\n for flowrule in infra.flowrules():\n f... | [
"0.643071",
"0.6034054",
"0.56939244",
"0.56860435",
"0.56860435",
"0.5672548",
"0.56001943",
"0.5492602",
"0.5438432",
"0.54368514",
"0.53913593",
"0.53680015",
"0.5324636",
"0.5317145",
"0.5315461",
"0.5261797",
"0.5247321",
"0.5217608",
"0.521028",
"0.5185313",
"0.518496",... | 0.8117143 | 0 |
Create a new NFFG from the given ``nffg`` and filter out the stopped/failed Nfs. | def filter_non_running_NFs (self, nffg, log=logging.getLogger("FILTER")):
# TODO implement
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_difference_of_nffgs (cls, old, new, ignore_infras=False):\n add_nffg = copy.deepcopy(new)\n add_nffg.mode = NFFG.MODE_ADD\n del_nffg = copy.deepcopy(old)\n del_nffg.mode = NFFG.MODE_DEL\n add_nffg = NFFGToolBox.subtract_nffg(add_nffg, old,\n consi... | [
"0.57996505",
"0.5127524",
"0.51053214",
"0.5094821",
"0.50266916",
"0.5008383",
"0.48391506",
"0.48264992",
"0.48109856",
"0.4789917",
"0.4757365",
"0.47047874",
"0.46826434",
"0.4595612",
"0.45872706",
"0.4578142",
"0.45675346",
"0.45310426",
"0.4513786",
"0.45125392",
"0.4... | 0.74227095 | 0 |
Remove all the installed NFs, flowrules and dynamic ports from given NFFG. | def remove_deployed_services (cls, nffg, log=logging.getLogger("CLEAN")):
for infra in nffg.infras:
log.debug("Remove deployed elements from Infra: %s" % infra.id)
del_ports = []
del_nfs = []
for src, dst, link in nffg.network.out_edges_iter(data=True):
if link.type == NFFG.TYPE_LINK... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deinstallnetifs(self):\n for n in sorted(self._objs.keys()):\n emanenode = self._objs[n]\n emanenode.deinstallnetifs()",
"def on_prune(self, fgraph, app, reason):\r\n if app not in self.debug_all_apps: raise ProtocolError(\"prune without import\")\r\n self.debug_all... | [
"0.60870355",
"0.6056826",
"0.6044345",
"0.5828601",
"0.5807269",
"0.5700049",
"0.56651765",
"0.5626257",
"0.5589477",
"0.5544968",
"0.55105555",
"0.54942024",
"0.5431496",
"0.53695846",
"0.5343798",
"0.532446",
"0.53048974",
"0.52995867",
"0.5297375",
"0.52886486",
"0.528399... | 0.7053235 | 0 |
Copies all element from iterator if it is not in target, and merges their port lists. | def _copy_node_type (cls, type_iter, target, log):
for obj in type_iter:
if obj.id not in target:
c_obj = target.add_node(deepcopy(obj))
log.debug("Copy NFFG node: %s" % c_obj)
else:
for p in obj.ports:
if p.id not in target.network.node[obj.id].ports:
targe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_ports(destination):\n output_ports = set()\n if isinstance(destination, collections.Iterable):\n for device in destination:\n # ports leading to device\n ports_towards_device = self.forwarding_table.get(\n de... | [
"0.5419328",
"0.5359984",
"0.52457196",
"0.5013337",
"0.49989697",
"0.49255812",
"0.49108243",
"0.49108243",
"0.4874527",
"0.48633096",
"0.48607433",
"0.48544478",
"0.48544478",
"0.48544478",
"0.48544478",
"0.48501763",
"0.4848988",
"0.48328236",
"0.4809087",
"0.48068747",
"0... | 0.54106486 | 1 |
Merges new `NFFG` to target `NFFG` keeping all parameters and copying port object from new. Comparison is done based on object id, resources and requirements are kept unchanged in target. | def merge_nffgs (cls, target, new, log=logging.getLogger("UNION")):
# Copy Infras
target = cls._copy_node_type_with_flowrules(new.infras, target, log)
# Copy NFs
target = cls._copy_node_type(new.nfs, target, log)
# Copy SAPs
target = cls._copy_node_type(new.saps, target, log)
# Copy remaini... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy (self):\n copy = NFFG(id=self.id, name=self.name, version=self.version,\n mode=self.mode, metadata=self.metadata.copy(),\n status=self.status)\n copy.network = self.network.copy()\n return copy",
"def generate_difference_of_nffgs (cls, old, new, ignore_infras=False... | [
"0.56954485",
"0.5646142",
"0.55691403",
"0.54555297",
"0.5425318",
"0.53708476",
"0.5336824",
"0.52707225",
"0.5062177",
"0.50367194",
"0.5034017",
"0.50319964",
"0.4986245",
"0.49800143",
"0.49546924",
"0.48907632",
"0.48616588",
"0.48399198",
"0.4826294",
"0.4810259",
"0.4... | 0.74760544 | 0 |
Deletes every (all types of) node from minuend which have higher degree in subtrahend. And removes every (all types of) edge from minuend which are present in subtrahend. Changes minuend, but doesn't change subtrahend. | def subtract_nffg (cls, minuend, subtrahend, consider_vnf_status=False,
ignore_infras=False):
if ignore_infras:
minuend_degrees = {}
for nf in minuend.nfs:
minuend_degrees[nf.id] = len(minuend.adjacent_sghops(nf.id))
subtrahend_degrees = [(nf.id, len(subtrahend.adjacen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_edges(self, node: NodeKey) -> Edge:",
"def _delete_edges(self, to_be_deleted_set, adj_dict):\n for pair in to_be_deleted_set:\n first_node = pair[0]\n second_node = pair[1]\n adj_dict.pop((first_node, second_node), None)",
"def _removeEdgesNodes(self, curNode)... | [
"0.5800726",
"0.57609105",
"0.57273424",
"0.5721632",
"0.5678901",
"0.5648727",
"0.5642913",
"0.5627054",
"0.5599555",
"0.5575118",
"0.5509748",
"0.5438803",
"0.5436207",
"0.543222",
"0.5426978",
"0.54125166",
"0.5401846",
"0.5397296",
"0.537213",
"0.53634346",
"0.5344739",
... | 0.6400291 | 0 |
Creates two NFFG objects which can be used in NFFG.MODE_ADD and NFFG.MODE_DEL operation modes of the mapping algorithm. Doesn't modify input objects. If infra nodes shall be ignored, node degree comparison is only based on SGHops, but the output structure still contains the infras which were in the input. | def generate_difference_of_nffgs (cls, old, new, ignore_infras=False):
add_nffg = copy.deepcopy(new)
add_nffg.mode = NFFG.MODE_ADD
del_nffg = copy.deepcopy(old)
del_nffg.mode = NFFG.MODE_DEL
add_nffg = NFFGToolBox.subtract_nffg(add_nffg, old,
consider_vnf_sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nb_edit_operations(g1, g2, forward_map, backward_map):\n n_vi = 0\n n_vr = 0\n n_vs = 0\n n_ei = 0\n n_er = 0\n n_es = 0\n\n nodes1 = [n for n in g1.nodes()]\n for i, map_i in enumerate(forward_map):\n if map_i == np.inf:\n n_vr += 1\n elif g1.nodes[nodes1[i... | [
"0.5660053",
"0.55723387",
"0.55439883",
"0.5527758",
"0.5520193",
"0.53698385",
"0.5297372",
"0.52619475",
"0.5233402",
"0.52191544",
"0.5174066",
"0.5160298",
"0.51529",
"0.5122552",
"0.50979644",
"0.5049677",
"0.50166327",
"0.5005129",
"0.4994638",
"0.498568",
"0.49426013"... | 0.6875129 | 0 |
Interprets the match field of a flowrule as everything is flowclass except "TAG=" and "in_port=" fields. Returns the string to be put into the flowclass field. Hopefully the order of the match segments are kept or irrelevant. | def _extract_flowclass (splitted_matches):
flowclass = ""
for match in splitted_matches:
field, mparam = match.split("=", 1)
if field == "flowclass":
flowclass += mparam
elif field != "TAG" and field != "in_port":
flowclass += "".join((field, "=", mparam))
if flowclass == "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_missing_match_TAGs (cls, nffg, log=logging.getLogger(\"TAG\")):\n log.debug(\"Recreate missing TAG matching fields...\")\n for infra in nffg.infras:\n # Iterate over flowrules of the infra\n for flowrule in infra.flowrules():\n # Get the source in_port of the flowrule from match... | [
"0.52396417",
"0.516592",
"0.50807893",
"0.500554",
"0.495508",
"0.4831025",
"0.47114286",
"0.4685041",
"0.46545094",
"0.46535552",
"0.46359196",
"0.46065676",
"0.46049976",
"0.45998904",
"0.45807922",
"0.4565503",
"0.45568678",
"0.454837",
"0.4540766",
"0.45060453",
"0.45025... | 0.81690514 | 0 |
Finds the Flowrule which belongs to the path of SGHop with ID 'fr_id'. | def _get_flowrule_and_its_starting_port (infra, fr_id):
for p in infra.ports:
for fr in p.flowrules:
if fr.id == fr_id:
return fr, p
else:
raise RuntimeError("Couldn't find Flowrule for SGHop %s in Infra %s!"
% (fr_id, infra.id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flowpath(cursor, huc12, fpath):\n cursor.execute(\n \"\"\"\n SELECT fid from flowpaths where huc_12 = %s and fpath = %s\n and scenario = %s\n \"\"\",\n (huc12, fpath, SCENARIO),\n )\n if cursor.rowcount == 0:\n cursor.execute(\n \"\"\"\n ... | [
"0.6005852",
"0.5729562",
"0.5702933",
"0.56665075",
"0.56562155",
"0.5592889",
"0.5592889",
"0.5592889",
"0.55519015",
"0.550501",
"0.54963535",
"0.5473717",
"0.5473717",
"0.53750736",
"0.53665125",
"0.5363853",
"0.5345485",
"0.53424156",
"0.5279123",
"0.5270722",
"0.5251553... | 0.77779925 | 0 |
Find the port object where this Flowrule sends the traffic out. | def _get_output_port_of_flowrule (infra, fr):
for action in fr.action.split(";"):
comm, arg = action.split("=", 1)
if comm == 'output':
if "://" in arg:
# target-less flow rule -> skip
return
arg = NFFGToolBox.try_to_convert(arg)
return infra.ports[arg]
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port_out(self) -> int:\n return self.proto.port_out",
"def find_outport_by_ip(self, dst_ip):\n for port_no, port in self.ports.items():\n if port.gateway and dst_ip in port.gateway.ipv4_subnet:\n return port_no\n return None",
"def _get_port(self):\n return... | [
"0.6986233",
"0.68707657",
"0.6860134",
"0.6847393",
"0.6819305",
"0.67228955",
"0.67110026",
"0.6605388",
"0.660051",
"0.6585751",
"0.6514898",
"0.64527076",
"0.6407663",
"0.6398077",
"0.6387409",
"0.63723224",
"0.63607484",
"0.6274443",
"0.6270258",
"0.62499225",
"0.6242954... | 0.69392216 | 1 |
Checks whether there is an inconsistencity with Flowrule or SGHop 'fr_sg' and the other flowrules which are part of the SGHop's sequence OR SGHop which is in sg_map. Throws runtime exception if error found. Uses only the common fields of Flowrules and SGHops. 'flowclass' needs to be extracted if 'fr_sg' is not an SGHop... | def _check_flow_consistencity (sg_map, fr_sg):
if isinstance(fr_sg, Flowrule):
flowclass = NFFGToolBox._extract_flowclass(fr_sg.match.split(";"))
else:
flowclass = fr_sg.flowclass
consistent = True
if sg_map[fr_sg.id][2] != flowclass:
consistent = False
if (sg_map[fr_sg.id][3] is N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check(self):\n if not isinstance(self.fc_layers, tuple):\n raise TypeError(f'fc_layers require tuple, get {type(self.fc_layers)}')\n if not isinstance(self.use_dropout, tuple):\n raise TypeError(f'use_dropout require tuple, get {type(self.use_dropout)}')\n if not isi... | [
"0.50664634",
"0.5059571",
"0.50145936",
"0.49911734",
"0.4919192",
"0.49057424",
"0.4858774",
"0.48540297",
"0.47235358",
"0.46927387",
"0.4672308",
"0.46373573",
"0.46141183",
"0.46102306",
"0.45959538",
"0.4574853",
"0.45564124",
"0.45541632",
"0.45250165",
"0.45225924",
"... | 0.7957934 | 0 |
Returns a dictionary keyed by sghopid, data is [PortObjsrc, PortObjdst, SGHop.flowclass, SGHop.bandwidth, SGHop.delay] list of port objects. Source and destination VNFs can be retreived from port references (port.node.id). The function 'recreate_all_sghops' should receive this exact NFFG object and the output of this f... | def get_all_sghop_info (nffg, return_paths=False):
sg_map = {}
for i in nffg.infras:
for p in i.ports:
for fr in p.flowrules:
# if fr.external:
# continue
if fr.id not in sg_map:
# The path is unordered!!
path_of_shop = []
flowcla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_all_sghops (nffg):\n sg_map = NFFGToolBox.get_all_sghop_info(nffg)\n for sg_hop_id, data in sg_map.iteritems():\n src, dst, flowclass, bandwidth, delay = data\n if not (src and dst):\n continue\n if not nffg.network.has_edge(src.node.id, dst.node.id, key=sg_hop_id):\n ... | [
"0.69388586",
"0.5128839",
"0.493439",
"0.49192998",
"0.48895034",
"0.48668212",
"0.48530778",
"0.4835813",
"0.48097304",
"0.4799513",
"0.47819477",
"0.474145",
"0.4737266",
"0.4715825",
"0.47005218",
"0.46844685",
"0.4662982",
"0.46054044",
"0.458867",
"0.45739138",
"0.45622... | 0.6567149 | 1 |
Extracts the SGHop information from the input NFFG, and creates the SGHop objects in the NFFG. | def recreate_all_sghops (nffg):
sg_map = NFFGToolBox.get_all_sghop_info(nffg)
for sg_hop_id, data in sg_map.iteritems():
src, dst, flowclass, bandwidth, delay = data
if not (src and dst):
continue
if not nffg.network.has_edge(src.node.id, dst.node.id, key=sg_hop_id):
nffg.add_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_sghop_info (nffg, return_paths=False):\n sg_map = {}\n for i in nffg.infras:\n for p in i.ports:\n for fr in p.flowrules:\n # if fr.external:\n # continue\n if fr.id not in sg_map:\n # The path is unordered!!\n path_of_shop = []\n ... | [
"0.5692072",
"0.52976584",
"0.52797633",
"0.5264818",
"0.49701652",
"0.4933256",
"0.4910132",
"0.48744756",
"0.48728806",
"0.4856233",
"0.48540264",
"0.48535174",
"0.4833228",
"0.4828",
"0.48267072",
"0.48083073",
"0.4805149",
"0.47973818",
"0.47905827",
"0.47883868",
"0.4781... | 0.6285458 | 0 |
Redirect flowrules from `from` to `to_port` handling match/action fields. | def redirect_flowrules (from_port, to_port, infra, mark_external=False,
log=logging.getLogger("MOVE")):
# Flowrules pointing to the from_port -> rewrite output reference in action
for port in infra.ports:
for fr in port.flowrules:
output = fr.action.split(';', 1)[0].split... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_bidi(self, src_port, dst_port, command_logger=None):\r\n\r\n #Isolate source and destination port numbers from list provided by Cloudshell\r\n source = src_port[2]\r\n dest = dst_port[2]\r\n #Define URI to set rules via REST\r\n uri = 'http://' + self.address + '/rest/rul... | [
"0.5860748",
"0.5828182",
"0.56599706",
"0.56322217",
"0.5563851",
"0.53899115",
"0.5352825",
"0.51800925",
"0.51514894",
"0.5147007",
"0.5087051",
"0.5070545",
"0.50512785",
"0.50444746",
"0.50359976",
"0.5035886",
"0.5009846",
"0.49699217",
"0.49512655",
"0.49409634",
"0.49... | 0.6944747 | 0 |
Merge detected external ports in nodes of given `nffg` and only leave the original SAP port. | def merge_external_ports (cls, nffg, log=logging.getLogger("MERGE")):
for infra in nffg.infras:
for ext_port in [p for p in infra.ports if p.role == "EXTERNAL"]:
log.debug("Found external port: %s" % ext_port)
# Collect ports with the same SAP tag
origin_port = [p for p in infra.ports ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_inter_domain_SAPs (nffg, log=logging.getLogger(\"SAP-recreate\")):\n for infra in nffg.infras:\n for port in infra.ports:\n # Check ports of remained Infra's for SAP ports\n if port.get_property(\"type\") == \"inter-domain\":\n # Found inter-domain SAP port\n lo... | [
"0.6237199",
"0.6132542",
"0.6013807",
"0.56149006",
"0.5586992",
"0.5426036",
"0.51144695",
"0.5108328",
"0.50822425",
"0.4942656",
"0.49080583",
"0.4848519",
"0.48327482",
"0.4830631",
"0.4827639",
"0.48201877",
"0.47958925",
"0.47202426",
"0.47074836",
"0.46978286",
"0.468... | 0.788689 | 0 |
Return true if there is a Static outbound or inbound EdgeLink, false if there is a Dynamic outbound or inbound link, throws exception if borth, or warning if multiple of the same type. | def isStaticInfraPort (cls, G, p):
static_link_found = False
dynamic_link_found = False
for edge_func, src_or_dst in ((G.out_edges_iter, 'src'),
(G.in_edges_iter, 'dst')):
for i, j, k, link in edge_func([p.node.id], data=True, keys=True):
src_or_dst_port = get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cross_onap_link(self, logical_link):\n for relationship in logical_link[\"relationship-list\"][\"relationship\"]:\n if relationship[\"related-to\"] == \"ext-aai-network\":\n return True\n return False",
"def can_auralise(self):\n\n if not self.sources:\n ... | [
"0.62145",
"0.60337317",
"0.60157526",
"0.5975105",
"0.5946777",
"0.5906914",
"0.5846751",
"0.58444256",
"0.58435833",
"0.5783474",
"0.5763917",
"0.57411116",
"0.57314605",
"0.5711576",
"0.5703112",
"0.56962645",
"0.56906474",
"0.5684504",
"0.5678857",
"0.5668293",
"0.5659386... | 0.63736135 | 0 |
If history_table_name is Not None and its not created yet by a provided template, create it here | def create_hist_table(sc, table_name, history_table_name):
tgt_db, tgt_tbl = table_name.split(".")
hist_db, hist_tbl = history_table_name.split(".")
hist_db_tables = [_i.name for _i in sc.catalog.listTables(hist_db)]
if hist_tbl not in hist_db_tables:
ddl = sc.sql("show create table {}".format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_table(self):\n pass",
"def create_gt_database_template_old(self):\n pass\n with self.connection as cursor:\n fn = os.path.join(os.path.dirname(__file__), 'gtlogold.sql')\n self.cursor.execute(open(fn, \"r\").read())",
"def create_gt_database_template(self):... | [
"0.6478658",
"0.6477836",
"0.64602244",
"0.6390303",
"0.63097805",
"0.6200222",
"0.60751015",
"0.6067548",
"0.6060933",
"0.6009766",
"0.5999947",
"0.5998369",
"0.59083533",
"0.5908017",
"0.585254",
"0.5846531",
"0.5837164",
"0.5834249",
"0.58302236",
"0.58302236",
"0.5813292"... | 0.682582 | 0 |
This will create and purge history table. If no history table is passed then still the old S3 data needs to be removed, because every time current table points to a new location | def purge_history(sc, table, history_table, keep_latest_n):
if sys.platform != "darwin":
# remove the corresponding s3 location - safety check that the location is a run_id location in particular buckets.
# wants to make sure we are deleting s3 path with expected pattern.
# Expected S3 path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteHistory(self):\n\t\tmc.delete( self.objects, ch = True )",
"def create_hist_table(sc, table_name, history_table_name):\n tgt_db, tgt_tbl = table_name.split(\".\")\n hist_db, hist_tbl = history_table_name.split(\".\")\n\n hist_db_tables = [_i.name for _i in sc.catalog.listTables(hist_db)]\n\n ... | [
"0.59812003",
"0.590165",
"0.5847703",
"0.58427507",
"0.58074504",
"0.5759624",
"0.5723268",
"0.557413",
"0.5487858",
"0.54855293",
"0.5478863",
"0.5464969",
"0.545989",
"0.54579055",
"0.54423064",
"0.54258645",
"0.5396567",
"0.53866327",
"0.537805",
"0.53767323",
"0.537315",... | 0.75283176 | 0 |
Shows a list with all subrecipes of the user, ordered by name. Also, if the search form is submitted, it redirects to the search_by_name route. | def sort_by_name(arg):
form = SearchForm()
if form.validate_on_submit():
return redirect(url_for(
'subrecipes.search_by_name', arg=form.name.data
))
return render_template(
'overview/subrecipe.html',
title='Subrecetas',
recipe_form=SearchRecipeForm(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_recipes():\r\n cuisine, course, allergens = Helpers.dropdowns(coll_cuisines, coll_courses, coll_allergens)\r\n args = request.args.get\r\n args_list = request.args.getlist\r\n\r\n # Get Search and Pagination arguments from URL\r\n keyword_args = (\r\n args(\"search_keys\") if args(... | [
"0.67048424",
"0.66493833",
"0.66376406",
"0.663031",
"0.6617709",
"0.6362511",
"0.6243317",
"0.6164669",
"0.61598754",
"0.6131195",
"0.6125848",
"0.6100509",
"0.5957846",
"0.5862467",
"0.5806422",
"0.5784425",
"0.577519",
"0.57444817",
"0.57404995",
"0.57025814",
"0.56878424... | 0.74321026 | 0 |
Initializes the attributes of a new Java method. | def __init__(self, exact=None, javadocs=None, modifiers=None,
return_type=None, name=None, params=None, exceptions=None,
body=None, indent=4):
super(JavaMethod, self).__init__(exact=exact, javadocs=javadocs,
modifiers=modifiers, name=nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super(MethodInfo, self).__init__()\n self.DocString = None",
"def initialize(self, *args, **kwargs):",
"def __init__ (self, name):\n self.name = name\n self.methods = [ ]\n self.methodVariants = {}",
"def __init__(self,\r\n path=No... | [
"0.6430161",
"0.6364987",
"0.6340873",
"0.62993217",
"0.6253602",
"0.6237848",
"0.6228457",
"0.61988485",
"0.6122478",
"0.61200064",
"0.6106455",
"0.60920376",
"0.60920376",
"0.60920376",
"0.6067838",
"0.60619867",
"0.6044233",
"0.60326505",
"0.6029616",
"0.5974848",
"0.59712... | 0.67852986 | 0 |
Sets the type of the return value of this method | def set_return_type(self, return_type, this_class_name=''):
retval = None if not return_type else self.add_dependency(return_type, this_class_name)
self._set_instance_data('return_type', retval) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result(self, type):\n self._result = type\n return self",
"def type(self, value):\n return value",
"def return_type(self) -> global___Type:",
"def result_type(self, result_type):\n\n self._result_type = result_type",
"def TYPE(value):\n raise NotImplementedError()",
"def ... | [
"0.75649786",
"0.72444797",
"0.6993231",
"0.6764628",
"0.6507684",
"0.64511466",
"0.64139664",
"0.6375838",
"0.6364737",
"0.62479186",
"0.623826",
"0.623826",
"0.62107956",
"0.61821705",
"0.61821705",
"0.6180463",
"0.61707777",
"0.6161656",
"0.6158912",
"0.60795885",
"0.60794... | 0.7336352 | 1 |
Adds a parameter to this method. The argument type is added to list of dependencies. param_type String representation of the argument type param_name String representation of the argument name | def add_parameter(self, param_type, param_name, this_class_name=''):
self._set_instance_data('parameters',
' '.join([self.add_dependency(param_type, this_class_name),
param_name])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_param(self, param):\n self._params.append(param)\n self.add_decompostion(param)",
"def _add_param(self, name):\n param = ParameterInfo()\n param._name = name\n self._parameters.append(param)\n return param",
"def add_param(self, param):\n self.params.app... | [
"0.72313774",
"0.71395564",
"0.70870864",
"0.7012361",
"0.6993316",
"0.6898438",
"0.65771914",
"0.65337783",
"0.652828",
"0.649369",
"0.6483649",
"0.6479143",
"0.64629084",
"0.6436926",
"0.6415659",
"0.6367334",
"0.6293474",
"0.62267184",
"0.6206001",
"0.6145263",
"0.61266017... | 0.83773285 | 0 |
Adds line to method body | def add_line(self, line):
self._set_instance_data('body', self.indent + ' ' * 4 + line) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, line):\n self.body.append(line)",
"def add_line(self, line):\n self.code.extend([\" \" * self.indent_level, line, \"\\n\"])",
"def add_line(self, line):\n self.code.extend([\" \" * self.indent_level, line, \"\\n\"])",
"def write_line(self,msg):\n self.body += str(msg... | [
"0.770481",
"0.73965085",
"0.73965085",
"0.6645379",
"0.64370364",
"0.640303",
"0.6330092",
"0.6328881",
"0.6298249",
"0.6215157",
"0.6215084",
"0.6201794",
"0.6194234",
"0.61729324",
"0.6144135",
"0.6044206",
"0.5998459",
"0.5984399",
"0.5945984",
"0.5931727",
"0.5927758",
... | 0.7952433 | 0 |
Wrap each generator invocation with the context manager factory. The input should be a function that returns a context manager, not a context manager itself, to handle oneshot context managers. | def _wrap_generator(ctx_factory, func):
@functools.wraps(func)
def generator_context(*args, **kwargs):
gen = func(*args, **kwargs)
# Generators are suspended and unsuspended at `yield`, hence we
# make sure the grad mode is properly set every time the execution
# flow returns in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doodad(fun: Generator):\n if inspect.isasyncgenfunction(fun):\n return asynccontextmanager(fun)\n else:\n return contextmanager(fun)",
"def _wrap_generator(self, func):\n @functools.wraps(func)\n def generator_context(*args, **kwargs):\n gen = func(*args, **kwargs... | [
"0.6608195",
"0.65393394",
"0.6536661",
"0.6470864",
"0.6386853",
"0.625493",
"0.6149387",
"0.6143508",
"0.61228955",
"0.6108546",
"0.6038699",
"0.6036093",
"0.60054135",
"0.59975433",
"0.59737784",
"0.5948477",
"0.58998334",
"0.5813369",
"0.58005047",
"0.57802796",
"0.576170... | 0.70858335 | 0 |
Pseudonymize value with salt, using HMACSHA256 encoding | def pseudonymize(value, salt=SALT_KEY):
# NOTE: Here we must bypass empty or None value as
# it will introduce specific hash value
if value is None or value is np.nan or value == '':
return None
return hmac.new(
key=salt.encode('utf-8'), # La clé
msg=str(value).encode('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_128_bit_pass(passwd):\n h = hashlib.sha256()\n h.update(passwd)\n return h.hexdigest()[:16]",
"def hash_with_salt(self, s):\n\n data = f'{s} {self.salt}'.encode('ascii') # encode string to raw bytes object\n hash_obj = hashlib.md5(data) # hash it \n if self.tru... | [
"0.6816568",
"0.66319567",
"0.66172683",
"0.6548917",
"0.6438281",
"0.6438281",
"0.635587",
"0.63431126",
"0.63226515",
"0.63068724",
"0.63068205",
"0.63068205",
"0.63068205",
"0.629659",
"0.6293497",
"0.62230414",
"0.6204245",
"0.6189054",
"0.61886877",
"0.6163169",
"0.61610... | 0.76911515 | 0 |
Method to retrieve a list of team instances from a text file | def get_teams_from_text(file_name, index):
teams = []
List = open("teams/" + file_name + ".txt",'r').read().splitlines()
j = 0
for i in range(0,len(List)):
if j < index:
dummy_team = Team(List[i], "Wappen")
teams.append(dummy_team)
j = j+1
return teams | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_teams():",
"def load_player_list(self, team_file):\n\n # Returns a player object list\n\n team_data = self.read_team_data(team_file)\n data = []\n for player_file in team_data['player_files']:\n data.append(self.read_player_data(player_file))\n return(data)",... | [
"0.65129673",
"0.6293432",
"0.6105414",
"0.6000561",
"0.5933526",
"0.5922148",
"0.5908699",
"0.58901787",
"0.5862978",
"0.5859831",
"0.58411944",
"0.5785471",
"0.57634604",
"0.5742617",
"0.5741107",
"0.57301307",
"0.57057446",
"0.56992114",
"0.56918526",
"0.56575686",
"0.5652... | 0.7461378 | 0 |
This method compares the name of an instance Team to names of a list of instances Team | def eq_name(team_a,team_list):
for i in range (0,len(team_list)):
if team_a.name == team_list[i].name:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_teams():",
"def test_teams_list(self):\n pass",
"def _validteams(self):\n db_filename = self.registryValue('dbLocation')\n with sqlite3.connect(db_filename) as conn:\n cursor = conn.cursor()\n query = \"select team from mlb\"\n cursor.execute(query)... | [
"0.62714523",
"0.6159894",
"0.6100396",
"0.6047044",
"0.6012417",
"0.59765226",
"0.58929336",
"0.5870103",
"0.5848383",
"0.5847634",
"0.57672846",
"0.5725971",
"0.56663734",
"0.56356865",
"0.56354773",
"0.56324697",
"0.5614358",
"0.5614358",
"0.5609009",
"0.5607091",
"0.55783... | 0.73956645 | 0 |
With this function, it is possible to set the league of a list of instances of Team | def set_league(teams, l):
#~ print teams[0].name
if l>0 and l<10:
for team in teams:
team.league = l
else:
print("Error! Only leagues between 1 and 9 can be set.")
return teams | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_teams():",
"def set_team(self, team):\n self.team_id = team.instance_id\n self.team_id_friendlyname = team.friendlyname\n self.team_name = team.name",
"def test_teams_list(self):\n pass",
"def set_team(self, team):\n self.team = team.upper()",
"def change_team():\... | [
"0.6486708",
"0.6357686",
"0.63449895",
"0.6287147",
"0.622929",
"0.6203808",
"0.6198986",
"0.61638767",
"0.6140999",
"0.6138326",
"0.6138326",
"0.6138326",
"0.6138326",
"0.6082325",
"0.6074363",
"0.6041492",
"0.60389125",
"0.59785634",
"0.59716797",
"0.59472585",
"0.5911203"... | 0.8204629 | 0 |
Prints the table of top scoring players | def print_top_scorers(teams):
all_players = []
for i in range(0,len(teams)):
for j in range(0, len(teams[i].players)):
all_players.append(teams[i].players[j])
players_sorted_score = sorted(all_players, key=attrgetter('shot_goals'), reverse=True)
for player in players_sorted_score:
if player.shot_goa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showtopscores(self):\n top_scores = LeaderBoard.gettopscorerslist(CURRENT_GAME_LEVEL)\n level_string = \"\"\n if CURRENT_GAME_LEVEL == DifficultyLevel.ExpertLevel:\n level_string = \"Expert level\"\n elif CURRENT_GAME_LEVEL == DifficultyLevel.BeginnerLevel:\n l... | [
"0.72427595",
"0.7058736",
"0.6919998",
"0.68565327",
"0.68301934",
"0.6799589",
"0.6799118",
"0.6768449",
"0.67436785",
"0.66828907",
"0.66562414",
"0.6649078",
"0.66353863",
"0.6630413",
"0.6612367",
"0.6593271",
"0.65779495",
"0.65458363",
"0.64895374",
"0.6461998",
"0.644... | 0.7383959 | 0 |
adding books to cart | def cart_add(request,book_id):
cart = Cart(request)
book = get_object_or_404(Book, id=book_id)
form = CartAddProductForm(request.POST)
if book.get_discounted_price()>0 :
if form.is_valid():
cd = form.cleaned_data
if book.has_inventory(cd['quantity']):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_book(self, data):\n exists = self.check_if_exists(data['isbn'])\n\n if exists:\n query = f\"\"\"UPDATE {TABLE} SET quantity = quantity + 10 WHERE bookID = '{data[\"isbn\"]}'\"\"\"\n else:\n query = f\"\"\"INSERT INTO {TABLE}(bookID, title, authors, avg_rating, rat... | [
"0.7237716",
"0.7159144",
"0.70528185",
"0.66772777",
"0.6627203",
"0.6573009",
"0.6544839",
"0.63841444",
"0.63628125",
"0.6349684",
"0.6331701",
"0.6306289",
"0.6272989",
"0.6156932",
"0.61442184",
"0.6121998",
"0.6118804",
"0.6106468",
"0.60736144",
"0.60259473",
"0.602490... | 0.7435848 | 0 |
removing the book from cart by pressing bottum | def cart_remove(request, book_id):
cart = Cart(request)
book = get_object_or_404(Book, id=book_id)
cart.remove(book)
return redirect('cart_detail') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_cart_item(request, article):\n cart_items = get_cart_items(request)\n if cart_items:\n cart_item_of_book = get_cart_item_of_book(cart_items, article)\n cart_item_of_book.delete()",
"def remove(self, conta):\n conta_id = str(conta.id)\n if conta_id in self.cart:\n ... | [
"0.7153638",
"0.6921485",
"0.6892331",
"0.6775543",
"0.67327744",
"0.6707741",
"0.6707651",
"0.6649209",
"0.6596261",
"0.6583109",
"0.6536278",
"0.6525487",
"0.64927036",
"0.6433649",
"0.64303595",
"0.64124286",
"0.6373824",
"0.6363877",
"0.63450587",
"0.6332115",
"0.6314338"... | 0.76401997 | 0 |
Add attribute to a components symbol | def add_symbol_attribute(self, symbol_attribute):
self.symbol_attributes.append(symbol_attribute) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_attribute(self, attr_type, name, components):\n self.attributes[attr_type] = {\"name\": name, \"components\": components}",
"def add_attribute(node_proto, name, value):\n node_proto.attribute.extend([make_attribute(name, value)])",
"def add_attribute(a, name, other):\n raise TypeError(\"ca... | [
"0.6974129",
"0.64148414",
"0.6248401",
"0.61786723",
"0.6157826",
"0.61389965",
"0.6125191",
"0.6111428",
"0.60390425",
"0.5983835",
"0.59692466",
"0.5955999",
"0.5899659",
"0.58925384",
"0.5872711",
"0.58150303",
"0.5802511",
"0.57953763",
"0.57946783",
"0.57858855",
"0.575... | 0.7023135 | 0 |
Return the instance id | def get_instance_id(self):
return self.instance_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_id(self) -> str:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"instance_id\")",
"def instance_id(self) -> pulumi.... | [
"0.9116741",
"0.88717157",
"0.88717157",
"0.88717157",
"0.886873",
"0.88266855",
"0.88266855",
"0.88266855",
"0.88266855",
"0.88266855",
"0.88266855",
"0.8816027",
"0.8816027",
"0.8816027",
"0.8701977",
"0.8701977",
"0.8701977",
"0.8701977",
"0.8701977",
"0.8701977",
"0.85580... | 0.90589434 | 1 |
Has pet already departed? | def already_departed(
pet_id: int,
all_pets: typing.List[pet_record.PetRecord]
) -> bool:
all_instances_of_pet_id = (p for p in all_pets if p.animal_id == pet_id)
for pet in all_instances_of_pet_id:
if not pet.departure:
# At least one departure not populated. Pet has not departed.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def petExist(animal, pet_id):\n return Animal.objects.filter(pk = pet_id).exists()",
"def test_create_a_pet(self):\n pet = Pet(0, \"fido\", \"dog\", False)\n self.assertNotEqual(pet, None)\n self.assertEqual(pet.id, 0)\n self.assertEqual(pet.name, \"fido\")\n self.assertEqua... | [
"0.65678793",
"0.55475163",
"0.55035734",
"0.5395228",
"0.53744984",
"0.5299733",
"0.5282993",
"0.5153859",
"0.51426494",
"0.5135253",
"0.5130445",
"0.51144177",
"0.50716674",
"0.507005",
"0.5067336",
"0.50638634",
"0.5063598",
"0.50367695",
"0.50337285",
"0.50283796",
"0.502... | 0.7600332 | 0 |
Classify current pets as new or existing. | def classify_pets(
current_pets: typing.List[int],
all_pets: typing.List[pet_record.PetRecord],
photos_path: str
) -> typing.Tuple[
typing.List[int],
typing.List[int],
typing.List[int],
typing.List[int]
]:
existing = []
new = []
photoless = []
all_pet_ids = set((p.animal_id f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_new(self):\n return self.new",
"def fusionne(self, new):\n if new == self:\n raise ValueError(\"une catégorie ne peut être fusionnée avec elle même\")\n self.alters_data = True\n if not isinstance(new, type(self)):\n raise TypeError(\"pas la même classe d'... | [
"0.5386672",
"0.49865335",
"0.49057952",
"0.48573503",
"0.47803438",
"0.47661558",
"0.4729286",
"0.47274882",
"0.46817902",
"0.46589866",
"0.46489355",
"0.4643516",
"0.46063337",
"0.46057928",
"0.46006587",
"0.45878243",
"0.4581355",
"0.4574922",
"0.45671228",
"0.456059",
"0.... | 0.52864456 | 1 |
Set departure time for adopted pets. | def update_adopted_pets(
all_pets: typing.List[pet_record.PetRecord],
adopted_pets: typing.List[int],
today: datetime.date
) -> None:
for adopted in adopted_pets:
all_instances_of_adopted = (p for p in all_pets if p.animal_id == adopted)
for pet in all_instances_of_adopted:
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def departure(self, when: datetime.date):\n if self._departure:\n logging.warning(\n f'Overwriting departure date of {self._departure.isoformat()} '\n f'for pet {self.animal_id} with {when.isoformat()}'\n )\n\n self._departure = when\n if sel... | [
"0.7171231",
"0.589961",
"0.5873297",
"0.57936215",
"0.57619715",
"0.5473302",
"0.54667395",
"0.53260934",
"0.53037345",
"0.53037345",
"0.5267912",
"0.5227267",
"0.5225046",
"0.5210831",
"0.5210831",
"0.5210831",
"0.5193452",
"0.5172613",
"0.5172613",
"0.5159191",
"0.5147607"... | 0.595063 | 1 |
Generate a random datetime between `start` and `end` | def random_date(start, end):
return start + datetime.timedelta(
# Get a random amount of seconds between `start` and `end`
seconds=random.randint(0, int((end - start).total_seconds())),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_date(start, end):\r\n delta = end - start\r\n int_delta = (delta.days * 24 * 60 * 60) + delta.seconds\r\n random_second = randrange(int_delta)\r\n return start + timedelta(seconds=random_second)",
"def random_date(start, end):\n delta = end - start\n int_delta = (delta.days * 24 * 60... | [
"0.8574811",
"0.856864",
"0.8555419",
"0.8545934",
"0.8545934",
"0.8545934",
"0.8545934",
"0.8545934",
"0.8485558",
"0.8219636",
"0.7930098",
"0.7594896",
"0.7429996",
"0.74030083",
"0.7347596",
"0.70903665",
"0.7050192",
"0.69726646",
"0.6915079",
"0.6781375",
"0.6757689",
... | 0.88036513 | 0 |
Converts a date into a single number matching that returned by the sqlite julianday function | def JulianDay(ADate):
C.execute('''SELECT julianday(?)''', (ADate,))
return C.fetchall()[0][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date(date):\n return date",
"def get_date_as_int(date):\n\n return int(date.replace('-', ''))",
"def date_to_julian_day(my_date):\n a = (14 - my_date.month)//12\n y = my_date.year + 4800 - a\n m = my_date.month + 12*a - 3\n return my_date.day + ((153*m + 2)//5) + 365*y + y//4 - y//100... | [
"0.6564208",
"0.65479034",
"0.6366078",
"0.63133544",
"0.62384015",
"0.61957335",
"0.6186449",
"0.6159146",
"0.6146235",
"0.61170274",
"0.61011696",
"0.6085772",
"0.60837555",
"0.60624623",
"0.60475886",
"0.6046806",
"0.60060817",
"0.5999101",
"0.59681314",
"0.59609896",
"0.5... | 0.7013769 | 0 |
Creates a behaviour tree from a list of routines and a plan | def makeTree(plan, initialState):
#The initial node of the behaviour tree
tree = Sequence("Tree")
#Added the routines from the black board
tree.add_child(global_vars.black_board.makeRoutines())
#The node of the plan
planTask = Sequence("Plan")
#Initialize the first place where the robot starts
lastPlace = g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(plans_list, parent=None):\n result_list = []\n for plan in plans_list:\n node_type = plan[\"Node Type\"].upper()\n if parent is None:\n node = AnyNode(id=node_type, node_type=node_type)\n else:\n node = AnyNode(id=node_type, node_type=node_type, paren... | [
"0.5846435",
"0.580866",
"0.5758244",
"0.5750241",
"0.5644726",
"0.5593508",
"0.5569872",
"0.55670184",
"0.5320712",
"0.5294947",
"0.5276819",
"0.5257191",
"0.5233083",
"0.52096087",
"0.514865",
"0.514865",
"0.5127134",
"0.51208824",
"0.5117699",
"0.5039895",
"0.5018156",
"... | 0.6762166 | 0 |
Runs the robot Initializes all the variables needed for the application, calls for a plan, makes the behaviour tree and runs it. | def runRobot(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n\n # Set up environment and agent\n e = Environment() # create environment (also adds some dummy traffic)\n a = e.create_agent(LearningAgent) # create agent\n e.set_primary_agent(a, enforce_deadline= True ) # set agent to track\n\n # Now simulate it\n sim = Simulator(e, update_dela... | [
"0.71409136",
"0.7139036",
"0.6987785",
"0.6987306",
"0.69841075",
"0.6847667",
"0.67823875",
"0.67612064",
"0.67385036",
"0.6728832",
"0.67133343",
"0.67090654",
"0.6580082",
"0.65632033",
"0.6501628",
"0.64961094",
"0.64783174",
"0.6460529",
"0.6443476",
"0.63901764",
"0.63... | 0.7163699 | 0 |
Shutdown function for rospy Cancels all the goals given to move_base, stops the robot | def shutdown():
rospy.loginfo("Stopping the robot...")
global_vars.move_base.cancel_all_goals()
global_vars.cmd_vel_pub.publish(Twist())
rospy.sleep(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutdown(self):\n\t\trospy.loginfo(\"Stopping the robot...\")\n\t\tself.cmd_vel.publish(Twist())\n\t\trospy.sleep(1)",
"def shutdown(self):\n rospy.loginfo(\"Stopping Project\")\n rospy.sleep(1)",
"def shutdown(self):\n cv2.destroyAllWindows()\n rospy.loginfo(\"Stop\")\n # wait f... | [
"0.7312391",
"0.70726043",
"0.6825934",
"0.66775507",
"0.65933686",
"0.6475001",
"0.6448581",
"0.64221257",
"0.6396579",
"0.6386079",
"0.63841546",
"0.63747454",
"0.63605803",
"0.6359077",
"0.63532734",
"0.63455474",
"0.6325083",
"0.6286674",
"0.6286674",
"0.6286674",
"0.6286... | 0.8110793 | 0 |
gets the string representation of this cache item. | def __str__(self):
return 'CacheItem: [{key}-{value}]'.format(key=self._key, value=self._value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return str(self.item)",
"def __str__(self):\r\n return str(self._items)",
"def __str__(self):\r\n return str(self._items)",
"def __str__(self):\n return str(self._items)",
"def __str__(self):\n sio = StringIO()\n for k in self:\n sio... | [
"0.74889135",
"0.730028",
"0.730028",
"0.7283758",
"0.72216547",
"0.7142162",
"0.7127339",
"0.71139985",
"0.7080182",
"0.7080182",
"0.7080182",
"0.7035659",
"0.7030708",
"0.6975201",
"0.6967679",
"0.6949584",
"0.6948848",
"0.6948848",
"0.6939739",
"0.6932366",
"0.69174695",
... | 0.8231518 | 0 |
gets the cached value. it is intended to be overridden in subclasses. | def _get_cached_value(self, value):
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cached_value(self, value):\n\n if self._refreshable is True and self.is_expired is False:\n self.refresh()\n\n return deepcopy(value)",
"def value(self) -> Any:\n if self._value_cached is not None:\n return self._value_cached\n self._value_cached = self.... | [
"0.7799119",
"0.764737",
"0.752614",
"0.7508518",
"0.73872054",
"0.73817015",
"0.73647845",
"0.7306414",
"0.72809434",
"0.7271853",
"0.72630554",
"0.7256612",
"0.72316223",
"0.72316223",
"0.71943533",
"0.71513164",
"0.71259624",
"0.7089675",
"0.7021115",
"0.7005014",
"0.69937... | 0.854396 | 0 |
prepares value to be cached. it is intended to be overridden in subclasses. | def _prepare_cache(self, value):
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cached_value(self, value):\n\n return value",
"def _get_cached_value(self, value):\n\n if self._refreshable is True and self.is_expired is False:\n self.refresh()\n\n return deepcopy(value)",
"def _prepare_cache(self, value):\n\n return deepcopy(value)",
"def s... | [
"0.73523057",
"0.70580417",
"0.6872638",
"0.68010664",
"0.6271395",
"0.62071866",
"0.6176342",
"0.61380947",
"0.6068087",
"0.5973661",
"0.5972515",
"0.59407",
"0.5929409",
"0.59153795",
"0.57857066",
"0.576996",
"0.5768973",
"0.5756361",
"0.57486516",
"0.57405144",
"0.5739884... | 0.75677896 | 0 |
gets the cached value. | def _get_cached_value(self, value):
if self._refreshable is True and self.is_expired is False:
self.refresh()
return deepcopy(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_cached_value(self, value):\n\n return value",
"def get(key):\n return Cache.cache_connector.get(key)",
"def get(self, key):\n return self.cache_data.get(key)",
"def get_cache(self, key):\n return self.r.get(key)",
"def get(self, key):\n if key in self.cache:\n ... | [
"0.8474321",
"0.7811911",
"0.7775612",
"0.7767617",
"0.76671743",
"0.7648609",
"0.7535196",
"0.75289977",
"0.75075233",
"0.7494821",
"0.7490765",
"0.7490765",
"0.747118",
"0.7377791",
"0.7334462",
"0.72209233",
"0.7209859",
"0.7149562",
"0.71232504",
"0.7093771",
"0.70923954"... | 0.7819751 | 1 |
the administrator adds a new pathology | def save_new_pathology(self, request, pathology_name, zone,
vegetable_oil, essential_oil1,
essential_oil2, essential_oil3):
if Pathology.objects.filter(name=pathology_name).exists():
messages.error(request, "la pathologie existe")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_location():\n\n if not g.user:\n flash(\"Please login to access\", \"danger\")\n return redirect(\"/\")\n \n if g.user.is_admin == False:\n flash (\"Unauthorized\", \"danger\")\n return redirect(\"/login\")\n \n form = Location_Form()\n\n if form.validate_on_su... | [
"0.59666294",
"0.57213724",
"0.56700027",
"0.53929853",
"0.53479624",
"0.5333595",
"0.5325051",
"0.52315253",
"0.52217925",
"0.5212629",
"0.5207334",
"0.5200829",
"0.51908076",
"0.5179957",
"0.5169304",
"0.5168064",
"0.5133272",
"0.51280755",
"0.5124735",
"0.5122166",
"0.5100... | 0.71392554 | 0 |
Returns the test run status name given the outcome and marginal args. | def _measurement_outcome_to_test_run_status_name(outcome: measurements.Outcome,
marginal: bool) -> str:
return ('MARGINAL_PASS'
if marginal else MEASUREMENT_OUTCOME_TO_TEST_RUN_STATUS_NAME[outcome]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test_run_status_name_to_measurement_outcome_and_marginal(\n name: str) -> Tuple[measurements.Outcome, bool]:\n return TEST_RUN_STATUS_NAME_TO_MEASUREMENT_OUTCOME[name], 'MARGINAL' in name",
"def get_test_outcome(outcome):\n return PYTEST_TO_TESTRAIL_STATUS[outcome]",
"def outcome_string(outcome):\r... | [
"0.72438514",
"0.6721773",
"0.6460381",
"0.62691253",
"0.6109823",
"0.5718859",
"0.564338",
"0.5613157",
"0.5607453",
"0.55998284",
"0.5524718",
"0.5430438",
"0.5346939",
"0.5333566",
"0.53230983",
"0.5322826",
"0.53128666",
"0.5300884",
"0.527742",
"0.52624595",
"0.5246134",... | 0.8378723 | 0 |
Returns the outcome and marginal args given the test run status name. | def _test_run_status_name_to_measurement_outcome_and_marginal(
name: str) -> Tuple[measurements.Outcome, bool]:
return TEST_RUN_STATUS_NAME_TO_MEASUREMENT_OUTCOME[name], 'MARGINAL' in name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _measurement_outcome_to_test_run_status_name(outcome: measurements.Outcome,\n marginal: bool) -> str:\n return ('MARGINAL_PASS'\n if marginal else MEASUREMENT_OUTCOME_TO_TEST_RUN_STATUS_NAME[outcome])",
"def get_status_cmd_args(self):\r\n retur... | [
"0.66902375",
"0.59399647",
"0.57447547",
"0.5450125",
"0.54283667",
"0.53478825",
"0.533082",
"0.5327453",
"0.5282185",
"0.5273283",
"0.52266145",
"0.5218727",
"0.5218227",
"0.5200822",
"0.5190498",
"0.51495296",
"0.5123641",
"0.5122203",
"0.5120503",
"0.5118654",
"0.5108743... | 0.69326115 | 0 |
Populate dict of units by code iff UNITS_BY_CODE is empty. | def _lazy_load_units_by_code():
if UNITS_BY_CODE:
# already populated
return
for unit in units.UNITS_BY_NAME.values():
UNITS_BY_CODE[unit.code] = unit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_results_dict(fr_codes):\r\n \r\n res_dict = {}\r\n for k,v in fr_codes.items():\r\n res_dict[v] = 0\r\n \r\n return res_dict",
"def get_unit_map(self):\n units = dict()\n for t in META:\n for c in META[t]:\n for i in META[t][c]:\n ... | [
"0.5603126",
"0.5337711",
"0.5094251",
"0.508921",
"0.504245",
"0.48573163",
"0.4834563",
"0.4782013",
"0.4774707",
"0.476743",
"0.4766414",
"0.47527552",
"0.4719702",
"0.46092945",
"0.46032363",
"0.45835316",
"0.45801938",
"0.45299393",
"0.45222956",
"0.44630036",
"0.4442852... | 0.82740927 | 0 |
Convert an OpenHTF TestRecord to an MfgEvent proto. Most fields are copied over directly and some are pulled out of metadata (listed below). Multidimensional measurements are stored only in the JSON dump of the record. | def mfg_event_from_test_record(
record: htf_test_record.TestRecord,
attachment_cache: Optional[AttachmentCacheT] = None,
) -> mfg_event_pb2.MfgEvent:
mfg_event = mfg_event_pb2.MfgEvent()
_populate_basic_data(mfg_event, record)
_attach_record_as_json(mfg_event, record)
_attach_argv(mfg_event)
_attach_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _populate_basic_data(mfg_event: mfg_event_pb2.MfgEvent,\n record: htf_test_record.TestRecord) -> None:\n # TODO(openhtf-team):\n # * Missing in proto: set run name from metadata.\n # * `part_tags` field on proto is unused\n # * `timings` field on proto is unused.\n # * Hand... | [
"0.7340775",
"0.6667909",
"0.6549148",
"0.5736281",
"0.57038325",
"0.5535558",
"0.54890156",
"0.5474751",
"0.5380055",
"0.5356222",
"0.5277961",
"0.5199769",
"0.51934624",
"0.5189531",
"0.516178",
"0.5153152",
"0.51446366",
"0.5129921",
"0.51214886",
"0.51074195",
"0.5080802"... | 0.6952815 | 1 |
Copies data from the OpenHTF TestRecord to the MfgEvent proto. | def _populate_basic_data(mfg_event: mfg_event_pb2.MfgEvent,
record: htf_test_record.TestRecord) -> None:
# TODO(openhtf-team):
# * Missing in proto: set run name from metadata.
# * `part_tags` field on proto is unused
# * `timings` field on proto is unused.
# * Handle arbitrar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _copy_attachment(self, name, data, mimetype, mfg_event):\n attachment = mfg_event.attachment.add()\n attachment.name = name\n attachment.value_binary = data\n if mimetype in test_runs_converter.MIMETYPE_MAP:\n attachment.type = test_runs_converter.MIMETYPE_MAP[mimetype]\n elif mimetype == t... | [
"0.59818894",
"0.5833238",
"0.57654357",
"0.5740569",
"0.570361",
"0.5694899",
"0.5657889",
"0.5577725",
"0.54895407",
"0.5373589",
"0.53671736",
"0.53190356",
"0.53156585",
"0.52705157",
"0.5197876",
"0.5197516",
"0.51928586",
"0.5190057",
"0.5175267",
"0.51428556",
"0.51388... | 0.7525545 | 0 |
Attach a copy of the record as JSON so we have an unmangled copy. | def _attach_record_as_json(mfg_event, record):
attachment = mfg_event.attachment.add()
attachment.name = TEST_RECORD_ATTACHMENT_NAME
test_record_dict = htf_data.convert_to_base_types(record)
attachment.value_binary = _convert_object_to_json(test_record_dict)
attachment.type = test_runs_pb2.TEXT_UTF8 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _jsonify(self):\n return self.experiment_record.to_ddb_record()",
"def encode_record(record):\n return json.dumps(record)",
"def serialize_to_json(self, record, pretty=False):\n return self._json_serializer.to_json(record)",
"def to_json(self, record: Mapping[str, Any]) -> str:\n ... | [
"0.64197916",
"0.6271602",
"0.62554306",
"0.62538844",
"0.616609",
"0.59119684",
"0.5905489",
"0.5893929",
"0.58342296",
"0.5789882",
"0.57281804",
"0.56270313",
"0.559412",
"0.5588478",
"0.55728716",
"0.5551583",
"0.5551583",
"0.5475389",
"0.542358",
"0.53990954",
"0.5383139... | 0.6540382 | 0 |
Makes the names of phase measurement and attachments unique. This function will make the names of measurements and attachments unique. It modifies the input all_phases. | def phase_uniquizer(all_phases):
measurement_name_maker = UniqueNameMaker(
itertools.chain.from_iterable(
phase.measurements.keys() for phase in all_phases
if phase.measurements))
attachment_names = list(itertools.chain.from_iterable(
phase.attachments.keys() for phase in all_phases)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_names_unique(animations):\n counts = {}\n for a in animations:\n c = counts.get(a['name'], 0) + 1\n counts[a['name']] = c\n if c > 1:\n a['name'] += '_' + str(c - 1)\n\n dupes = set(k for k, v in counts.items() if v > 1)\n for a in animations:\n if a['na... | [
"0.64196336",
"0.5934985",
"0.554763",
"0.55056745",
"0.53984594",
"0.5367987",
"0.5249584",
"0.52124804",
"0.50584024",
"0.49809545",
"0.49367014",
"0.49135208",
"0.4910912",
"0.4910722",
"0.48929605",
"0.48702845",
"0.48270914",
"0.47974837",
"0.47963843",
"0.47960886",
"0.... | 0.8443444 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.