query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
Stores to new versions after updating | def updateVersions(self):
f = open('../versions.pckl', 'wb')
pickle.dump(self.versions, f)
f.close() | [
"def update_version(self, version):",
"def update_store_version(self, current_version):\n raise NotImplementedError('update_store_version must be replaced when subclassed')",
"def save_last_version(sender, instance, *args, **kwargs):\n if instance._StrataCustomerStack__version is not None:\n in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the grafana.db fail to display updates dashboards | def updateGrafana(self, data):
try:
if "version" not in self.versions["grafana"] or self.mission_name + "_" + data["grafana"]["version"] != self.versions["grafana"]["version"]:
downloadAndReplaceFile(self.config.get_conf("Client", "grafana-database"), data["grafana"]["link"])
... | [
"def test_dashboards_v2_update(self):\n pass",
"def test_dashboard_update_dashboard(self):\n pass",
"def test_dashboard_partially_update_dashboard(self):\n pass",
"def test_update_dashboard(self):\n pass",
"def grafana_dashboard_check(name, dashboard):\n if dashboard[\"id\"] i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the subsystems files to respond to changes in packet configuration | def updateSubSystems(self, data):
current_subsystems_files = {}
for subsystems_filename in self.versions["subsystems"]:
current_subsystems_files[subsystems_filename] = self.versions["subsystems"][subsystems_filename]
for subsystems_filename in data["subsystems"]:
... | [
"def updateconfig(self):\n\n # Initialize the yaml data\n ydata = {\"metadata\": self._metadata, \"nodes\": self._nodes}\n\n # Write the system config file\n filename = self._rootdir + self._metadata[\"system_config_file\"]\n with open(filename, \"w\") as yamlfile:\n ya... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a function that dispatches to dask for dask array inputs. | def _dask_or_eager_func(name, eager_module=np, list_of_args=False, n_array_args=1):
if has_dask:
def f(*args, **kwargs):
dispatch_args = args[0] if list_of_args else args
if any(isinstance(a, dsa.Array) for a in dispatch_args[:n_array_args]):
module = dsa
... | [
"def gnumpy_func_wrap(f):\n def inner(*args):\n args = garray_to_cudandarray_nested(args)\n res = f(*args)\n if isinstance(res, list):\n res = cudandarray_to_garray_nested(res)\n else:\n # TODO: check for CudaNdArray instance instead\n if not isinstanc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Supply boundary conditions for an xarray.DataArray da according along the specified dimension. Returns a raw dask or numpy array, depending on the underlying data. | def _apply_boundary_condition(da, dim, left, boundary=None, fill_value=0.0):
if boundary not in ["fill", "extend", "extrapolate"]:
raise ValueError(
"`boundary` must be 'fill', 'extend' or "
"'extrapolate', not %r." % boundary
)
axis_num = da.get_axis_num(dim)
# th... | [
"def _last_item_cond_true(cond, dim):\n # force DataArray because isel (when transforming to dim space) requires DataArray\n if isinstance(cond, xr.Dataset):\n was_dataset = True\n cond = cond.to_array()\n else:\n was_dataset = False\n # index last True\n reached = cond.argmin(di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pad an xarray.DataArray da according to the boundary conditions along dim. Return a raw dask or numpy array, depending on the underlying data. | def _pad_array(da, dim, left=False, boundary=None, fill_value=0.0):
if boundary not in ["fill", "extend"]:
raise ValueError("`boundary` must be `'fill'` or `'extend'`")
axis_num = da.get_axis_num(dim)
shape = list(da.shape)
shape[axis_num] = 1
base_array = da.data
index = slice(0, 1) ... | [
"def _pad_or_trim(self, array, axis=-1):\n if array.shape[axis] > self._n_samples:\n array = array.index_select(\n dim=axis,\n index=torch.arange(self._n_samples, device=array.device),\n )\n\n if array.shape[axis] < self._n_samples:\n pad_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function monitors IP traffic in real time using Scapy's sniff function. If an exception occurres it will run again in 5 seconds. | def run_ip_traffic_monitor(db_connection, net_interfaces, device_id, agent_ip):
while 1:
try:
arp_traffic_out = sniff(prn = ip_monitoring_callback(db_connection, net_interfaces, device_id, agent_ip), filter = "ip", store = 0);
except:
utc_time_now = str(datetime.utcnow())
print('[' + utc_ti... | [
"def run_forever(self):\n scapy.sniff(prn=self.arp_cb, filter=\"arp\", store=0, count=0)",
"def sniff_online(args):\n print('viewer: listening on ' + args.interface)\n\n try:\n sniffer = pcapy.open_live(args.interface, 65536, 1, 1)\n sniffer.setfilter('icmp')\n except Exception as e:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function monitors IP traffic in real time using Scapy's sniff function and result stores in the sqlite3 database. | def ip_monitoring_callback(db_connection, net_interfaces, device_id, host_ip):
# For example, if 10.2.x.x talks to 10.1.x.x that is fine.
subnet_ip_list = []
for data in net_interfaces:
local_ip = data['ip']
local_ip = local_ip.split('.')
subnet_ip_list.append(str(local_ip[0]))
host_parts = host_i... | [
"def run_ip_traffic_monitor(db_connection, net_interfaces, device_id, agent_ip):\n\n while 1:\n try:\n arp_traffic_out = sniff(prn = ip_monitoring_callback(db_connection, net_interfaces, device_id, agent_ip), filter = \"ip\", store = 0);\n except:\n utc_time_now = str(datetime.utcnow())\n prin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prettyprinter for dumping this variable to _file | def prettyprint(self, _file):
xstr = "var " + self.name + " " + self.type.desc()
_file.write(xstr + "\n") | [
"def prettyprint(self, _file):\n xstr = \"reg \" + self.name + \" \" + self.type.desc()\n _file.write(xstr + \"\\n\")",
"def prettyprint(self, _file):\n _file.write(\"Function %s returns %s\\n\" % (self.name, self.returnType))\n _file.write(\" local vars\\n\")\n for val in self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prettyprinter for dumping this register to _file | def prettyprint(self, _file):
xstr = "reg " + self.name + " " + self.type.desc()
_file.write(xstr + "\n") | [
"def prettyprint(self, _file):\n xstr = \"var \" + self.name + \" \" + self.type.desc()\n _file.write(xstr + \"\\n\")",
"def prettyprint(self, _file):\n _file.write(\"Function %s returns %s\\n\" % (self.name, self.returnType))\n _file.write(\" local vars\\n\")\n for val in self.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generate new, unused label | def genLabel(self):
self._nextlabelid += 1
return CLABEL(self._nextlabelid) | [
"def _unused_label(self, label):\n original = label\n existing = self.column_labels\n i = 2\n while label in existing:\n label = '{}_{}'.format(original, i)\n i += 1\n return label",
"def new_label(self):\n self.label_nr += 1\n return \".LDBG_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates new, globally unique virtual register and returns it | def getFreeVirtReg(self, function, _type: common.Type):
while True:
name = "$R"+str(self._nextvregid)
self._nextvregid += 1
if not name in self._used_names:
break
reg = VirtualRegister(name, _type)
self._used_names.add(name)
function.ad... | [
"def register(self):\n pass",
"def register(self):\n raise NotImplementedError(\"Should have implemented this\")",
"def register(blk):\n pass",
"def reg(context: Any) -> Registry:\n return context.registry",
"def test_create_anonymous_classical_register(self):\n cr = Classical... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
inserts otherinstr before this instruction in this instruction's owner | def insertBefore(self, otherinstr):
# pylint: disable=protected-access
assert isinstance(otherinstr, ICode)
if self.__prev is None:
self.__prev = otherinstr
otherinstr.__next = self
otherinstr.owner = self.owner
self.owner._firstInstr = otherinstr
... | [
"def insertAfter(self, otherinstr):\n # pylint: disable=protected-access\n assert isinstance(otherinstr, ICode)\n if self.__next is None:\n self.__next = otherinstr\n otherinstr.__prev = self\n otherinstr.owner = self.owner\n self.owner._lastInstr = o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
inserts otherinstr after this instruction in this instruction's owner | def insertAfter(self, otherinstr):
# pylint: disable=protected-access
assert isinstance(otherinstr, ICode)
if self.__next is None:
self.__next = otherinstr
otherinstr.__prev = self
otherinstr.owner = self.owner
self.owner._lastInstr = otherinstr
... | [
"def insertBefore(self, otherinstr):\n # pylint: disable=protected-access\n assert isinstance(otherinstr, ICode)\n if self.__prev is None:\n self.__prev = otherinstr\n otherinstr.__next = self\n otherinstr.owner = self.owner\n self.owner._firstInstr =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
removes this instruction from this instruction's owner | def remove(self):
# pylint: disable=protected-access
if self.__next is None and self.__prev is None:
self.owner._firstInstr = self.owner._lastInstr = None
elif self.__next is None:
self.owner._lastInstr = self.__prev
self.__prev.__next = None
elif self... | [
"def removeInstruction(self, instruction: ghidra.program.model.listing.Instruction) -> None:\n ...",
"def remove_from_hand(self):\n pass",
"def remove(self):\n if self.basic_block is None:\n if self not in self.module.global_insts:\n raise IRError('Instruction is n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a list of operands read in this instruction | def getOperandsRead(self):
# pylint: disable=no-self-use
return [] | [
"def operands(self):\n if self._operands is None:\n self.generate_instruction_parts()\n return self._operands",
"def operands(self):\r\n return [_make_value(self._ptr.getOperand(i))\r\n for i in range(self.operand_count)]",
"def getOperands(self):\n\t\treturn [self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a list of operands written in this instruction | def getOperandsWritten(self):
# pylint: disable=no-self-use
return [] | [
"def operands(self):\n if self._operands is None:\n self.generate_instruction_parts()\n return self._operands",
"def operands(self):\r\n return [_make_value(self._ptr.getOperand(i))\r\n for i in range(self.operand_count)]",
"def getOperands(self):\n\t\treturn [self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a reverseiterator over the instructions of this function | def instrsreversed(self):
x = self._lastInstr
while x is not None:
# now we can remove x and continue iterating :)
x_prev = x.prev
yield x
x = x_prev | [
"def instructions_reversed(self):\n for function in reversed(self.functions[:]):\n for inst in function.instructions_reversed():\n yield inst\n for inst in reversed(self.global_insts[:]):\n yield inst",
"def instructions_reversed(self):\n yield self.end_in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prettyprinter for dumping this function to _file | def prettyprint(self, _file):
_file.write("Function %s returns %s\n" % (self.name, self.returnType))
_file.write(" local vars\n")
for val in self.vars.values():
_file.write(" ")
val.prettyprint(_file)
_file.write(" params\n")
for val in self.params.values... | [
"def _pretty_print(arg, p, cycle):\n p.text(stringify_func(arg))",
"def prettyprint(self, _file):\n xstr = \"reg \" + self.name + \" \" + self.type.desc()\n _file.write(xstr + \"\\n\")",
"def prettyprint(self, _file):\n xstr = \"var \" + self.name + \" \" + self.type.desc()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Draws lines on the board, the first and last lines are not drawn because these lines are the ends of the screen | def draw_lines(self):
for x_cord in range(0, Dimension.SCREEN_WIDTH.value, Dimension.SQUARE_WIDTH.value):
pg.draw.line(self.window, Colors.BLACK.value, (x_cord, 0), (x_cord, Dimension.SCREEN_HEIGHT.value))
for y_cord in range(0, Dimension.SCREEN_HEIGHT.value, Dimension.SQUARE_HEIGHT.value):... | [
"def draw_lines(self):\n # draw x lines\n y = self.step_y\n while y <= self.height:\n x = 0\n while x <= self.width:\n self.canvas.create_line(x, y, x+3.5, y)\n self.canvas.update()\n x += 3.5\n y += self.step_y\n \n # draw y lines\n x = self.step_x\n while x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obstacles created by self.create_obstacles are drawn on self.windows as a black rectangles. | def draw_obstacles(self):
for obstacle in self.obstacles:
obstacle.draw(self.window, Colors.BLACK.value) | [
"def __draw_obstacles(self):\n self.canvas.delete(OBSTACLES_TAG)\n for i in range(0, PACMAN_BOARD_SIDE_SQUARES_NUMBER):\n for j in range(0, PACMAN_BOARD_SIDE_SQUARES_NUMBER):\n if self.board[j][i] == 1:\n self.canvas.create_rectangle(\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function creates from 1 to 10 obstacles with random coordinates. The self.matrix is modified to reflect the changes to on the board | def create_obstacles(self) -> List[Square]:
obstacles_number = random.randint(1, self.maximum_obstacles_on_board)
obstacles = list()
while len(obstacles) < obstacles_number:
obstacle_x_pos = random.randint(0, Dimension.board_width() - 1)
obstacle_y_pos = random.randint(... | [
"def recreate_obstacles(self):\n self.board_matrix = np.full(Dimension.board_size(), 1)\n self.obstacles = self.create_obstacles()",
"def create_obstacles(self):\n if self.mode == 'simple':\n self.obstacles.append(Obstacle((300, 400), 400, 20))\n elif self.mode == 'medium':\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if clicked square is not obstacle and it's possible to start/end path here. | def is_square_empty(self, clicked_square: Square) -> bool:
return clicked_square not in self.obstacles | [
"def is_obstacle(self, x, y, l):\n return self.at(x, y, l).cost == -1",
"def isObstacle(self, x, y):\n point = Point(x, y)\n isObst = False\n id = 0\n\n while not isObst and id<len(self.shapes):\n if self.shapes[id] != self.rect:\n isObst = point.contai... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates new state of board with different number of obstacles and their positions. | def recreate_obstacles(self):
self.board_matrix = np.full(Dimension.board_size(), 1)
self.obstacles = self.create_obstacles() | [
"def new_board():\n board = Board()\n for idx, troop in enumerate(STARTING_BOARD[0]):\n board[Position(idx + 1, 'A')] = Piece(troop, Color.White)\n board[Position(idx + 1, 'I')] = Piece(troop, Color.Black)\n for idx, troop in enumerate(STARTING_BOARD[1]):\n board[Position(idx + 1, 'B')... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
`check_for_fit` wraps a method that validates if `self._is_fitted` is `True`. It raises an exception if `False` and calls and returns the wrapped method if `True`. | def check_for_fit(cls, method):
@wraps(method)
def _check_for_fit(self, X=None, y=None):
klass = type(self).__name__
if not self._is_fitted and self.needs_fitting:
raise ComponentNotYetFittedError(
f"This {klass} is not fitted yet. You must fi... | [
"def check_for_fit(cls, method):\n\n @wraps(method)\n def _check_for_fit(self, *args, **kwargs):\n klass = type(self).__name__\n if not self._is_fitted:\n raise PipelineNotYetFittedError(\n f\"This {klass} is not fitted yet. You must fit {klass} ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obtains max statelevel fuel price | def get_max_fp(state_abbr, fuel_type="NG", year=False):
if(not year):
year = UpdateParams.today.year
if fuel_type.upper() == "NG":
series_ID = "NG.N3035" + state_abbr + "3.A"
elif fuel_type.upper() == "COAL":
series_ID = "COAL.COST." + state_abbr... | [
"def state_max(self) -> float:\n raise NotImplementedError",
"def max_price(self):\n return self._max_price",
"def __find_max_price(self):\n prices_map = map(\n lambda iceberg: utils.get_actual_penguin_amount(\n self.__game, iceberg),\n self.__game.get_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Grabs fuel esc from EERC | def get_esc(state_abbr, fuel_type="NG"):
temp_dict = {"NG": "Natural Gas", "COAL" : "Coal", "PETRO": "Residual"}
return UpdateParams.eerc_esc.loc[state_abbr, temp_dict[fuel_type]] | [
"def test_parse_e_elect(self):\n path = os.path.join(ARC_PATH, 'arc', 'testing', 'sp', 'mehylamine_CCSD(T).out')\n e_elect = parser.parse_e_elect(path)\n self.assertAlmostEqual(e_elect, -251377.49160993524)\n\n path = os.path.join(ARC_PATH, 'arc', 'testing', 'composite', 'SO2OO_CBS-QB3.l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return date of next car, according to given schedule. Schedule is considered as a list of Horaire objects, that represent when a car (or tram) arrives to a stop. travel_time input must be a Horaire object. Returned value is the index of next car in schedule. (so, access to schedule[returned_value] give the Horaire obje... | def next_car(schedule, travel_time):
#travel_time = datetime.datetime.strptime(datetime.datetime.strptime(travel_time, '%Y-%m-%d %H:%M:%S').strftime('%H:%M:%S'), '%H:%M:%S')
next_time = None
for index, time in enumerate(schedule):
if time.is_after(travel_time):
next_time = index
... | [
"def get_next_occurrence(self, start, time):\n d = datetime.datetime.combine(start, time)\n if d < start:\n d += datetime.timedelta(days=1)\n return d.astimezone(self.time_zone)",
"def test_get_next_competition():\n result = schedule.get_next_competition()\n\n if result:\n assert result... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return the dir url | def get_dirurl(self, dirpath):
paths = dirpath.split("/")
return "/".join(paths[paths.index("static"):]) | [
"def dir_url_bit(self):\r\n url = []\r\n if self.predir:\r\n url.append(self.predir.lower())\r\n if self.postdir:\r\n url.extend(['-', self.postdir.lower()])\r\n return ''.join(url)",
"def Directory(self) -> str:",
"def _get_dir_url(endpoint, path, **kwargs):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
filter to return font files only | def filter_fontfiles(self, filenames, d=dict()):
for f in filenames:
n, ext = os.path.splitext(f)
# skip for the files that are not supported
if not ext in SUPPORTED_FONTS: continue
d[n] = d[n] + [ext] if d.get(n) else [ext]
return d | [
"def _GetFontFiles(path):\n return [f for f in listdir(path)\n if os.path.splitext(f)[1] in ('.ttf', '.otf')]",
"def load_all_fonts(directory, accept=(\".ttf\", '.otf')):\r\n return load_all_music(directory, accept)",
"def load_all_fonts(directory, accept=(\".ttf\",)):\n return load_all_music(di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests the home page. | def test_home(self):
response = self.client.get('/')
self.assertContains(response, 'Home Page', 1, 200) | [
"def test_home(self):\n\t\tresponse = self.client.get('/')\n\t\tself.assertContains(response, 'Home Page', 1, 200)",
"def test_home(self):\n\n response = self.client.get(reverse('home'))\n\n assert response.status_code == 200",
"def test_home(self):\n response = self.app.get(\"/\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return callback for LoadLibraryA | def LoadLibraryA_rtn_handler(exec_ctx):
logging.info("kernel32.dll.LoadLibraryA returned 0x%08x" % \
exec_ctx.regs.EAX)
# TODO: check / update list of hooks also
pybox.MODULES.update()
return | [
"def load(self):\n\n # If internal library is already loaded, skip\n if self._lib is not None and self._lib.value is not None:\n return\n self._stub = ctypes.CDLL(self._stub_filename)\n\n # Set return types of stub functions\n self._stub.load_library.restype = ctypes.c_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search for the provided account address in KV 'History of Accounts' table. | def kv_seek_account_history(account_address: str, block_number: int, target: str = DEFAULT_TARGET):
account_history_key = kv_metadata.encode_account_history_key(account_address, block_number)
print('REQ1 account_address:', account_address, '(key: ' + str(account_history_key.hex()) + ')')
print('RSP1 accou... | [
"def get_by_address(self, address):\n assert len(address) == 20\n accounts = [account for account in self.accounts if account.address == address]\n if len(accounts) == 0:\n raise KeyError('account with address {} not found'.format(encode_hex(address)))\n elif len(accounts) > 1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if "console.getData()" JS command returns some error. If so, the test will fail. | def _checkJSErrors(self):
js_error = False
console_data = []
try:
console_data = self.driver.execute_script("return console.getData()")
except:
pass
if console_data:
for item in console_data:
if item["type"] == "error":
... | [
"def test_get_data_fail(self):\n self.assertIsNone(get_data('this_must_fail', 5, 0))",
"def test_command(self):\n out = io.StringIO()\n management.call_command('import_data', stdout=out)\n self.assertIn(\"Successfully imported\", out.getvalue())",
"def test_commandRecievesRequestedDa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Some special settings for IE to make the browser more stable. | def _finetuneIE(self):
# start IE in private mode to prevent storing cookies
self._browser_capabilities["ie.forceCreateProcessApi"] = 1
self._browser_capabilities["ie.browserCommandLineSwitches"] = "-private"
# seems not reliable. More testing needed.
#self._browser_capabilitie... | [
"def test_msieParser(self):\n agent = UserAgent.fromHeaderValue(\n 'Mozilla/4.0 (compatible; MSIE 4.5; Windows 98; Win 9x 4.8410008)')\n self.assertEqual(agent.browser, browsers.INTERNET_EXPLORER)",
"def browserOptions(self):\n return (True,False)",
"def add_header(response):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates indices for a mini_batch, given an iteration state and number of data points in a batch. | def BatchCreator(self, j, n_batch):
j_start = (j-1)*n_batch + 1
j_end = j*n_batch + 1
ind = np.arange(start= j_start, stop=j_end, step=1)
return ind | [
"def compute_batch_indices(batch_size: int, beam_size: int) ->torch.LongTensor:\n batch_pos = torch.arange(batch_size)\n batch_pos = batch_pos.view(-1, 1).expand(batch_size, beam_size)\n return batch_pos",
"def batch_indices(self):\n b = self.batch_size\n return [np.arange(i*b, i*b+b) for i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the version of the userandjobstate service. | def ver(self, context=None):
return self._client.call_method(
'UserAndJobState.ver',
[], self._service_ver, context) | [
"def version(self):\n response = self._request_call('/version')\n return response.version_etcdserver",
"def service_version_log(self):\n return self.service_version",
"def version():\n version_info = pbr.version.VersionInfo('ardana-service')\n return version_info.version_string_with_v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the state of a key for a service without service authentication. | def set_state(self, service, key, value, context=None):
return self._client.call_method(
'UserAndJobState.set_state',
[service, key, value], self._service_ver, context) | [
"async def set_appservice_state(\n self, service: ApplicationService, state: ApplicationServiceState\n ) -> None:\n await self.db_pool.simple_upsert(\n \"application_services_state\", {\"as_id\": service.id}, {\"state\": state.value}\n )",
"def set_key(self, key):\r\n sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the state of a key for a service with service authentication. | def set_state_auth(self, token, key, value, context=None):
return self._client.call_method(
'UserAndJobState.set_state_auth',
[token, key, value], self._service_ver, context) | [
"def set_state(self, service, key, value, context=None):\n return self._client.call_method(\n 'UserAndJobState.set_state',\n [service, key, value], self._service_ver, context)",
"async def set_appservice_state(\n self, service: ApplicationService, state: ApplicationServiceState... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new job status report. create_job2 | def create_job(self, context=None):
return self._client.call_method(
'UserAndJobState.create_job',
[], self._service_ver, context) | [
"def gen_batch_status(config, tenant, report, iteration=\"hourly\", user=None, mongo_method=\"insert\"):\n description = \"{}:{} {} Status\".format(tenant, report, iteration)\n\n if iteration == \"daily\":\n # generate a daily job\n cron_prefix = get_daily(DAILY_HOUR, HOURLY_MIN)\n # dail... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the status and progress for a job. | def update_job_progress(self, job, token, status, prog, est_complete, context=None):
return self._client.call_method(
'UserAndJobState.update_job_progress',
[job, token, status, prog, est_complete], self._service_ver, context) | [
"def update(self) -> None:\n self.previous_status = self.status\n\n jobs = self._client.describe_jobs(jobs = [ self.id ])[\"jobs\"]\n\n try:\n self.state = jobs[0]\n except IndexError:\n raise ValueError(\"Invalid or unknown job id %s\" % self.id) from None",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the description of a job. | def get_job_description(self, job, context=None):
return self._client.call_method(
'UserAndJobState.get_job_description',
[job], self._service_ver, context) | [
"def job_description(self):\n return self._job_description",
"def job_detail(self, job):\n url = self.endpoints['job'] + job\n request = requests.get(url, headers=self.request_headers)\n job = request.json()\n return job",
"def describe_labeling_job(LabelingJobName=None):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the status of a job. | def get_job_status(self, job, context=None):
return self._client.call_method(
'UserAndJobState.get_job_status',
[job], self._service_ver, context) | [
"def job_status(self, job_id):\n return self.api_client.job(job_id).status()",
"def get_status(self):\n\t\treturn call_sdk_function('PrlJob_GetStatus', self.handle)",
"def get_status(job_id):\n job = fetch_data.AsyncResult(job_id, app=app)\n return jsonify({'job_id': job_id, 'status': job.status})"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List jobs. Leave 'services' empty or null to list jobs from all services. list_jobs2 | def list_jobs(self, services, filter, context=None):
return self._client.call_method(
'UserAndJobState.list_jobs',
[services, filter], self._service_ver, context) | [
"def list_job_services(self, context=None):\n return self._client.call_method(\n 'UserAndJobState.list_job_services',\n [], self._service_ver, context)",
"def list():\n\treturn _jobs.all()",
"def list_jobs(self):\n jobs = []\n services = {}\n recent = []\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List all job services. Note that only services with jobs owned by the user or shared with the user via the default auth strategy will be listed. | def list_job_services(self, context=None):
return self._client.call_method(
'UserAndJobState.list_job_services',
[], self._service_ver, context) | [
"def list(self):\n\n for job_name in self.upstart.get_all_jobs():\n yield self.get_service(job_name)",
"def list_services(self, request):\n return self._list(request, None, u\"services\")",
"def list_jobs(self, services, filter, context=None):\n return self._client.call_metho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Share a job. Sharing a job to the same user twice or with the job owner has no effect. Attempting to share a job not using the default auth strategy will fail. | def share_job(self, job, users, context=None):
return self._client.call_method(
'UserAndJobState.share_job',
[job, users], self._service_ver, context) | [
"def share(self, user, name):\n raise NotImplementedError",
"def _share_model(job_id, entity_ids, permission_level, entity_type,\n client=None, **kwargs):\n client = client or APIClient()\n if entity_type not in ['groups', 'users']:\n raise ValueError(\"'entity_type' must be on... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stop sharing a job. Removing sharing from a user that the job is not shared with or the job owner has no effect. Attemping to unshare a job not using the default auth strategy will fail. | def unshare_job(self, job, users, context=None):
return self._client.call_method(
'UserAndJobState.unshare_job',
[job, users], self._service_ver, context) | [
"def stopSharingNote(self, authenticationToken, guid):\r\n pass",
"def stopSharingNote(self, authenticationToken, guid):\r\n self.send_stopSharingNote(authenticationToken, guid)\r\n self.recv_stopSharingNote()",
"def _unshare_model(job_id, entity_id, entity_type, client=None):\n client = client or A... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the owner of a job. | def get_job_owner(self, job, context=None):
return self._client.call_method(
'UserAndJobState.get_job_owner',
[job], self._service_ver, context) | [
"def owner(self):\n self._update()\n return self._job[\"owner\"]",
"def job_owner(self) -> Optional[str]:\n if self.job_build:\n owner = self.job_build.metadata.get(\"owner\")\n if owner:\n return owner\n\n return self.api.copr_helper.copr_client.co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete a job. Will fail if the job is not complete. Only the job owner can delete a job. | def delete_job(self, job, context=None):
return self._client.call_method(
'UserAndJobState.delete_job',
[job], self._service_ver, context) | [
"def delete_job(jobId=None, force=None):\n pass",
"def delete_job(context, job_id=None):\n endpoint = job_endpoint(context, job_id)\n context.response = requests.delete(endpoint)",
"def delete_job(self, job):\n subprocess.call(self.cli + [PlatformJenkinsJavaCLI.DELETE_JOB, job.name])",
"def de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Force delete a job will succeed unless the job has not been started. In that case, the service must start the job and then delete it, since a job is not "owned" by any service until it is started. Only the job owner can delete a job. | def force_delete_job(self, token, job, context=None):
return self._client.call_method(
'UserAndJobState.force_delete_job',
[token, job], self._service_ver, context) | [
"def delete_job(jobId=None, force=None):\n pass",
"def _delete_job(self, job):",
"def _delete_job(self, job):\n if self.jenkins.job_exists(job):\n self.jenkins.delete_job(job)",
"def delete(self):\n self._server.delete_job(self.name)",
"def delete_job(context, job_id=None):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a UserConfig object from an environment variable. | def load_from_env_var(cls, env_var):
return cls.load_from_filename(os.environ.get(env_var)) | [
"def get_user_env(swift, container_name):\n return yaml.safe_load(\n swiftutils.get_object_string(swift, container_name,\n constants.USER_ENVIRONMENT))",
"def from_env():\n environment = os.getenv('APP_ENV', 'TEST')\n\n return ConfigurationFactory.get_co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse some extra information out of the bibtex database so that we can include it in the webpage. | def extra_bibparse(db):
for key,entry in db.entries.items():
for auth in entry.persons["author"]:
if ("Harrison" not in auth.first_names or
"Chapman" not in auth.last_names):
entry.add_person(auth, "otherauthor") | [
"def extract(page):\n # data.find_all(href=re.compile(\"book/index.php\\?md5=\"))\n # for i, data in enumerate():\n # book['id'] = i\n # book['author'] = None\n # book['title'] = None\n # book['publisher'] = None\n # book['year'] = None\n # book['pages'] = None\n # book['lang'] = None\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calculate sane rectangular coordinates inside the axis limits | def sane_rect_coord(ax, xperc=[0.1, 0.4], yperc=[0.1, 0.9]):
xlim = ax.get_xlim()
ylim = ax.get_ylim()
xdist = xlim[1] - xlim[0]
ydist = ylim[1] - ylim[0]
xs = [xlim[0] + xperc[0] * xdist, xlim[0] + xperc[0] * xdist,
xlim[0] + xperc[1] * xdist, xlim[0] + xperc[1] * xdist]
ys = [ylim[0... | [
"def check_extent(self):\n if self.lower_left.x > self.upper_right.x:\n dlx = self.lower_left.x\n self.lower_left.x = self.upper_right.x\n self.upper_right.y = dlx\n\n if self.lower_left.y > self.upper_right.y:\n dly = self.lower_left.y\n self.low... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns string rep of directions (capital X is pos x, lowercase x is neg x) | def __str__(self):
prev_directions = ""
if self.prev_step:
prev_directions = str(self.prev_step) + ' '
direction = '?'
for scale, name in zip(self.direction, 'xyz'):
if scale == 0:
continue
if scale == 1:
direction = name.upper()
else:
direction = name
... | [
"def directions(self):\n \n # Initalize variables for the directions.\n NSEW = [a for a in dir(self) if len(a) == 1 and a in \"NSEW\"]\n dir_names = {'N': 'north', 'S': 'south', 'E': 'east', 'W': 'west'}\n dir_desc = []\n \n # Print the directions available from the ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
create and save species dict for convenience | def create_species_encode():
data = pd.read_csv("../train.csv")
species = sorted(data.species.unique())
species_dict = {species: index for index, species in enumerate(species)}
return species_dict | [
"def create_dicts(self):\n self.dict_species = {v: i for i, v in enumerate(self.all_species_list)}\n self.dict_qss_species = {\n v: i for i, v in enumerate(self.qssa_species_list)\n }\n self.dict_nonqss_species = {\n v: i for i, v in enumerate(self.nonqssa_species_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export samplesheets for Bioanalyzer machine. | def export_bioanalyzer(args):
clarity_epp.export.bioanalyzer.samplesheet(lims, args.process_id, args.output_file) | [
"def test_generate_sample_sheet(self):\n pass",
"def export_tapestation(args):\n clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)",
"def start_output(self):\r\n self.create_output_file()\r\n\r\n for elem in range(len(self.output_zakladki)):\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export samplesheets for caliper machine. | def export_caliper(args):
if args.type == 'normalise':
clarity_epp.export.caliper.samplesheet_normalise(lims, args.process_id, args.output_file)
elif args.type == 'dilute':
clarity_epp.export.caliper.samplesheet_dilute(lims, args.process_id, args.output_file) | [
"def test_generate_sample_sheet(self):\n pass",
"def export_tapestation(args):\n clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)",
"def test_export_spreadsheet(self):\r\n client = self.getClient()\r\n if client:\r\n exp = [['#SampleID', 'DOB... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export samplesheets for hamilton machine. | def export_hamilton(args):
if args.type == 'filling_out':
clarity_epp.export.hamilton.samplesheet_filling_out(lims, args.process_id, args.output_file)
elif args.type == 'purify':
clarity_epp.export.hamilton.samplesheet_purify(lims, args.process_id, args.output_file) | [
"def export_tapestation(args):\n clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)",
"def test_generate_sample_sheet(self):\n pass",
"def ExportSampleSheet():\n\n if len(sys.argv) != 2:\n print 'Usage: CreateLearningSheet [SampleSheet.xls]'\n sys.exit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export (updated) illumina samplesheet. | def export_illumina(args):
clarity_epp.export.illumina.update_samplesheet(lims, args.process_id, args.artifact_id, args.output_file) | [
"def test_generate_sample_sheet(self):\n pass",
"def make_custom_sample_sheet(input_sample_sheet,output_sample_sheet=None,\n lanes=None,fmt=None):\n # Load the sample sheet data\n sample_sheet = IlluminaData.SampleSheet(input_sample_sheet)\n # Determine the column names... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export removed samples table. | def export_removed_samples(args):
clarity_epp.export.sample.removed_samples(lims, args.output_file) | [
"def delete_output_records(self):\n for table in self.control.output_tables:\n if self.control.with_deletion:\n db.truncate(table)\n else:\n id = table.c.rapo_process_id\n delete = table.delete().where(id == self.control.process_id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export related MIP samples | def export_sample_related_mip(args):
clarity_epp.export.sample.sample_related_mip(lims, args.process_id, args.output_file) | [
"def export_removed_samples(args):\n clarity_epp.export.sample.removed_samples(lims, args.output_file)",
"def save_samples(self):\n pass",
"def output_sample_info(param):\n param['pheno_file'] = param['working_dir']+'deliverables/sample_info.txt'\n output_phenotype(param, param['pheno_file'])",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export samplesheets for Tapestation machine. | def export_tapestation(args):
clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file) | [
"def export_tecan(args):\n clarity_epp.export.tecan.samplesheet(lims, args.process_id, args.type, args.output_file)",
"def test_generate_sample_sheet(self):\n pass",
"def test_export_spreadsheet(self):\r\n client = self.getClient()\r\n if client:\r\n exp = [['#SampleID', 'DOB'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export samplesheets for tecan machine. | def export_tecan(args):
clarity_epp.export.tecan.samplesheet(lims, args.process_id, args.type, args.output_file) | [
"def export_tapestation(args):\n clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)",
"def test_generate_sample_sheet(self):\n pass",
"def write_clinical_samples_tsv(sheets):\n\n # Header lines, first item must start with #\n # attribute Display Names\n NAMES ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Export workflow overview files. | def export_workflow(args):
if args.type == 'magnis':
clarity_epp.export.workflow.helix_magnis(lims, args.process_id, args.output_file)
elif args.type == 'mip':
clarity_epp.export.workflow.helix_mip(lims, args.process_id, args.output_file) | [
"def tasks_export(request):\n \n # refer to label-specific tasks \n if 'label' in request.POST:\n try:\n label = Label.objects.get(id=request.POST.get('label'))\n tasks = Task.objects.filter(user=request.user, labels=label)\n except Label.DoesNotExist:\n messages.error(request, 'No such labe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Upload samples from helix output file. | def upload_samples(args):
clarity_epp.upload.samples.from_helix(lims, config.email, args.input_file) | [
"def write_samples(self, path):\n hp = self.hp\n p = self.placeholder['valid']\n p['x_fake'].forward(clear_buffer=True)\n X, Z = p['x_real'].d.copy(), p['x_fake'].d.copy()\n for i, (x, z) in enumerate(zip(X, Z)):\n sf.write(str(path / f'real_{i}.wav'), x[0], hp.sr)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set QC status based on fragment length measurement. | def qc_fragment_length(args):
clarity_epp.qc.fragment_length.set_qc_flag(lims, args.process_id) | [
"def set_qcstatus(self, qcstatus):\n raise NotImplementedError()",
"def set_length(self, length):\n self.progress = 0\n if length == 0:\n self.progress_per_file = self.progress_bar_length\n self.increment()\n return\n self.progress_per_file = self.progr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set QC status based on qubit measurement. | def qc_qubit(args):
clarity_epp.qc.qubit.set_qc_flag(lims, args.process_id) | [
"def set_qcstatus(self, qcstatus):\n raise NotImplementedError()",
"def set_proc_and_qc_status(self, procstatus, qcstatus):\n raise NotImplementedError()",
"def test_ramsey_set_qubit(self):\n ramsey_cal = self.sim_ramsey(False)\n #test update_settings\n new_settings = auspex.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change artifact name to sequence name. | def placement_artifact_set_name(args):
if args.type == 'sequence_name':
clarity_epp.placement.artifact.set_sequence_name(lims, args.process_id)
elif args.type == 'run_id':
clarity_epp.placement.artifact.set_runid_name(lims, args.process_id) | [
"def name(self, value):\n with qdb.sql_connection.TRN:\n sql = \"\"\"UPDATE qiita.artifact\n SET name = %s\n WHERE artifact_id = %s\"\"\"\n qdb.sql_connection.TRN.add(sql, [value, self.id])\n qdb.sql_connection.TRN.execute()",
"def ch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Route artifacts to a workflow | def placement_route_artifact(args):
clarity_epp.placement.artifact.route_to_workflow(lims, args.process_id, args.workflow) | [
"def workflow_manager(project, exp, args, subj_source):\n\n # Create workflow in function defined elsewhere in this package\n (xnatconvert, xnatconvert_input,\n xnatconvert_output) = workflow_spec(exp_info=exp)\n\n xnatconvert.connect([\n (subj_source, xnatconvert_input, [('subject_id', 'subj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Complete protocol step (Dx Mark protocol complete). | def placement_complete_step(args):
clarity_epp.placement.step.finish_protocol_complete(lims, args.process_id) | [
"def OperationCompleteCommand(self):\n self.go('*OPC')",
"async def cmd_complete(self, ctx):\n pass",
"def complete(self):\n self._state = \"COMPLETE\"",
"def complete(self):\n self.completed = 1",
"def end(self):\n self.my_print(\"\\t[DONE]\", msg_types.INFO)\n sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Placement tecan process, distribute artifacts over two containers | def placement_tecan(args):
clarity_epp.placement.tecan.place_artifacts(lims, args.process_id) | [
"def task_prod():\n return {\n 'actions': [\"docker run -p 8080:8080 %s python3 -m %s %s\" % (IMAGE, PACKAGE_PATH, \"%(args)s\")],\n 'task_dep': [\"build\"],\n 'params': PARAMS\n }",
"def deploy_production():\n\n # Use Starcluster to push up client, runner, spider, and feynman\n c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve a person from the database to store in client model | def get_person(self, id):
PERSON = """SELECT name FROM Person
WHERE id = %s"""
ret = None
try:
self.db_cursor.execute("""SELECT name, id FROM Person WHERE id = %s""", (id,))
self.db_cursor.execute(PERSON, (id,))
self.db_connection.commit()... | [
"def getPerson(self, name, client):",
"def select_person():\r\n body = request.get_json()\r\n\r\n try:\r\n SELECT_PERSON_SCHEMA.validate(body)\r\n except SchemaError as err:\r\n raise ServiceBodyError(str(err))\r\n\r\n with sqlite_client:\r\n message = get_person(sqlite_client, bo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to determine if the list of courses is in the general courses table | def validate_new_curriculum_courses(self, curriculum_courses):
for cur in curriculum_courses:
# check to make sure its in the general courses table
self.db_cursor.execute("""SELECT COUNT(*) FROM Course WHERE name = %s""", (cur,))
ct = self.db_cursor.fetchone()
ct... | [
"def course_in(courses):\n def satisfies(course):\n key = \"%s %s\" % (course.abbreviation, course.course_number)\n return key in courses\n return satisfies",
"def course_not_in(courses):\n def _satisfies(course):\n key = \"%s %s\" % (course.abbreviation, course.course_number)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Funtion to determine if a person with the same id as a new person already exists in the database | def validate_new_person(self, person_id):
self.db_cursor.execute("""SELECT COUNT(*) FROM Person WHERE id == %s""", (person_id,))
ct = self.db_cursor.fetchone()
ct = ct[0]
if ct == 0:
return False
return True | [
"def new_patient():\n try:\n patient_raw = request.get_json()\n patient1 = validate_patient_data(patient_raw)\n if not all_patients:\n all_patients.append(patient1.copy())\n return \"Successful\"\n for patient in all_patients:\n if patient[\"patient_id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to determine if a topic with the same id as the new topic already exists in the database | def validate_new_topic(self, topic_id):
self.db_cursor.execute("""SELECT COUNT(*) FROM Topic WHERE id == %s""", (topic_id,))
ct = self.db_cursor.fetchone()
ct = ct[0]
if ct == 0:
return False
return True | [
"def _create_topic_if_not_exists(self, topic):\n if topic in self.environments['cluster'].kafka.consumer().topics():\n return True\n\n new_topic = NewTopic(name=topic, num_partitions=MAX_CONCURRENCY*2, replication_factor=1)\n admin_client = KafkaAdminClient(bootstrap_servers=self.env... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to add a brand new topic to the database | def add_new_topic_to_db(self, topic_obj):
# todo: don't need this anymore
self.db_cursor.execute("""INSERT INTO Topic (id, name) VALUES (%s, %s)""", (topic_obj.id, topic_obj.name))
self.db_connection.commit() | [
"def insert_topic(self,text,addition,year,user):\r\n topic = Topic(date=date.today(),text=text,year=year,user=user)\r\n topic.addition = addition\r\n \r\n session = self.persistence.get_session()\r\n session.add(topic)\r\n session.commit()",
"def new_topic(request):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve course from the database | def get_course(self, name):
GET_TOPIC_IDS = """SELECT topic_id FROM CourseTopics WHERE course_name = %s"""
GET_GOAL_IDS = """SELECT goal_id FROM CourseGoals WHERE course_name = %s"""
ret = None
try:
self.db_cursor.execute("""SELECT subject_code, credit_hours, description FR... | [
"def getCourseById(self, request):\n C = Course.objects.get(courseId=request[\"courseId\"])\n return C",
"def get_courses(db: Session = Depends(get_db)): # , _: models.User = Depends(get_current_user))\n return crud.course.get_multi(db, skip=0, limit=100)",
"def get(id):\n return Course... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fucntion to set the course in the db | def set_course(self, new_course, updating=False):
COURSE_QUERY = """UPDATE Course SET subject_code = %s, credit_hours = %s, description = %s WHERE name = %s""" if updating \
else """INSERT INTO Course (subject_code, credit_hours, description, name) VALUES (%s, %s, %s, %s)"""
self.db_cursor.... | [
"def save_course(self):\r\n self.course.save()\r\n self.store.update_item(self.course, self.user.id)",
"def test_update_course(self):\n pass",
"def editCourse(self, request):\n \"\"\" note: degree and branch are not editable fields \"\"\"\n C = Course.objects.get(courseId=requ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function for adding curriculum to the db | def set_curriculum(self, new_curriculum, updating=False):
if not updating:
#Add Curriculum to database:
self.db_cursor.execute("""INSERT INTO Curriculum (name, min_credit_hours, id_in_charge) VALUES (%s, %s, %s)""",
(new_curriculum.name, new_curriculum.... | [
"def remove_curriculum(self, curriculum):\n DELETE_CURRICULUM = \"\"\"DELETE FROM Curriculum WHERE name = %s\"\"\"\n\n try:\n self.db_cursor.execute(DELETE_CURRICULUM, (curriculum.name,))\n self.db_connection.commit()\n except:\n logging.warning(\"DBAdapter: Err... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all descriptions of a Goal, potentially across the context of multiple curricula and returns a description | def fetch_goal_context_description(self, goalId):
GET_ALL_CONTEXTS = """SELECT curriculum_name, description FROM Goal WHERE id = %s """
try:
self.db_cursor.execute(GET_ALL_CONTEXTS,(goalId,))
descriptions = self.db_cursor.fetchall()
if len(descriptions) <= 0:
... | [
"async def get_course_description(bot, *args):\n course_data = await _get_data(bot, *args)\n title = _get_course_title(course_data, course_list=True)\n description = {}\n attributes = [\n ('description', 'description'),\n ('sectionDegreeAttributes', 'type'),\n ('courseSectionInforma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve goal from the db | def get_goal(self, new_goal):
GOAL = """SELECT COUNT(*) FROM Section WHERE id = %s"""
ret = None
try:
self.db_cursor.execute(
"""SELECT description FROM Goal WHERE id = %s AND curriculum_name = %s""",
(new_goal.id, new_goal.curriculum_name,))
... | [
"def test_get_goal(self):\n pass",
"def get_goal(id, check_author=True):\n goal = (\n get_db()\n .execute(\n \"SELECT g.id AS id, title, created, author_id, username\"\n \" FROM goals g JOIN user u ON g.author_id = u.id\"\n \" WHERE g.id = ?\",\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to write course goal to the db | def set_course_goal(self, goal_id, course_name):
self.db_cursor.execute(
"""INSERT INTO CourseGoals (course_name, goal_id) VALUES (%s, %s)""",
(course_name, goal_id))
self.db_connection.commit() | [
"def commit(self):\n self.classification_time = datetime.datetime.now()\n db_dict = self.dbdict()\n #*** Write classification to database collection:\n self.clsfn.insert_one(db_dict)",
"def update_db():\n \n with open(\"courses_2016.json\") as data:\n data ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to write course topic to the db | def set_course_topic(self, topic_id,course_name):
self.db_cursor.execute(
"""INSERT INTO CourseTopics (course_name, topic_id) VALUES (%s, %s)""",
(course_name, topic_id))
self.db_connection.commit() | [
"def write_topics(con, cur, beta_file, vocab):\n cur.execute('CREATE TABLE topics (id INTEGER PRIMARY KEY, title VARCHAR(100))')\n con.commit()\n\n #NOTE: What is the following line for and why doesn't it raise an error?\n topics_file = open(filename, 'a')\n\n for topic in open(beta_file, 'r'):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to get a course topic from the db | def get_course_topic(self, topic_id, course_name):
ret = None
try:
self.db_cursor.execute(
"""SELECT course_name, topic_id FROM CourseTopics WHERE course_name = %s AND topic_id = %s""",
(course_name, topic_id))
ct = self.db_cursor.fetchall()
... | [
"def test_get_single_topic_courses(self):\r\n course_id = None # Change me!!\r\n topic_id = None # Change me!!\r\n\r\n r = self.client.get_single_topic_courses(topic_id, course_id)",
"def test_get_full_topic_courses(self):\r\n course_id = None # Change me!!\r\n topic_id = Non... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve curriculum topic from the db | def get_curriculum_topic(self, curriculum_name, curriculum_topic):
ret = None
try:
self.db_cursor.execute(
"""SELECT level, subject_area, time_unit FROM CurriculumTopics WHERE curriculum_name = %s AND topic_id = %s""",
(curriculum_name, curriculum_topic))
... | [
"def get_topic_of_question(question):\n dynamodb = boto3.resource(\"dynamodb\", region_name=\"eu-central-1\")\n topic_table = dynamodb.Table(\"Topics\")\n\n topic_id = question.get(\"TopicId\")\n # query topic_id of the question\n try:\n response = topic_table.get_item(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve a list of curriculum goals from the db | def curriculum_goal_list(self, curriculum_name):
ret = []
try:
self.db_cursor.execute(
"""SELECT id, description FROM Goal WHERE curriculum_name = %s""",
(curriculum_name,))
goals = self.db_cursor.fetchall()
if goals:
g... | [
"def goals():\n # db = get_db()\n goals = fetch_goals()\n return render_template(\"goals/index.html\", goals=goals)",
"def goals(self):\n return self.goal_set.all().distinct()",
"def goals(self):\r\n return goals.Goals(self)",
"def get_goal(self, new_goal):\n\n GOAL = \"\"\"SELEC... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve the section grades from the db and return them as a list (this works for SectionGrades table and SectionGoalGrades table) | def get_section_grades(self, section, section_goal=False):
if not section_goal:
SECTION_GRADES = """SELECT count_ap, count_a, count_am, count_bp, count_b, count_bm, count_cp, count_c, count_cm, count_dp, count_d, count_dm, count_f,count_i, count_w FROM SectionGrades WHERE course = %s AND semester = ... | [
"def getClassGrades(classId):\n\n AssignmentNames = Assignment.query.filter_by(class_id=classId).order_by(Assignment.assignment_due_date).all()\n headerList = []\n totalPoints = 0\n for assignment in AssignmentNames:\n header = {}\n header['name'] = assignment.name\n header['id'] = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to retrieve a list of sections based off of a course | def get_sections_of_a_course(self, course_name, year, semester_name):
if semester_name not in SEMESTER_NAME_MAP.keys():
logging.warning("DBAdapter: Error- invalid semester name.")
return None
semester = SEMESTER_NAME_MAP[semester_name]
return_list = []
GET_SECTIO... | [
"def select_all_sections(self, course_id):\n conn = sqlite3.connect(self.db_path)\n cursor = conn.cursor()\n with conn:\n cursor.execute(\n \"\"\"SELECT * FROM course_sections \n WHERE course_id = ?\"\"\",\n (course_id,),\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove curriculum goals from the db | def remove_curriculum_goals(self, curriculum):
DELETE_CURRICULUM_GOALS = """DELETE FROM Goal WHERE curriculum_name = %s"""
try:
self.db_cursor.execute(DELETE_CURRICULUM_GOALS, (curriculum.name,))
self.db_connection.commit()
except:
logging.warning("DBAdapter:... | [
"def remove_course_goals(self, course):\n DELETE_COURSE_GOALS = \"\"\"DELETE FROM CourseGoals WHERE course_name = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_GOALS, (course.name,))\n self.db_connection.commit()",
"def remove_curriculum(self, curriculum):\n DELETE_CURRICULUM = \"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove curriculum topics from the db | def remove_curriculum_topics(self, curriculum):
DELETE_FROM_CURRICULUM_TOPICS = """DELETE FROM CurriculumTopics WHERE curriculum_name = %s"""
try:
self.db_cursor.execute(DELETE_FROM_CURRICULUM_TOPICS, (curriculum.name,))
self.db_connection.commit()
except:
lo... | [
"def remove(topic):",
"def remove_course_topics(self, course):\n DELETE_COURSE_TOPICS = \"\"\"DELETE FROM CourseTopics WHERE course_name = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_TOPICS, (course.name,))\n self.db_connection.commit()",
"def remove_topic ( topics , level = ROOT.RooF... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove curriculum courses from the db | def remove_curriculum_courses(self, curriculum):
DELETE_FROM_CURRICULUM_LISTINGS = """DELETE FROM CurriculumListings WHERE curriculum_name = %s"""
try:
self.db_cursor.execute(DELETE_FROM_CURRICULUM_LISTINGS, (curriculum.name,))
self.db_connection.commit()
except:
... | [
"def remove_course_in_curriculum_listings(self, course):\n DELETE_CURRICULUM_COURSES = \"\"\"DELETE FROM CurriculumListings WHERE course_name = %s\"\"\"\n\n self.db_cursor.execute(DELETE_CURRICULUM_COURSES, (course.name,))\n self.db_connection.commit()",
"def remove_curriculum(self, curriculu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove curriculum from the db | def remove_curriculum(self, curriculum):
DELETE_CURRICULUM = """DELETE FROM Curriculum WHERE name = %s"""
try:
self.db_cursor.execute(DELETE_CURRICULUM, (curriculum.name,))
self.db_connection.commit()
except:
logging.warning("DBAdapter: Error- Could not delet... | [
"def remove_curriculum_courses(self, curriculum):\n DELETE_FROM_CURRICULUM_LISTINGS = \"\"\"DELETE FROM CurriculumListings WHERE curriculum_name = %s\"\"\"\n\n try:\n self.db_cursor.execute(DELETE_FROM_CURRICULUM_LISTINGS, (curriculum.name,))\n self.db_connection.commit()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to edit a course in the db | def edit_course(self, course):
EDIT_COURSE = """UPDATE Course SET subject_code = %s, credit_hours = %s, description = %s WHERE name = %s"""
self.db_cursor.execute(EDIT_COURSE, (
course.subject_code, course.credit_hours, course.description, course.name))
self.db_connection.commit()
... | [
"def edit_course():\n return",
"def editCourse(self, request):\n \"\"\" note: degree and branch are not editable fields \"\"\"\n C = Course.objects.get(courseId=request[\"courseId\"])\n C.courseId = request[\"courseId\"]\n C.courseName = request[\"courseName\"]\n C.courseType... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fuction to remove course goals from the db | def remove_course_goals(self, course):
DELETE_COURSE_GOALS = """DELETE FROM CourseGoals WHERE course_name = %s"""
self.db_cursor.execute(DELETE_COURSE_GOALS, (course.name,))
self.db_connection.commit() | [
"def remove_course_in_section_goal_grades(self, course):\n DELETE_COURSE_SECTION_GOAL_GRADES = \"\"\"DELETE FROM SectionGoalGrades WHERE course = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_SECTION_GOAL_GRADES, (course.name,))\n self.db_connection.commit()",
"def remove_curriculum_goals... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove course topics from the db | def remove_course_topics(self, course):
DELETE_COURSE_TOPICS = """DELETE FROM CourseTopics WHERE course_name = %s"""
self.db_cursor.execute(DELETE_COURSE_TOPICS, (course.name,))
self.db_connection.commit() | [
"def remove(topic):",
"def test_delete_topic_courses(self):\r\n course_id = None # Change me!!\r\n topic_id = None # Change me!!\r\n\r\n r = self.client.delete_topic_courses(topic_id, course_id)",
"def remove_curriculum_topics(self, curriculum):\n DELETE_FROM_CURRICULUM_TOPICS = \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove courses from a curriculum in the db | def remove_course_in_curriculum_listings(self, course):
DELETE_CURRICULUM_COURSES = """DELETE FROM CurriculumListings WHERE course_name = %s"""
self.db_cursor.execute(DELETE_CURRICULUM_COURSES, (course.name,))
self.db_connection.commit() | [
"def remove_curriculum_courses(self, curriculum):\n DELETE_FROM_CURRICULUM_LISTINGS = \"\"\"DELETE FROM CurriculumListings WHERE curriculum_name = %s\"\"\"\n\n try:\n self.db_cursor.execute(DELETE_FROM_CURRICULUM_LISTINGS, (curriculum.name,))\n self.db_connection.commit()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove all sections of a course in the db | def remove_course_in_section(self, course):
DELETE_COURSE_SECTIONS = """DELETE FROM Section WHERE course_name = %s"""
self.db_cursor.execute(DELETE_COURSE_SECTIONS, (course.name,))
self.db_connection.commit() | [
"def remove_course_in_section_grades(self, course):\n DELETE_COURSE_SECTION_GRADES = \"\"\"DELETE FROM SectionGrades WHERE course = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_SECTION_GRADES, (course.name,))\n self.db_connection.commit()",
"def del_section(request):\n id = request.GE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove occurances of course in section grades in the db | def remove_course_in_section_grades(self, course):
DELETE_COURSE_SECTION_GRADES = """DELETE FROM SectionGrades WHERE course = %s"""
self.db_cursor.execute(DELETE_COURSE_SECTION_GRADES, (course.name,))
self.db_connection.commit() | [
"def remove_course_in_section_goal_grades(self, course):\n DELETE_COURSE_SECTION_GOAL_GRADES = \"\"\"DELETE FROM SectionGoalGrades WHERE course = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_SECTION_GOAL_GRADES, (course.name,))\n self.db_connection.commit()",
"def remove_course_in_sectio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove occurances of course in section grades in the db | def remove_course_in_section_goal_grades(self, course):
DELETE_COURSE_SECTION_GOAL_GRADES = """DELETE FROM SectionGoalGrades WHERE course = %s"""
self.db_cursor.execute(DELETE_COURSE_SECTION_GOAL_GRADES, (course.name,))
self.db_connection.commit() | [
"def remove_course_in_section_grades(self, course):\n DELETE_COURSE_SECTION_GRADES = \"\"\"DELETE FROM SectionGrades WHERE course = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_SECTION_GRADES, (course.name,))\n self.db_connection.commit()",
"def remove_course_in_section(self, course):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove course from the db | def remove_course(self, course):
DELETE_COURSE = """DELETE FROM Course WHERE name = %s"""
self.db_cursor.execute(DELETE_COURSE, (course.name,))
self.db_connection.commit() | [
"def _delete_course():\n raise NotImplementedError",
"def remove_course_in_section(self, course):\n DELETE_COURSE_SECTIONS = \"\"\"DELETE FROM Section WHERE course_name = %s\"\"\"\n\n self.db_cursor.execute(DELETE_COURSE_SECTIONS, (course.name,))\n self.db_connection.commit()",
"def dele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |