repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
denisenkom/pytds | src/pytds/tds.py | _TdsSession.submit_rpc | def submit_rpc(self, rpc_name, params, flags=0):
""" Sends an RPC request.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/librar... | python | def submit_rpc(self, rpc_name, params, flags=0):
""" Sends an RPC request.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/librar... | [
"def",
"submit_rpc",
"(",
"self",
",",
"rpc_name",
",",
"params",
",",
"flags",
"=",
"0",
")",
":",
"logger",
".",
"info",
"(",
"'Sending RPC %s flags=%d'",
",",
"rpc_name",
",",
"flags",
")",
"self",
".",
"messages",
"=",
"[",
"]",
"self",
".",
"outpu... | Sends an RPC request.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/library/dd357576.aspx
:param rpc_name: Name of the RPC to ... | [
"Sends",
"an",
"RPC",
"request",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L974-L1032 |
denisenkom/pytds | src/pytds/tds.py | _TdsSession.submit_plain_query | def submit_plain_query(self, operation):
""" Sends a plain query to server.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/libra... | python | def submit_plain_query(self, operation):
""" Sends a plain query to server.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/libra... | [
"def",
"submit_plain_query",
"(",
"self",
",",
"operation",
")",
":",
"self",
".",
"messages",
"=",
"[",
"]",
"self",
".",
"cancel_if_pending",
"(",
")",
"self",
".",
"res_info",
"=",
"None",
"logger",
".",
"info",
"(",
"\"Sending query %s\"",
",",
"operat... | Sends a plain query to server.
This call will transition session into pending state.
If some operation is currently pending on the session, it will be
cancelled before sending this request.
Spec: http://msdn.microsoft.com/en-us/library/dd358575.aspx
:param operation: A string ... | [
"Sends",
"a",
"plain",
"query",
"to",
"server",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L1034-L1053 |
denisenkom/pytds | src/pytds/tds.py | _TdsSession.submit_bulk | def submit_bulk(self, metadata, rows):
""" Sends insert bulk command.
Spec: http://msdn.microsoft.com/en-us/library/dd358082.aspx
:param metadata: A list of :class:`Column` instances.
:param rows: A collection of rows, each row is a collection of values.
:return:
"""
... | python | def submit_bulk(self, metadata, rows):
""" Sends insert bulk command.
Spec: http://msdn.microsoft.com/en-us/library/dd358082.aspx
:param metadata: A list of :class:`Column` instances.
:param rows: A collection of rows, each row is a collection of values.
:return:
"""
... | [
"def",
"submit_bulk",
"(",
"self",
",",
"metadata",
",",
"rows",
")",
":",
"logger",
".",
"info",
"(",
"'Sending INSERT BULK'",
")",
"num_cols",
"=",
"len",
"(",
"metadata",
")",
"w",
"=",
"self",
".",
"_writer",
"serializers",
"=",
"[",
"]",
"with",
"... | Sends insert bulk command.
Spec: http://msdn.microsoft.com/en-us/library/dd358082.aspx
:param metadata: A list of :class:`Column` instances.
:param rows: A collection of rows, each row is a collection of values.
:return: | [
"Sends",
"insert",
"bulk",
"command",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L1055-L1100 |
denisenkom/pytds | src/pytds/tds.py | _TdsSession.put_cancel | def put_cancel(self):
""" Sends a cancel request to the server.
Switches connection to IN_CANCEL state.
"""
logger.info('Sending CANCEL')
self._writer.begin_packet(tds_base.PacketType.CANCEL)
self._writer.flush()
self.in_cancel = 1 | python | def put_cancel(self):
""" Sends a cancel request to the server.
Switches connection to IN_CANCEL state.
"""
logger.info('Sending CANCEL')
self._writer.begin_packet(tds_base.PacketType.CANCEL)
self._writer.flush()
self.in_cancel = 1 | [
"def",
"put_cancel",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Sending CANCEL'",
")",
"self",
".",
"_writer",
".",
"begin_packet",
"(",
"tds_base",
".",
"PacketType",
".",
"CANCEL",
")",
"self",
".",
"_writer",
".",
"flush",
"(",
")",
"self",
... | Sends a cancel request to the server.
Switches connection to IN_CANCEL state. | [
"Sends",
"a",
"cancel",
"request",
"to",
"the",
"server",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L1102-L1110 |
denisenkom/pytds | src/pytds/tds_base.py | iterdecode | def iterdecode(iterable, codec):
""" Uses an incremental decoder to decode each chunk in iterable.
This function is a generator.
:param iterable: Iterable object which yields raw data to be decoded
:param codec: An instance of codec
"""
decoder = codec.incrementaldecoder()
for chunk in iter... | python | def iterdecode(iterable, codec):
""" Uses an incremental decoder to decode each chunk in iterable.
This function is a generator.
:param iterable: Iterable object which yields raw data to be decoded
:param codec: An instance of codec
"""
decoder = codec.incrementaldecoder()
for chunk in iter... | [
"def",
"iterdecode",
"(",
"iterable",
",",
"codec",
")",
":",
"decoder",
"=",
"codec",
".",
"incrementaldecoder",
"(",
")",
"for",
"chunk",
"in",
"iterable",
":",
"yield",
"decoder",
".",
"decode",
"(",
"chunk",
")",
"yield",
"decoder",
".",
"decode",
"(... | Uses an incremental decoder to decode each chunk in iterable.
This function is a generator.
:param iterable: Iterable object which yields raw data to be decoded
:param codec: An instance of codec | [
"Uses",
"an",
"incremental",
"decoder",
"to",
"decode",
"each",
"chunk",
"in",
"iterable",
".",
"This",
"function",
"is",
"a",
"generator",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_base.py#L317-L327 |
denisenkom/pytds | src/pytds/tds_base.py | skipall | def skipall(stm, size):
""" Skips exactly size bytes in stm
If EOF is reached before size bytes are skipped
will raise :class:`ClosedConnectionError`
:param stm: Stream to skip bytes in, should have read method
this read method can return less than requested
number of b... | python | def skipall(stm, size):
""" Skips exactly size bytes in stm
If EOF is reached before size bytes are skipped
will raise :class:`ClosedConnectionError`
:param stm: Stream to skip bytes in, should have read method
this read method can return less than requested
number of b... | [
"def",
"skipall",
"(",
"stm",
",",
"size",
")",
":",
"res",
"=",
"stm",
".",
"recv",
"(",
"size",
")",
"if",
"len",
"(",
"res",
")",
"==",
"size",
":",
"return",
"elif",
"len",
"(",
"res",
")",
"==",
"0",
":",
"raise",
"ClosedConnectionError",
"(... | Skips exactly size bytes in stm
If EOF is reached before size bytes are skipped
will raise :class:`ClosedConnectionError`
:param stm: Stream to skip bytes in, should have read method
this read method can return less than requested
number of bytes.
:param size: Number of... | [
"Skips",
"exactly",
"size",
"bytes",
"in",
"stm"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_base.py#L496-L517 |
denisenkom/pytds | src/pytds/tds_base.py | read_chunks | def read_chunks(stm, size):
""" Reads exactly size bytes from stm and produces chunks
May call stm.read multiple times until required
number of bytes is read.
If EOF is reached before size bytes are read
will raise :class:`ClosedConnectionError`
:param stm: Stream to read bytes from, should ha... | python | def read_chunks(stm, size):
""" Reads exactly size bytes from stm and produces chunks
May call stm.read multiple times until required
number of bytes is read.
If EOF is reached before size bytes are read
will raise :class:`ClosedConnectionError`
:param stm: Stream to read bytes from, should ha... | [
"def",
"read_chunks",
"(",
"stm",
",",
"size",
")",
":",
"if",
"size",
"==",
"0",
":",
"yield",
"b''",
"return",
"res",
"=",
"stm",
".",
"recv",
"(",
"size",
")",
"if",
"len",
"(",
"res",
")",
"==",
"0",
":",
"raise",
"ClosedConnectionError",
"(",
... | Reads exactly size bytes from stm and produces chunks
May call stm.read multiple times until required
number of bytes is read.
If EOF is reached before size bytes are read
will raise :class:`ClosedConnectionError`
:param stm: Stream to read bytes from, should have read method,
this... | [
"Reads",
"exactly",
"size",
"bytes",
"from",
"stm",
"and",
"produces",
"chunks"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_base.py#L520-L547 |
denisenkom/pytds | src/pytds/tds_base.py | readall_fast | def readall_fast(stm, size):
"""
Slightly faster version of readall, it reads no more than two chunks.
Meaning that it can only be used to read small data that doesn't span
more that two packets.
:param stm: Stream to read from, should have read method.
:param size: Number of bytes to read.
... | python | def readall_fast(stm, size):
"""
Slightly faster version of readall, it reads no more than two chunks.
Meaning that it can only be used to read small data that doesn't span
more that two packets.
:param stm: Stream to read from, should have read method.
:param size: Number of bytes to read.
... | [
"def",
"readall_fast",
"(",
"stm",
",",
"size",
")",
":",
"buf",
",",
"offset",
"=",
"stm",
".",
"read_fast",
"(",
"size",
")",
"if",
"len",
"(",
"buf",
")",
"-",
"offset",
"<",
"size",
":",
"# slow case",
"buf",
"=",
"buf",
"[",
"offset",
":",
"... | Slightly faster version of readall, it reads no more than two chunks.
Meaning that it can only be used to read small data that doesn't span
more that two packets.
:param stm: Stream to read from, should have read method.
:param size: Number of bytes to read.
:return: | [
"Slightly",
"faster",
"version",
"of",
"readall",
"it",
"reads",
"no",
"more",
"than",
"two",
"chunks",
".",
"Meaning",
"that",
"it",
"can",
"only",
"be",
"used",
"to",
"read",
"small",
"data",
"that",
"doesn",
"t",
"span",
"more",
"that",
"two",
"packet... | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_base.py#L567-L583 |
denisenkom/pytds | src/pytds/tds_types.py | _decode_num | def _decode_num(buf):
""" Decodes little-endian integer from buffer
Buffer can be of any size
"""
return functools.reduce(lambda acc, val: acc * 256 + tds_base.my_ord(val), reversed(buf), 0) | python | def _decode_num(buf):
""" Decodes little-endian integer from buffer
Buffer can be of any size
"""
return functools.reduce(lambda acc, val: acc * 256 + tds_base.my_ord(val), reversed(buf), 0) | [
"def",
"_decode_num",
"(",
"buf",
")",
":",
"return",
"functools",
".",
"reduce",
"(",
"lambda",
"acc",
",",
"val",
":",
"acc",
"*",
"256",
"+",
"tds_base",
".",
"my_ord",
"(",
"val",
")",
",",
"reversed",
"(",
"buf",
")",
",",
"0",
")"
] | Decodes little-endian integer from buffer
Buffer can be of any size | [
"Decodes",
"little",
"-",
"endian",
"integer",
"from",
"buffer"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L29-L34 |
denisenkom/pytds | src/pytds/tds_types.py | PlpReader.chunks | def chunks(self):
""" Generates chunks from stream, each chunk is an instace of bytes.
"""
if self.is_null():
return
total = 0
while True:
chunk_len = self._rdr.get_uint()
if chunk_len == 0:
if not self.is_unknown_len() and tota... | python | def chunks(self):
""" Generates chunks from stream, each chunk is an instace of bytes.
"""
if self.is_null():
return
total = 0
while True:
chunk_len = self._rdr.get_uint()
if chunk_len == 0:
if not self.is_unknown_len() and tota... | [
"def",
"chunks",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_null",
"(",
")",
":",
"return",
"total",
"=",
"0",
"while",
"True",
":",
"chunk_len",
"=",
"self",
".",
"_rdr",
".",
"get_uint",
"(",
")",
"if",
"chunk_len",
"==",
"0",
":",
"if",
"no... | Generates chunks from stream, each chunk is an instace of bytes. | [
"Generates",
"chunks",
"from",
"stream",
"each",
"chunk",
"is",
"an",
"instace",
"of",
"bytes",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L68-L88 |
denisenkom/pytds | src/pytds/tds_types.py | Date.from_pydate | def from_pydate(cls, pydate):
"""
Creates sql date object from Python date object.
@param pydate: Python date
@return: sql date
"""
return cls(days=(datetime.datetime.combine(pydate, datetime.time(0, 0, 0)) - _datetime2_base_date).days) | python | def from_pydate(cls, pydate):
"""
Creates sql date object from Python date object.
@param pydate: Python date
@return: sql date
"""
return cls(days=(datetime.datetime.combine(pydate, datetime.time(0, 0, 0)) - _datetime2_base_date).days) | [
"def",
"from_pydate",
"(",
"cls",
",",
"pydate",
")",
":",
"return",
"cls",
"(",
"days",
"=",
"(",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"pydate",
",",
"datetime",
".",
"time",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
"-",
"_datetime2_ba... | Creates sql date object from Python date object.
@param pydate: Python date
@return: sql date | [
"Creates",
"sql",
"date",
"object",
"from",
"Python",
"date",
"object",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1484-L1490 |
denisenkom/pytds | src/pytds/tds_types.py | Time.to_pytime | def to_pytime(self):
"""
Converts sql time object into Python's time object
this will truncate nanoseconds to microseconds
@return: naive time
"""
nanoseconds = self._nsec
hours = nanoseconds // 1000000000 // 60 // 60
nanoseconds -= hours * 60 * 60 * 10000... | python | def to_pytime(self):
"""
Converts sql time object into Python's time object
this will truncate nanoseconds to microseconds
@return: naive time
"""
nanoseconds = self._nsec
hours = nanoseconds // 1000000000 // 60 // 60
nanoseconds -= hours * 60 * 60 * 10000... | [
"def",
"to_pytime",
"(",
"self",
")",
":",
"nanoseconds",
"=",
"self",
".",
"_nsec",
"hours",
"=",
"nanoseconds",
"//",
"1000000000",
"//",
"60",
"//",
"60",
"nanoseconds",
"-=",
"hours",
"*",
"60",
"*",
"60",
"*",
"1000000000",
"minutes",
"=",
"nanoseco... | Converts sql time object into Python's time object
this will truncate nanoseconds to microseconds
@return: naive time | [
"Converts",
"sql",
"time",
"object",
"into",
"Python",
"s",
"time",
"object",
"this",
"will",
"truncate",
"nanoseconds",
"to",
"microseconds"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1521-L1534 |
denisenkom/pytds | src/pytds/tds_types.py | Time.from_pytime | def from_pytime(cls, pytime):
"""
Converts Python time object to sql time object
ignoring timezone
@param pytime: Python time object
@return: sql time object
"""
secs = pytime.hour * 60 * 60 + pytime.minute * 60 + pytime.second
nsec = secs * 10 ** 9 + pyti... | python | def from_pytime(cls, pytime):
"""
Converts Python time object to sql time object
ignoring timezone
@param pytime: Python time object
@return: sql time object
"""
secs = pytime.hour * 60 * 60 + pytime.minute * 60 + pytime.second
nsec = secs * 10 ** 9 + pyti... | [
"def",
"from_pytime",
"(",
"cls",
",",
"pytime",
")",
":",
"secs",
"=",
"pytime",
".",
"hour",
"*",
"60",
"*",
"60",
"+",
"pytime",
".",
"minute",
"*",
"60",
"+",
"pytime",
".",
"second",
"nsec",
"=",
"secs",
"*",
"10",
"**",
"9",
"+",
"pytime",
... | Converts Python time object to sql time object
ignoring timezone
@param pytime: Python time object
@return: sql time object | [
"Converts",
"Python",
"time",
"object",
"to",
"sql",
"time",
"object",
"ignoring",
"timezone"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1537-L1546 |
denisenkom/pytds | src/pytds/tds_types.py | DateTime2.to_pydatetime | def to_pydatetime(self):
"""
Converts datetime2 object into Python's datetime.datetime object
@return: naive datetime.datetime
"""
return datetime.datetime.combine(self._date.to_pydate(), self._time.to_pytime()) | python | def to_pydatetime(self):
"""
Converts datetime2 object into Python's datetime.datetime object
@return: naive datetime.datetime
"""
return datetime.datetime.combine(self._date.to_pydate(), self._time.to_pytime()) | [
"def",
"to_pydatetime",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"self",
".",
"_date",
".",
"to_pydate",
"(",
")",
",",
"self",
".",
"_time",
".",
"to_pytime",
"(",
")",
")"
] | Converts datetime2 object into Python's datetime.datetime object
@return: naive datetime.datetime | [
"Converts",
"datetime2",
"object",
"into",
"Python",
"s",
"datetime",
".",
"datetime",
"object"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1583-L1588 |
denisenkom/pytds | src/pytds/tds_types.py | DateTime2.from_pydatetime | def from_pydatetime(cls, pydatetime):
"""
Creates sql datetime2 object from Python datetime object
ignoring timezone
@param pydatetime: Python datetime object
@return: sql datetime2 object
"""
return cls(date=Date.from_pydate(pydatetime.date),
t... | python | def from_pydatetime(cls, pydatetime):
"""
Creates sql datetime2 object from Python datetime object
ignoring timezone
@param pydatetime: Python datetime object
@return: sql datetime2 object
"""
return cls(date=Date.from_pydate(pydatetime.date),
t... | [
"def",
"from_pydatetime",
"(",
"cls",
",",
"pydatetime",
")",
":",
"return",
"cls",
"(",
"date",
"=",
"Date",
".",
"from_pydate",
"(",
"pydatetime",
".",
"date",
")",
",",
"time",
"=",
"Time",
".",
"from_pytime",
"(",
"pydatetime",
".",
"time",
")",
")... | Creates sql datetime2 object from Python datetime object
ignoring timezone
@param pydatetime: Python datetime object
@return: sql datetime2 object | [
"Creates",
"sql",
"datetime2",
"object",
"from",
"Python",
"datetime",
"object",
"ignoring",
"timezone"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1591-L1599 |
denisenkom/pytds | src/pytds/tds_types.py | DateTimeOffset.to_pydatetime | def to_pydatetime(self):
"""
Converts datetimeoffset object into Python's datetime.datetime object
@return: time zone aware datetime.datetime
"""
dt = datetime.datetime.combine(self._date.to_pydate(), self._time.to_pytime())
from .tz import FixedOffsetTimezone
ret... | python | def to_pydatetime(self):
"""
Converts datetimeoffset object into Python's datetime.datetime object
@return: time zone aware datetime.datetime
"""
dt = datetime.datetime.combine(self._date.to_pydate(), self._time.to_pytime())
from .tz import FixedOffsetTimezone
ret... | [
"def",
"to_pydatetime",
"(",
"self",
")",
":",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"self",
".",
"_date",
".",
"to_pydate",
"(",
")",
",",
"self",
".",
"_time",
".",
"to_pytime",
"(",
")",
")",
"from",
".",
"tz",
"import",
"... | Converts datetimeoffset object into Python's datetime.datetime object
@return: time zone aware datetime.datetime | [
"Converts",
"datetimeoffset",
"object",
"into",
"Python",
"s",
"datetime",
".",
"datetime",
"object"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1628-L1635 |
denisenkom/pytds | src/pytds/tds_types.py | TableSerializer.write_info | def write_info(self, w):
"""
Writes TVP_TYPENAME structure
spec: https://msdn.microsoft.com/en-us/library/dd302994.aspx
@param w: TdsWriter
@return:
"""
w.write_b_varchar("") # db_name, should be empty
w.write_b_varchar(self._table_type.typ_schema)
... | python | def write_info(self, w):
"""
Writes TVP_TYPENAME structure
spec: https://msdn.microsoft.com/en-us/library/dd302994.aspx
@param w: TdsWriter
@return:
"""
w.write_b_varchar("") # db_name, should be empty
w.write_b_varchar(self._table_type.typ_schema)
... | [
"def",
"write_info",
"(",
"self",
",",
"w",
")",
":",
"w",
".",
"write_b_varchar",
"(",
"\"\"",
")",
"# db_name, should be empty",
"w",
".",
"write_b_varchar",
"(",
"self",
".",
"_table_type",
".",
"typ_schema",
")",
"w",
".",
"write_b_varchar",
"(",
"self",... | Writes TVP_TYPENAME structure
spec: https://msdn.microsoft.com/en-us/library/dd302994.aspx
@param w: TdsWriter
@return: | [
"Writes",
"TVP_TYPENAME",
"structure"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L2245-L2255 |
denisenkom/pytds | src/pytds/tds_types.py | TableSerializer.write | def write(self, w, val):
"""
Writes remaining part of TVP_TYPE_INFO structure, resuming from TVP_COLMETADATA
specs:
https://msdn.microsoft.com/en-us/library/dd302994.aspx
https://msdn.microsoft.com/en-us/library/dd305261.aspx
https://msdn.microsoft.com/en-us/library/dd30... | python | def write(self, w, val):
"""
Writes remaining part of TVP_TYPE_INFO structure, resuming from TVP_COLMETADATA
specs:
https://msdn.microsoft.com/en-us/library/dd302994.aspx
https://msdn.microsoft.com/en-us/library/dd305261.aspx
https://msdn.microsoft.com/en-us/library/dd30... | [
"def",
"write",
"(",
"self",
",",
"w",
",",
"val",
")",
":",
"if",
"val",
".",
"is_null",
"(",
")",
":",
"w",
".",
"put_usmallint",
"(",
"tds_base",
".",
"TVP_NULL_TOKEN",
")",
"else",
":",
"columns",
"=",
"self",
".",
"_table_type",
".",
"columns",
... | Writes remaining part of TVP_TYPE_INFO structure, resuming from TVP_COLMETADATA
specs:
https://msdn.microsoft.com/en-us/library/dd302994.aspx
https://msdn.microsoft.com/en-us/library/dd305261.aspx
https://msdn.microsoft.com/en-us/library/dd303230.aspx
@param w: TdsWriter
... | [
"Writes",
"remaining",
"part",
"of",
"TVP_TYPE_INFO",
"structure",
"resuming",
"from",
"TVP_COLMETADATA"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L2257-L2305 |
denisenkom/pytds | src/pytds/tds_types.py | DeclarationsParser.parse | def parse(self, declaration):
"""
Parse sql type declaration, e.g. varchar(10) and return instance of corresponding type class,
e.g. VarCharType(10)
@param declaration: Sql declaration to parse, e.g. varchar(10)
@return: instance of SqlTypeMetaclass
"""
declarati... | python | def parse(self, declaration):
"""
Parse sql type declaration, e.g. varchar(10) and return instance of corresponding type class,
e.g. VarCharType(10)
@param declaration: Sql declaration to parse, e.g. varchar(10)
@return: instance of SqlTypeMetaclass
"""
declarati... | [
"def",
"parse",
"(",
"self",
",",
"declaration",
")",
":",
"declaration",
"=",
"declaration",
".",
"strip",
"(",
")",
"for",
"regex",
",",
"constructor",
"in",
"self",
".",
"_compiled",
":",
"m",
"=",
"regex",
".",
"match",
"(",
"declaration",
")",
"if... | Parse sql type declaration, e.g. varchar(10) and return instance of corresponding type class,
e.g. VarCharType(10)
@param declaration: Sql declaration to parse, e.g. varchar(10)
@return: instance of SqlTypeMetaclass | [
"Parse",
"sql",
"type",
"declaration",
"e",
".",
"g",
".",
"varchar",
"(",
"10",
")",
"and",
"return",
"instance",
"of",
"corresponding",
"type",
"class",
"e",
".",
"g",
".",
"VarCharType",
"(",
"10",
")"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L2575-L2588 |
denisenkom/pytds | src/pytds/tds_types.py | TdsTypeInferrer.from_value | def from_value(self, value):
""" Function infers TDS type from Python value.
:param value: value from which to infer TDS type
:return: An instance of subclass of :class:`BaseType`
"""
if value is None:
sql_type = NVarCharType(size=1)
else:
sql_typ... | python | def from_value(self, value):
""" Function infers TDS type from Python value.
:param value: value from which to infer TDS type
:return: An instance of subclass of :class:`BaseType`
"""
if value is None:
sql_type = NVarCharType(size=1)
else:
sql_typ... | [
"def",
"from_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"sql_type",
"=",
"NVarCharType",
"(",
"size",
"=",
"1",
")",
"else",
":",
"sql_type",
"=",
"self",
".",
"_from_class_value",
"(",
"value",
",",
"type",
"(",
"... | Function infers TDS type from Python value.
:param value: value from which to infer TDS type
:return: An instance of subclass of :class:`BaseType` | [
"Function",
"infers",
"TDS",
"type",
"from",
"Python",
"value",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L2609-L2619 |
denisenkom/pytds | src/pytds/__init__.py | dict_row_strategy | def dict_row_strategy(column_names):
""" Dict row strategy, rows returned as dictionaries
"""
# replace empty column names with indices
column_names = [(name or idx) for idx, name in enumerate(column_names)]
def row_factory(row):
return dict(zip(column_names, row))
return row_factory | python | def dict_row_strategy(column_names):
""" Dict row strategy, rows returned as dictionaries
"""
# replace empty column names with indices
column_names = [(name or idx) for idx, name in enumerate(column_names)]
def row_factory(row):
return dict(zip(column_names, row))
return row_factory | [
"def",
"dict_row_strategy",
"(",
"column_names",
")",
":",
"# replace empty column names with indices",
"column_names",
"=",
"[",
"(",
"name",
"or",
"idx",
")",
"for",
"idx",
",",
"name",
"in",
"enumerate",
"(",
"column_names",
")",
"]",
"def",
"row_factory",
"(... | Dict row strategy, rows returned as dictionaries | [
"Dict",
"row",
"strategy",
"rows",
"returned",
"as",
"dictionaries"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L88-L97 |
denisenkom/pytds | src/pytds/__init__.py | namedtuple_row_strategy | def namedtuple_row_strategy(column_names):
""" Namedtuple row strategy, rows returned as named tuples
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
import collections
# replace empty column names with placeholders
column_names = [name if is_valid_... | python | def namedtuple_row_strategy(column_names):
""" Namedtuple row strategy, rows returned as named tuples
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
import collections
# replace empty column names with placeholders
column_names = [name if is_valid_... | [
"def",
"namedtuple_row_strategy",
"(",
"column_names",
")",
":",
"import",
"collections",
"# replace empty column names with placeholders",
"column_names",
"=",
"[",
"name",
"if",
"is_valid_identifier",
"(",
"name",
")",
"else",
"'col%s_'",
"%",
"idx",
"for",
"idx",
"... | Namedtuple row strategy, rows returned as named tuples
Column names that are not valid Python identifiers will be replaced
with col<number>_ | [
"Namedtuple",
"row",
"strategy",
"rows",
"returned",
"as",
"named",
"tuples"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L104-L118 |
denisenkom/pytds | src/pytds/__init__.py | recordtype_row_strategy | def recordtype_row_strategy(column_names):
""" Recordtype row strategy, rows returned as recordtypes
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
try:
from namedlist import namedlist as recordtype # optional dependency
except ImportError:
... | python | def recordtype_row_strategy(column_names):
""" Recordtype row strategy, rows returned as recordtypes
Column names that are not valid Python identifiers will be replaced
with col<number>_
"""
try:
from namedlist import namedlist as recordtype # optional dependency
except ImportError:
... | [
"def",
"recordtype_row_strategy",
"(",
"column_names",
")",
":",
"try",
":",
"from",
"namedlist",
"import",
"namedlist",
"as",
"recordtype",
"# optional dependency",
"except",
"ImportError",
":",
"from",
"recordtype",
"import",
"recordtype",
"# optional dependency",
"# ... | Recordtype row strategy, rows returned as recordtypes
Column names that are not valid Python identifiers will be replaced
with col<number>_ | [
"Recordtype",
"row",
"strategy",
"rows",
"returned",
"as",
"recordtypes"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L121-L148 |
denisenkom/pytds | src/pytds/__init__.py | _get_servers_deque | def _get_servers_deque(servers, database):
""" Returns deque of servers for given tuple of servers and
database name.
This deque have active server at the begining, if first server
is not accessible at the moment the deque will be rotated,
second server will be moved to the first position, thirt to ... | python | def _get_servers_deque(servers, database):
""" Returns deque of servers for given tuple of servers and
database name.
This deque have active server at the begining, if first server
is not accessible at the moment the deque will be rotated,
second server will be moved to the first position, thirt to ... | [
"def",
"_get_servers_deque",
"(",
"servers",
",",
"database",
")",
":",
"key",
"=",
"(",
"servers",
",",
"database",
")",
"if",
"key",
"not",
"in",
"_servers_deques",
":",
"_servers_deques",
"[",
"key",
"]",
"=",
"deque",
"(",
"servers",
")",
"return",
"... | Returns deque of servers for given tuple of servers and
database name.
This deque have active server at the begining, if first server
is not accessible at the moment the deque will be rotated,
second server will be moved to the first position, thirt to the
second position etc, and previously first s... | [
"Returns",
"deque",
"of",
"servers",
"for",
"given",
"tuple",
"of",
"servers",
"and",
"database",
"name",
".",
"This",
"deque",
"have",
"active",
"server",
"at",
"the",
"begining",
"if",
"first",
"server",
"is",
"not",
"accessible",
"at",
"the",
"moment",
... | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L1107-L1121 |
denisenkom/pytds | src/pytds/__init__.py | _parse_connection_string | def _parse_connection_string(connstr):
"""
MSSQL style connection string parser
Returns normalized dictionary of connection string parameters
"""
res = {}
for item in connstr.split(';'):
item = item.strip()
if not item:
continue
key, value = item.split('=', 1... | python | def _parse_connection_string(connstr):
"""
MSSQL style connection string parser
Returns normalized dictionary of connection string parameters
"""
res = {}
for item in connstr.split(';'):
item = item.strip()
if not item:
continue
key, value = item.split('=', 1... | [
"def",
"_parse_connection_string",
"(",
"connstr",
")",
":",
"res",
"=",
"{",
"}",
"for",
"item",
"in",
"connstr",
".",
"split",
"(",
"';'",
")",
":",
"item",
"=",
"item",
".",
"strip",
"(",
")",
"if",
"not",
"item",
":",
"continue",
"key",
",",
"v... | MSSQL style connection string parser
Returns normalized dictionary of connection string parameters | [
"MSSQL",
"style",
"connection",
"string",
"parser"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L1124-L1139 |
denisenkom/pytds | src/pytds/__init__.py | connect | def connect(dsn=None, database=None, user=None, password=None, timeout=None,
login_timeout=15, as_dict=None,
appname=None, port=None, tds_version=tds_base.TDS74,
autocommit=False,
blocksize=4096, use_mars=False, auth=None, readonly=False,
load_balancer=None, u... | python | def connect(dsn=None, database=None, user=None, password=None, timeout=None,
login_timeout=15, as_dict=None,
appname=None, port=None, tds_version=tds_base.TDS74,
autocommit=False,
blocksize=4096, use_mars=False, auth=None, readonly=False,
load_balancer=None, u... | [
"def",
"connect",
"(",
"dsn",
"=",
"None",
",",
"database",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"login_timeout",
"=",
"15",
",",
"as_dict",
"=",
"None",
",",
"appname",
"=",
"None",
... | Opens connection to the database
:keyword dsn: SQL server host and instance: <host>[\<instance>]
:type dsn: string
:keyword failover_partner: secondary database host, used if primary is not accessible
:type failover_partner: string
:keyword database: the database to initially connect to
:type d... | [
"Opens",
"connection",
"to",
"the",
"database"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L1142-L1331 |
denisenkom/pytds | src/pytds/__init__.py | Connection.commit | def commit(self):
"""
Commit transaction which is currently in progress.
"""
self._assert_open()
if self._autocommit:
return
if not self._conn.tds72_transaction:
return
self._main_cursor._commit(cont=True, isolation_level=self._isolation_le... | python | def commit(self):
"""
Commit transaction which is currently in progress.
"""
self._assert_open()
if self._autocommit:
return
if not self._conn.tds72_transaction:
return
self._main_cursor._commit(cont=True, isolation_level=self._isolation_le... | [
"def",
"commit",
"(",
"self",
")",
":",
"self",
".",
"_assert_open",
"(",
")",
"if",
"self",
".",
"_autocommit",
":",
"return",
"if",
"not",
"self",
".",
"_conn",
".",
"tds72_transaction",
":",
"return",
"self",
".",
"_main_cursor",
".",
"_commit",
"(",
... | Commit transaction which is currently in progress. | [
"Commit",
"transaction",
"which",
"is",
"currently",
"in",
"progress",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L410-L419 |
denisenkom/pytds | src/pytds/__init__.py | Connection.cursor | def cursor(self):
"""
Return cursor object that can be used to make queries and fetch
results from the database.
"""
self._assert_open()
if self.mars_enabled:
in_tran = self._conn.tds72_transaction
if in_tran and self._dirty:
try:
... | python | def cursor(self):
"""
Return cursor object that can be used to make queries and fetch
results from the database.
"""
self._assert_open()
if self.mars_enabled:
in_tran = self._conn.tds72_transaction
if in_tran and self._dirty:
try:
... | [
"def",
"cursor",
"(",
"self",
")",
":",
"self",
".",
"_assert_open",
"(",
")",
"if",
"self",
".",
"mars_enabled",
":",
"in_tran",
"=",
"self",
".",
"_conn",
".",
"tds72_transaction",
"if",
"in_tran",
"and",
"self",
".",
"_dirty",
":",
"try",
":",
"retu... | Return cursor object that can be used to make queries and fetch
results from the database. | [
"Return",
"cursor",
"object",
"that",
"can",
"be",
"used",
"to",
"make",
"queries",
"and",
"fetch",
"results",
"from",
"the",
"database",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L421-L455 |
denisenkom/pytds | src/pytds/__init__.py | Connection.rollback | def rollback(self):
"""
Roll back transaction which is currently in progress.
"""
try:
if self._autocommit:
return
if not self._conn or not self._conn.is_connected():
return
if not self._conn.tds72_transaction:
... | python | def rollback(self):
"""
Roll back transaction which is currently in progress.
"""
try:
if self._autocommit:
return
if not self._conn or not self._conn.is_connected():
return
if not self._conn.tds72_transaction:
... | [
"def",
"rollback",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_autocommit",
":",
"return",
"if",
"not",
"self",
".",
"_conn",
"or",
"not",
"self",
".",
"_conn",
".",
"is_connected",
"(",
")",
":",
"return",
"if",
"not",
"self",
".",
"_c... | Roll back transaction which is currently in progress. | [
"Roll",
"back",
"transaction",
"which",
"is",
"currently",
"in",
"progress",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L457-L479 |
denisenkom/pytds | src/pytds/__init__.py | Connection.close | def close(self):
""" Close connection to an MS SQL Server.
This function tries to close the connection and free all memory used.
It can be called more than once in a row. No exception is raised in
this case.
"""
if self._conn:
if self._pooling:
... | python | def close(self):
""" Close connection to an MS SQL Server.
This function tries to close the connection and free all memory used.
It can be called more than once in a row. No exception is raised in
this case.
"""
if self._conn:
if self._pooling:
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_conn",
":",
"if",
"self",
".",
"_pooling",
":",
"_connection_pool",
".",
"add",
"(",
"self",
".",
"_key",
",",
"(",
"self",
".",
"_conn",
",",
"self",
".",
"_main_cursor",
".",
"_session",
... | Close connection to an MS SQL Server.
This function tries to close the connection and free all memory used.
It can be called more than once in a row. No exception is raised in
this case. | [
"Close",
"connection",
"to",
"an",
"MS",
"SQL",
"Server",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L481-L496 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.get_proc_outputs | def get_proc_outputs(self):
"""
If stored procedure has result sets and OUTPUT parameters use this method
after you processed all result sets to get values of OUTPUT parameters.
:return: A list of output parameter values.
"""
self._session.complete_rpc()
results ... | python | def get_proc_outputs(self):
"""
If stored procedure has result sets and OUTPUT parameters use this method
after you processed all result sets to get values of OUTPUT parameters.
:return: A list of output parameter values.
"""
self._session.complete_rpc()
results ... | [
"def",
"get_proc_outputs",
"(",
"self",
")",
":",
"self",
".",
"_session",
".",
"complete_rpc",
"(",
")",
"results",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"self",
".",
"_session",
".",
"output_params",
".",
"items",
"(",
")",
")",
"for",
"key",
","... | If stored procedure has result sets and OUTPUT parameters use this method
after you processed all result sets to get values of OUTPUT parameters.
:return: A list of output parameter values. | [
"If",
"stored",
"procedure",
"has",
"result",
"sets",
"and",
"OUTPUT",
"parameters",
"use",
"this",
"method",
"after",
"you",
"processed",
"all",
"result",
"sets",
"to",
"get",
"values",
"of",
"OUTPUT",
"parameters",
".",
":",
"return",
":",
"A",
"list",
"... | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L561-L572 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.callproc | def callproc(self, procname, parameters=()):
"""
Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence
Note: I... | python | def callproc(self, procname, parameters=()):
"""
Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence
Note: I... | [
"def",
"callproc",
"(",
"self",
",",
"procname",
",",
"parameters",
"=",
"(",
")",
")",
":",
"conn",
"=",
"self",
".",
"_assert_open",
"(",
")",
"conn",
".",
"_try_activate_cursor",
"(",
"self",
")",
"return",
"self",
".",
"_callproc",
"(",
"procname",
... | Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence
Note: If stored procedure has OUTPUT parameters and result sets this
... | [
"Call",
"a",
"stored",
"procedure",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L574-L589 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.get_proc_return_status | def get_proc_return_status(self):
""" Last stored proc result
"""
if self._session is None:
return None
if not self._session.has_status:
self._session.find_return_status()
return self._session.ret_status if self._session.has_status else None | python | def get_proc_return_status(self):
""" Last stored proc result
"""
if self._session is None:
return None
if not self._session.has_status:
self._session.find_return_status()
return self._session.ret_status if self._session.has_status else None | [
"def",
"get_proc_return_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"self",
".",
"_session",
".",
"has_status",
":",
"self",
".",
"_session",
".",
"find_return_status",
"(",
")",
"return"... | Last stored proc result | [
"Last",
"stored",
"proc",
"result"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L617-L624 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.cancel | def cancel(self):
""" Cancel current statement
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._session.cancel_if_pending() | python | def cancel(self):
""" Cancel current statement
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._session.cancel_if_pending() | [
"def",
"cancel",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"_assert_open",
"(",
")",
"conn",
".",
"_try_activate_cursor",
"(",
"self",
")",
"self",
".",
"_session",
".",
"cancel_if_pending",
"(",
")"
] | Cancel current statement | [
"Cancel",
"current",
"statement"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L626-L631 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.close | def close(self):
"""
Closes the cursor. The cursor is unusable from this point.
"""
conn = self._conn
if conn is not None:
conn = conn()
if conn is not None:
if self is conn._active_cursor:
conn._active_cursor = conn._main_cursor
... | python | def close(self):
"""
Closes the cursor. The cursor is unusable from this point.
"""
conn = self._conn
if conn is not None:
conn = conn()
if conn is not None:
if self is conn._active_cursor:
conn._active_cursor = conn._main_cursor
... | [
"def",
"close",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"_conn",
"if",
"conn",
"is",
"not",
"None",
":",
"conn",
"=",
"conn",
"(",
")",
"if",
"conn",
"is",
"not",
"None",
":",
"if",
"self",
"is",
"conn",
".",
"_active_cursor",
":",
"conn... | Closes the cursor. The cursor is unusable from this point. | [
"Closes",
"the",
"cursor",
".",
"The",
"cursor",
"is",
"unusable",
"from",
"this",
"point",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L633-L644 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.execute | def execute(self, operation, params=()):
""" Execute the query
:param operation: SQL statement
:type operation: str
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._execute(operation, params)
# for compatibility with pyodbc
ret... | python | def execute(self, operation, params=()):
""" Execute the query
:param operation: SQL statement
:type operation: str
"""
conn = self._assert_open()
conn._try_activate_cursor(self)
self._execute(operation, params)
# for compatibility with pyodbc
ret... | [
"def",
"execute",
"(",
"self",
",",
"operation",
",",
"params",
"=",
"(",
")",
")",
":",
"conn",
"=",
"self",
".",
"_assert_open",
"(",
")",
"conn",
".",
"_try_activate_cursor",
"(",
"self",
")",
"self",
".",
"_execute",
"(",
"operation",
",",
"params"... | Execute the query
:param operation: SQL statement
:type operation: str | [
"Execute",
"the",
"query"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L723-L733 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.execute_scalar | def execute_scalar(self, query_string, params=None):
"""
This method sends a query to the MS SQL Server to which this object
instance is connected, then returns first column of first row from
result. An exception is raised on failure. If there are pending
results or rows prior t... | python | def execute_scalar(self, query_string, params=None):
"""
This method sends a query to the MS SQL Server to which this object
instance is connected, then returns first column of first row from
result. An exception is raised on failure. If there are pending
results or rows prior t... | [
"def",
"execute_scalar",
"(",
"self",
",",
"query_string",
",",
"params",
"=",
"None",
")",
":",
"self",
".",
"execute",
"(",
"query_string",
",",
"params",
")",
"row",
"=",
"self",
".",
"fetchone",
"(",
")",
"if",
"not",
"row",
":",
"return",
"None",
... | This method sends a query to the MS SQL Server to which this object
instance is connected, then returns first column of first row from
result. An exception is raised on failure. If there are pending
results or rows prior to executing this command, they are silently
discarded.
T... | [
"This",
"method",
"sends",
"a",
"query",
"to",
"the",
"MS",
"SQL",
"Server",
"to",
"which",
"this",
"object",
"instance",
"is",
"connected",
"then",
"returns",
"first",
"column",
"of",
"first",
"row",
"from",
"result",
".",
"An",
"exception",
"is",
"raised... | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L761-L785 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.description | def description(self):
""" Cursor description, see http://legacy.python.org/dev/peps/pep-0249/#description
"""
if self._session is None:
return None
res = self._session.res_info
if res:
return res.description
else:
return None | python | def description(self):
""" Cursor description, see http://legacy.python.org/dev/peps/pep-0249/#description
"""
if self._session is None:
return None
res = self._session.res_info
if res:
return res.description
else:
return None | [
"def",
"description",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"None",
":",
"return",
"None",
"res",
"=",
"self",
".",
"_session",
".",
"res_info",
"if",
"res",
":",
"return",
"res",
".",
"description",
"else",
":",
"return",
"None"
... | Cursor description, see http://legacy.python.org/dev/peps/pep-0249/#description | [
"Cursor",
"description",
"see",
"http",
":",
"//",
"legacy",
".",
"python",
".",
"org",
"/",
"dev",
"/",
"peps",
"/",
"pep",
"-",
"0249",
"/",
"#description"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L808-L817 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.messages | def messages(self):
""" Messages generated by server, see http://legacy.python.org/dev/peps/pep-0249/#cursor-messages
"""
if self._session:
result = []
for msg in self._session.messages:
ex = _create_exception_by_message(msg)
result.append(... | python | def messages(self):
""" Messages generated by server, see http://legacy.python.org/dev/peps/pep-0249/#cursor-messages
"""
if self._session:
result = []
for msg in self._session.messages:
ex = _create_exception_by_message(msg)
result.append(... | [
"def",
"messages",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
":",
"result",
"=",
"[",
"]",
"for",
"msg",
"in",
"self",
".",
"_session",
".",
"messages",
":",
"ex",
"=",
"_create_exception_by_message",
"(",
"msg",
")",
"result",
".",
"append... | Messages generated by server, see http://legacy.python.org/dev/peps/pep-0249/#cursor-messages | [
"Messages",
"generated",
"by",
"server",
"see",
"http",
":",
"//",
"legacy",
".",
"python",
".",
"org",
"/",
"dev",
"/",
"peps",
"/",
"pep",
"-",
"0249",
"/",
"#cursor",
"-",
"messages"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L825-L835 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.native_description | def native_description(self):
""" todo document
"""
if self._session is None:
return None
res = self._session.res_info
if res:
return res.native_descr
else:
return None | python | def native_description(self):
""" todo document
"""
if self._session is None:
return None
res = self._session.res_info
if res:
return res.native_descr
else:
return None | [
"def",
"native_description",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"None",
":",
"return",
"None",
"res",
"=",
"self",
".",
"_session",
".",
"res_info",
"if",
"res",
":",
"return",
"res",
".",
"native_descr",
"else",
":",
"return",
... | todo document | [
"todo",
"document"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L838-L847 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.fetchone | def fetchone(self):
""" Fetches next row, or ``None`` if there are no more rows
"""
row = self._session.fetchone()
if row:
return self._row_factory(row) | python | def fetchone(self):
""" Fetches next row, or ``None`` if there are no more rows
"""
row = self._session.fetchone()
if row:
return self._row_factory(row) | [
"def",
"fetchone",
"(",
"self",
")",
":",
"row",
"=",
"self",
".",
"_session",
".",
"fetchone",
"(",
")",
"if",
"row",
":",
"return",
"self",
".",
"_row_factory",
"(",
"row",
")"
] | Fetches next row, or ``None`` if there are no more rows | [
"Fetches",
"next",
"row",
"or",
"None",
"if",
"there",
"are",
"no",
"more",
"rows"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L849-L854 |
denisenkom/pytds | src/pytds/__init__.py | Cursor.copy_to | def copy_to(self, file=None, table_or_view=None, sep='\t', columns=None,
check_constraints=False, fire_triggers=False, keep_nulls=False,
kb_per_batch=None, rows_per_batch=None, order=None, tablock=False,
schema=None, null_string=None, data=None):
""" *Experimental... | python | def copy_to(self, file=None, table_or_view=None, sep='\t', columns=None,
check_constraints=False, fire_triggers=False, keep_nulls=False,
kb_per_batch=None, rows_per_batch=None, order=None, tablock=False,
schema=None, null_string=None, data=None):
""" *Experimental... | [
"def",
"copy_to",
"(",
"self",
",",
"file",
"=",
"None",
",",
"table_or_view",
"=",
"None",
",",
"sep",
"=",
"'\\t'",
",",
"columns",
"=",
"None",
",",
"check_constraints",
"=",
"False",
",",
"fire_triggers",
"=",
"False",
",",
"keep_nulls",
"=",
"False"... | *Experimental*. Efficiently load data to database from file using ``BULK INSERT`` operation
:param file: Source file-like object, should be in csv format. Specify
either this or data, not both.
:param table_or_view: Destination table or view in the database
:type table_or_view: str
... | [
"*",
"Experimental",
"*",
".",
"Efficiently",
"load",
"data",
"to",
"database",
"from",
"file",
"using",
"BULK",
"INSERT",
"operation"
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L898-L1003 |
denisenkom/pytds | src/pytds/__init__.py | _MarsCursor.close | def close(self):
"""
Closes the cursor. The cursor is unusable from this point.
"""
if self._session is not None:
try:
self._session.close()
self._session = None
except socket.error as e:
if e.errno != errno.ECONNRES... | python | def close(self):
"""
Closes the cursor. The cursor is unusable from this point.
"""
if self._session is not None:
try:
self._session.close()
self._session = None
except socket.error as e:
if e.errno != errno.ECONNRES... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"_session",
".",
"close",
"(",
")",
"self",
".",
"_session",
"=",
"None",
"except",
"socket",
".",
"error",
"as",
"e",
":",
"... | Closes the cursor. The cursor is unusable from this point. | [
"Closes",
"the",
"cursor",
".",
"The",
"cursor",
"is",
"unusable",
"from",
"this",
"point",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L1031-L1041 |
denisenkom/pytds | src/pytds/__init__.py | _MarsCursor.callproc | def callproc(self, procname, parameters=()):
"""
Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence
"""
... | python | def callproc(self, procname, parameters=()):
"""
Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence
"""
... | [
"def",
"callproc",
"(",
"self",
",",
"procname",
",",
"parameters",
"=",
"(",
")",
")",
":",
"self",
".",
"_assert_open",
"(",
")",
"return",
"self",
".",
"_callproc",
"(",
"procname",
",",
"parameters",
")"
] | Call a stored procedure with the given name.
:param procname: The name of the procedure to call
:type procname: str
:keyword parameters: The optional parameters for the procedure
:type parameters: sequence | [
"Call",
"a",
"stored",
"procedure",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L1049-L1059 |
galaxyproject/pulsar | pulsar/managers/base/__init__.py | __posix_to_local_path | def __posix_to_local_path(path, local_path_module=os.path):
"""
Converts a posix path (coming from Galaxy), to a local path (be it posix or Windows).
>>> import ntpath
>>> __posix_to_local_path('dataset_1_files/moo/cow', local_path_module=ntpath)
'dataset_1_files\\\\moo\\\\cow'
>>> import posix... | python | def __posix_to_local_path(path, local_path_module=os.path):
"""
Converts a posix path (coming from Galaxy), to a local path (be it posix or Windows).
>>> import ntpath
>>> __posix_to_local_path('dataset_1_files/moo/cow', local_path_module=ntpath)
'dataset_1_files\\\\moo\\\\cow'
>>> import posix... | [
"def",
"__posix_to_local_path",
"(",
"path",
",",
"local_path_module",
"=",
"os",
".",
"path",
")",
":",
"partial_path",
"=",
"deque",
"(",
")",
"while",
"True",
":",
"if",
"not",
"path",
"or",
"path",
"==",
"'/'",
":",
"break",
"(",
"path",
",",
"base... | Converts a posix path (coming from Galaxy), to a local path (be it posix or Windows).
>>> import ntpath
>>> __posix_to_local_path('dataset_1_files/moo/cow', local_path_module=ntpath)
'dataset_1_files\\\\moo\\\\cow'
>>> import posixpath
>>> __posix_to_local_path('dataset_1_files/moo/cow', local_path... | [
"Converts",
"a",
"posix",
"path",
"(",
"coming",
"from",
"Galaxy",
")",
"to",
"a",
"local",
"path",
"(",
"be",
"it",
"posix",
"or",
"Windows",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/base/__init__.py#L373-L390 |
galaxyproject/pulsar | pulsar/managers/base/__init__.py | JobDirectory.calculate_path | def calculate_path(self, remote_path, input_type):
""" Verify remote_path is in directory for input_type inputs
and create directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
path = get_mapped_file(directory, remote_path, allow_neste... | python | def calculate_path(self, remote_path, input_type):
""" Verify remote_path is in directory for input_type inputs
and create directory if needed.
"""
directory, allow_nested_files = self._directory_for_file_type(input_type)
path = get_mapped_file(directory, remote_path, allow_neste... | [
"def",
"calculate_path",
"(",
"self",
",",
"remote_path",
",",
"input_type",
")",
":",
"directory",
",",
"allow_nested_files",
"=",
"self",
".",
"_directory_for_file_type",
"(",
"input_type",
")",
"path",
"=",
"get_mapped_file",
"(",
"directory",
",",
"remote_path... | Verify remote_path is in directory for input_type inputs
and create directory if needed. | [
"Verify",
"remote_path",
"is",
"in",
"directory",
"for",
"input_type",
"inputs",
"and",
"create",
"directory",
"if",
"needed",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/base/__init__.py#L231-L237 |
galaxyproject/pulsar | pulsar/client/client.py | BaseJobClient.setup | def setup(self, tool_id=None, tool_version=None, preserve_galaxy_python_environment=None):
"""
Setup remote Pulsar server to run this job.
"""
setup_args = {"job_id": self.job_id}
if tool_id:
setup_args["tool_id"] = tool_id
if tool_version:
setup_a... | python | def setup(self, tool_id=None, tool_version=None, preserve_galaxy_python_environment=None):
"""
Setup remote Pulsar server to run this job.
"""
setup_args = {"job_id": self.job_id}
if tool_id:
setup_args["tool_id"] = tool_id
if tool_version:
setup_a... | [
"def",
"setup",
"(",
"self",
",",
"tool_id",
"=",
"None",
",",
"tool_version",
"=",
"None",
",",
"preserve_galaxy_python_environment",
"=",
"None",
")",
":",
"setup_args",
"=",
"{",
"\"job_id\"",
":",
"self",
".",
"job_id",
"}",
"if",
"tool_id",
":",
"setu... | Setup remote Pulsar server to run this job. | [
"Setup",
"remote",
"Pulsar",
"server",
"to",
"run",
"this",
"job",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/client.py#L66-L77 |
galaxyproject/pulsar | pulsar/client/client.py | JobClient.launch | def launch(self, command_line, dependencies_description=None, env=[], remote_staging=[], job_config=None):
"""
Queue up the execution of the supplied `command_line` on the remote
server. Called launch for historical reasons, should be renamed to
enqueue or something like that.
*... | python | def launch(self, command_line, dependencies_description=None, env=[], remote_staging=[], job_config=None):
"""
Queue up the execution of the supplied `command_line` on the remote
server. Called launch for historical reasons, should be renamed to
enqueue or something like that.
*... | [
"def",
"launch",
"(",
"self",
",",
"command_line",
",",
"dependencies_description",
"=",
"None",
",",
"env",
"=",
"[",
"]",
",",
"remote_staging",
"=",
"[",
"]",
",",
"job_config",
"=",
"None",
")",
":",
"launch_params",
"=",
"dict",
"(",
"command_line",
... | Queue up the execution of the supplied `command_line` on the remote
server. Called launch for historical reasons, should be renamed to
enqueue or something like that.
**Parameters**
command_line : str
Command to execute. | [
"Queue",
"up",
"the",
"execution",
"of",
"the",
"supplied",
"command_line",
"on",
"the",
"remote",
"server",
".",
"Called",
"launch",
"for",
"historical",
"reasons",
"should",
"be",
"renamed",
"to",
"enqueue",
"or",
"something",
"like",
"that",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/client.py#L102-L133 |
galaxyproject/pulsar | pulsar/client/client.py | JobClient.fetch_output | def fetch_output(self, path, name, working_directory, action_type, output_type):
"""
Fetch (transfer, copy, etc...) an output from the remote Pulsar server.
**Parameters**
path : str
Local path of the dataset.
name : str
Remote name of file (i.e. path re... | python | def fetch_output(self, path, name, working_directory, action_type, output_type):
"""
Fetch (transfer, copy, etc...) an output from the remote Pulsar server.
**Parameters**
path : str
Local path of the dataset.
name : str
Remote name of file (i.e. path re... | [
"def",
"fetch_output",
"(",
"self",
",",
"path",
",",
"name",
",",
"working_directory",
",",
"action_type",
",",
"output_type",
")",
":",
"if",
"output_type",
"in",
"[",
"'output_workdir'",
",",
"'output_metadata'",
"]",
":",
"self",
".",
"_populate_output_path"... | Fetch (transfer, copy, etc...) an output from the remote Pulsar server.
**Parameters**
path : str
Local path of the dataset.
name : str
Remote name of file (i.e. path relative to remote staging output
or working directory).
working_directory : str
... | [
"Fetch",
"(",
"transfer",
"copy",
"etc",
"...",
")",
"an",
"output",
"from",
"the",
"remote",
"Pulsar",
"server",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/client.py#L196-L220 |
galaxyproject/pulsar | pulsar/managers/queued_drmaa_xsede.py | check_output | def check_output(args):
"""Pipe-safe (and 2.6 compatible) version of subprocess.check_output
"""
proc = Popen(args, stdout=PIPE)
out = proc.communicate()[0]
if proc.returncode:
raise CalledProcessError(proc.returncode, args, output=out)
return out | python | def check_output(args):
"""Pipe-safe (and 2.6 compatible) version of subprocess.check_output
"""
proc = Popen(args, stdout=PIPE)
out = proc.communicate()[0]
if proc.returncode:
raise CalledProcessError(proc.returncode, args, output=out)
return out | [
"def",
"check_output",
"(",
"args",
")",
":",
"proc",
"=",
"Popen",
"(",
"args",
",",
"stdout",
"=",
"PIPE",
")",
"out",
"=",
"proc",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
"if",
"proc",
".",
"returncode",
":",
"raise",
"CalledProcessError",
"(... | Pipe-safe (and 2.6 compatible) version of subprocess.check_output | [
"Pipe",
"-",
"safe",
"(",
"and",
"2",
".",
"6",
"compatible",
")",
"version",
"of",
"subprocess",
".",
"check_output"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/queued_drmaa_xsede.py#L42-L49 |
galaxyproject/pulsar | pulsar/client/action_mapper.py | FileActionMapper.unstructured_mappers | def unstructured_mappers(self):
""" Return mappers that will map 'unstructured' files (i.e. go beyond
mapping inputs, outputs, and config files).
"""
return filter(lambda m: path_type.UNSTRUCTURED in m.path_types, self.mappers) | python | def unstructured_mappers(self):
""" Return mappers that will map 'unstructured' files (i.e. go beyond
mapping inputs, outputs, and config files).
"""
return filter(lambda m: path_type.UNSTRUCTURED in m.path_types, self.mappers) | [
"def",
"unstructured_mappers",
"(",
"self",
")",
":",
"return",
"filter",
"(",
"lambda",
"m",
":",
"path_type",
".",
"UNSTRUCTURED",
"in",
"m",
".",
"path_types",
",",
"self",
".",
"mappers",
")"
] | Return mappers that will map 'unstructured' files (i.e. go beyond
mapping inputs, outputs, and config files). | [
"Return",
"mappers",
"that",
"will",
"map",
"unstructured",
"files",
"(",
"i",
".",
"e",
".",
"go",
"beyond",
"mapping",
"inputs",
"outputs",
"and",
"config",
"files",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/action_mapper.py#L177-L181 |
galaxyproject/pulsar | pulsar/client/action_mapper.py | FileActionMapper.__process_action | def __process_action(self, action, file_type):
""" Extension point to populate extra action information after an
action has been created.
"""
if getattr(action, "inject_url", False):
self.__inject_url(action, file_type)
if getattr(action, "inject_ssh_properties", Fals... | python | def __process_action(self, action, file_type):
""" Extension point to populate extra action information after an
action has been created.
"""
if getattr(action, "inject_url", False):
self.__inject_url(action, file_type)
if getattr(action, "inject_ssh_properties", Fals... | [
"def",
"__process_action",
"(",
"self",
",",
"action",
",",
"file_type",
")",
":",
"if",
"getattr",
"(",
"action",
",",
"\"inject_url\"",
",",
"False",
")",
":",
"self",
".",
"__inject_url",
"(",
"action",
",",
"file_type",
")",
"if",
"getattr",
"(",
"ac... | Extension point to populate extra action information after an
action has been created. | [
"Extension",
"point",
"to",
"populate",
"extra",
"action",
"information",
"after",
"an",
"action",
"has",
"been",
"created",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/action_mapper.py#L235-L242 |
galaxyproject/pulsar | pulsar/managers/util/kill.py | _psutil_kill_pid | def _psutil_kill_pid(pid):
"""
http://stackoverflow.com/questions/1230669/subprocess-deleting-child-processes-in-windows
"""
try:
parent = Process(pid)
for child in parent.children(recursive=True):
child.kill()
parent.kill()
except NoSuchProcess:
return | python | def _psutil_kill_pid(pid):
"""
http://stackoverflow.com/questions/1230669/subprocess-deleting-child-processes-in-windows
"""
try:
parent = Process(pid)
for child in parent.children(recursive=True):
child.kill()
parent.kill()
except NoSuchProcess:
return | [
"def",
"_psutil_kill_pid",
"(",
"pid",
")",
":",
"try",
":",
"parent",
"=",
"Process",
"(",
"pid",
")",
"for",
"child",
"in",
"parent",
".",
"children",
"(",
"recursive",
"=",
"True",
")",
":",
"child",
".",
"kill",
"(",
")",
"parent",
".",
"kill",
... | http://stackoverflow.com/questions/1230669/subprocess-deleting-child-processes-in-windows | [
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"1230669",
"/",
"subprocess",
"-",
"deleting",
"-",
"child",
"-",
"processes",
"-",
"in",
"-",
"windows"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/kill.py#L20-L30 |
galaxyproject/pulsar | pulsar/managers/util/external.py | parse_external_id | def parse_external_id(output, type=EXTERNAL_ID_TYPE_ANY):
"""
Attempt to parse the output of job submission commands for an external id.__doc__
>>> parse_external_id("12345.pbsmanager")
'12345.pbsmanager'
>>> parse_external_id('Submitted batch job 185')
'185'
>>> parse_external_id('Submitte... | python | def parse_external_id(output, type=EXTERNAL_ID_TYPE_ANY):
"""
Attempt to parse the output of job submission commands for an external id.__doc__
>>> parse_external_id("12345.pbsmanager")
'12345.pbsmanager'
>>> parse_external_id('Submitted batch job 185')
'185'
>>> parse_external_id('Submitte... | [
"def",
"parse_external_id",
"(",
"output",
",",
"type",
"=",
"EXTERNAL_ID_TYPE_ANY",
")",
":",
"external_id",
"=",
"None",
"for",
"pattern_type",
",",
"pattern",
"in",
"EXTERNAL_ID_PATTERNS",
":",
"if",
"type",
"!=",
"EXTERNAL_ID_TYPE_ANY",
"and",
"type",
"!=",
... | Attempt to parse the output of job submission commands for an external id.__doc__
>>> parse_external_id("12345.pbsmanager")
'12345.pbsmanager'
>>> parse_external_id('Submitted batch job 185')
'185'
>>> parse_external_id('Submitted batch job 185', type='torque')
'Submitted batch job 185'
>>>... | [
"Attempt",
"to",
"parse",
"the",
"output",
"of",
"job",
"submission",
"commands",
"for",
"an",
"external",
"id",
".",
"__doc__"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/external.py#L12-L37 |
galaxyproject/pulsar | pulsar/managers/queued_external_drmaa.py | _handle_default | def _handle_default(value, script_name):
""" There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer s... | python | def _handle_default(value, script_name):
""" There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer s... | [
"def",
"_handle_default",
"(",
"value",
",",
"script_name",
")",
":",
"if",
"value",
":",
"return",
"value",
"installed_script",
"=",
"which",
"(",
"\"pulsar-%s\"",
"%",
"script_name",
".",
"replace",
"(",
"\"_\"",
",",
"\"-\"",
")",
")",
"if",
"installed_sc... | There are two potential variants of these scripts,
the Bash scripts that are meant to be run within PULSAR_ROOT
for older-style installs and the binaries created by setup.py
as part of a proper pulsar installation.
This method first looks for the newer style variant of these
scripts and returns the... | [
"There",
"are",
"two",
"potential",
"variants",
"of",
"these",
"scripts",
"the",
"Bash",
"scripts",
"that",
"are",
"meant",
"to",
"be",
"run",
"within",
"PULSAR_ROOT",
"for",
"older",
"-",
"style",
"installs",
"and",
"the",
"binaries",
"created",
"by",
"setu... | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/queued_external_drmaa.py#L91-L108 |
galaxyproject/pulsar | pulsar/client/staging/up.py | _read | def _read(path):
"""
Utility method to quickly read small files (config files and tool
wrappers) into memory as bytes.
"""
input = open(path, "r", encoding="utf-8")
try:
return input.read()
finally:
input.close() | python | def _read(path):
"""
Utility method to quickly read small files (config files and tool
wrappers) into memory as bytes.
"""
input = open(path, "r", encoding="utf-8")
try:
return input.read()
finally:
input.close() | [
"def",
"_read",
"(",
"path",
")",
":",
"input",
"=",
"open",
"(",
"path",
",",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"try",
":",
"return",
"input",
".",
"read",
"(",
")",
"finally",
":",
"input",
".",
"close",
"(",
")"
] | Utility method to quickly read small files (config files and tool
wrappers) into memory as bytes. | [
"Utility",
"method",
"to",
"quickly",
"read",
"small",
"files",
"(",
"config",
"files",
"and",
"tool",
"wrappers",
")",
"into",
"memory",
"as",
"bytes",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/up.py#L487-L496 |
galaxyproject/pulsar | pulsar/client/staging/up.py | JobInputs.find_referenced_subfiles | def find_referenced_subfiles(self, directory):
"""
Return list of files below specified `directory` in job inputs. Could
use more sophisticated logic (match quotes to handle spaces, handle
subdirectories, etc...).
**Parameters**
directory : str
Full path to ... | python | def find_referenced_subfiles(self, directory):
"""
Return list of files below specified `directory` in job inputs. Could
use more sophisticated logic (match quotes to handle spaces, handle
subdirectories, etc...).
**Parameters**
directory : str
Full path to ... | [
"def",
"find_referenced_subfiles",
"(",
"self",
",",
"directory",
")",
":",
"if",
"directory",
"is",
"None",
":",
"return",
"[",
"]",
"pattern",
"=",
"r'''[\\'\\\"]?(%s%s[^\\s\\'\\\"]+)[\\'\\\"]?'''",
"%",
"(",
"escape",
"(",
"directory",
")",
",",
"escape",
"("... | Return list of files below specified `directory` in job inputs. Could
use more sophisticated logic (match quotes to handle spaces, handle
subdirectories, etc...).
**Parameters**
directory : str
Full path to directory to search. | [
"Return",
"list",
"of",
"files",
"below",
"specified",
"directory",
"in",
"job",
"inputs",
".",
"Could",
"use",
"more",
"sophisticated",
"logic",
"(",
"match",
"quotes",
"to",
"handle",
"spaces",
"handle",
"subdirectories",
"etc",
"...",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/up.py#L360-L376 |
galaxyproject/pulsar | pulsar/client/staging/up.py | JobInputs.rewrite_paths | def rewrite_paths(self, local_path, remote_path):
"""
Rewrite references to `local_path` with `remote_path` in job inputs.
"""
self.__rewrite_command_line(local_path, remote_path)
self.__rewrite_config_files(local_path, remote_path) | python | def rewrite_paths(self, local_path, remote_path):
"""
Rewrite references to `local_path` with `remote_path` in job inputs.
"""
self.__rewrite_command_line(local_path, remote_path)
self.__rewrite_config_files(local_path, remote_path) | [
"def",
"rewrite_paths",
"(",
"self",
",",
"local_path",
",",
"remote_path",
")",
":",
"self",
".",
"__rewrite_command_line",
"(",
"local_path",
",",
"remote_path",
")",
"self",
".",
"__rewrite_config_files",
"(",
"local_path",
",",
"remote_path",
")"
] | Rewrite references to `local_path` with `remote_path` in job inputs. | [
"Rewrite",
"references",
"to",
"local_path",
"with",
"remote_path",
"in",
"job",
"inputs",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/up.py#L387-L392 |
galaxyproject/pulsar | pulsar/client/staging/up.py | TransferTracker.rewrite_input_paths | def rewrite_input_paths(self):
"""
For each file that has been transferred and renamed, updated
command_line and configfiles to reflect that rewrite.
"""
for local_path, remote_path in self.file_renames.items():
self.job_inputs.rewrite_paths(local_path, remote_path) | python | def rewrite_input_paths(self):
"""
For each file that has been transferred and renamed, updated
command_line and configfiles to reflect that rewrite.
"""
for local_path, remote_path in self.file_renames.items():
self.job_inputs.rewrite_paths(local_path, remote_path) | [
"def",
"rewrite_input_paths",
"(",
"self",
")",
":",
"for",
"local_path",
",",
"remote_path",
"in",
"self",
".",
"file_renames",
".",
"items",
"(",
")",
":",
"self",
".",
"job_inputs",
".",
"rewrite_paths",
"(",
"local_path",
",",
"remote_path",
")"
] | For each file that has been transferred and renamed, updated
command_line and configfiles to reflect that rewrite. | [
"For",
"each",
"file",
"that",
"has",
"been",
"transferred",
"and",
"renamed",
"updated",
"command_line",
"and",
"configfiles",
"to",
"reflect",
"that",
"rewrite",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/up.py#L475-L481 |
galaxyproject/pulsar | pulsar/client/amqp_exchange.py | PulsarExchange.__get_payload | def __get_payload(self, uuid, failed):
"""Retry reading a message from the publish_uuid_store once, delete on the second failure."""
# Caller should have the publish_uuid_store lock
try:
return self.publish_uuid_store[uuid]
except Exception as exc:
msg = "Failed t... | python | def __get_payload(self, uuid, failed):
"""Retry reading a message from the publish_uuid_store once, delete on the second failure."""
# Caller should have the publish_uuid_store lock
try:
return self.publish_uuid_store[uuid]
except Exception as exc:
msg = "Failed t... | [
"def",
"__get_payload",
"(",
"self",
",",
"uuid",
",",
"failed",
")",
":",
"# Caller should have the publish_uuid_store lock",
"try",
":",
"return",
"self",
".",
"publish_uuid_store",
"[",
"uuid",
"]",
"except",
"Exception",
"as",
"exc",
":",
"msg",
"=",
"\"Fail... | Retry reading a message from the publish_uuid_store once, delete on the second failure. | [
"Retry",
"reading",
"a",
"message",
"from",
"the",
"publish_uuid_store",
"once",
"delete",
"on",
"the",
"second",
"failure",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/amqp_exchange.py#L239-L252 |
galaxyproject/pulsar | pulsar/manager_endpoint_util.py | __job_complete_dict | def __job_complete_dict(complete_status, manager, job_id):
""" Build final dictionary describing completed job for consumption by
Pulsar client.
"""
return_code = manager.return_code(job_id)
if return_code == PULSAR_UNKNOWN_RETURN_CODE:
return_code = None
stdout_contents = manager.stdout... | python | def __job_complete_dict(complete_status, manager, job_id):
""" Build final dictionary describing completed job for consumption by
Pulsar client.
"""
return_code = manager.return_code(job_id)
if return_code == PULSAR_UNKNOWN_RETURN_CODE:
return_code = None
stdout_contents = manager.stdout... | [
"def",
"__job_complete_dict",
"(",
"complete_status",
",",
"manager",
",",
"job_id",
")",
":",
"return_code",
"=",
"manager",
".",
"return_code",
"(",
"job_id",
")",
"if",
"return_code",
"==",
"PULSAR_UNKNOWN_RETURN_CODE",
":",
"return_code",
"=",
"None",
"stdout_... | Build final dictionary describing completed job for consumption by
Pulsar client. | [
"Build",
"final",
"dictionary",
"describing",
"completed",
"job",
"for",
"consumption",
"by",
"Pulsar",
"client",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/manager_endpoint_util.py#L29-L54 |
galaxyproject/pulsar | pulsar/manager_endpoint_util.py | submit_job | def submit_job(manager, job_config):
""" Launch new job from specified config. May have been previously 'setup'
if 'setup_params' in job_config is empty.
"""
# job_config is raw dictionary from JSON (from MQ or HTTP endpoint).
job_id = job_config.get('job_id')
try:
command_line = job_con... | python | def submit_job(manager, job_config):
""" Launch new job from specified config. May have been previously 'setup'
if 'setup_params' in job_config is empty.
"""
# job_config is raw dictionary from JSON (from MQ or HTTP endpoint).
job_id = job_config.get('job_id')
try:
command_line = job_con... | [
"def",
"submit_job",
"(",
"manager",
",",
"job_config",
")",
":",
"# job_config is raw dictionary from JSON (from MQ or HTTP endpoint).",
"job_id",
"=",
"job_config",
".",
"get",
"(",
"'job_id'",
")",
"try",
":",
"command_line",
"=",
"job_config",
".",
"get",
"(",
"... | Launch new job from specified config. May have been previously 'setup'
if 'setup_params' in job_config is empty. | [
"Launch",
"new",
"job",
"from",
"specified",
"config",
".",
"May",
"have",
"been",
"previously",
"setup",
"if",
"setup_params",
"in",
"job_config",
"is",
"empty",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/manager_endpoint_util.py#L57-L105 |
galaxyproject/pulsar | pulsar/manager_endpoint_util.py | setup_job | def setup_job(manager, job_id, tool_id, tool_version, use_metadata=False):
""" Setup new job from these inputs and return dict summarizing state
(used to configure command line).
"""
job_id = manager.setup_job(job_id, tool_id, tool_version)
if use_metadata:
manager.enable_metadata_directory(... | python | def setup_job(manager, job_id, tool_id, tool_version, use_metadata=False):
""" Setup new job from these inputs and return dict summarizing state
(used to configure command line).
"""
job_id = manager.setup_job(job_id, tool_id, tool_version)
if use_metadata:
manager.enable_metadata_directory(... | [
"def",
"setup_job",
"(",
"manager",
",",
"job_id",
",",
"tool_id",
",",
"tool_version",
",",
"use_metadata",
"=",
"False",
")",
":",
"job_id",
"=",
"manager",
".",
"setup_job",
"(",
"job_id",
",",
"tool_id",
",",
"tool_version",
")",
"if",
"use_metadata",
... | Setup new job from these inputs and return dict summarizing state
(used to configure command line). | [
"Setup",
"new",
"job",
"from",
"these",
"inputs",
"and",
"return",
"dict",
"summarizing",
"state",
"(",
"used",
"to",
"configure",
"command",
"line",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/manager_endpoint_util.py#L108-L121 |
galaxyproject/pulsar | pulsar/core.py | PulsarApp.__setup_tool_config | def __setup_tool_config(self, conf):
"""
Setups toolbox object and authorization mechanism based
on supplied toolbox_path.
"""
tool_config_files = conf.get("tool_config_files", None)
if not tool_config_files:
# For compatibity with Galaxy, allow tool_config_fi... | python | def __setup_tool_config(self, conf):
"""
Setups toolbox object and authorization mechanism based
on supplied toolbox_path.
"""
tool_config_files = conf.get("tool_config_files", None)
if not tool_config_files:
# For compatibity with Galaxy, allow tool_config_fi... | [
"def",
"__setup_tool_config",
"(",
"self",
",",
"conf",
")",
":",
"tool_config_files",
"=",
"conf",
".",
"get",
"(",
"\"tool_config_files\"",
",",
"None",
")",
"if",
"not",
"tool_config_files",
":",
"# For compatibity with Galaxy, allow tool_config_file",
"# option name... | Setups toolbox object and authorization mechanism based
on supplied toolbox_path. | [
"Setups",
"toolbox",
"object",
"and",
"authorization",
"mechanism",
"based",
"on",
"supplied",
"toolbox_path",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/core.py#L67-L83 |
galaxyproject/pulsar | pulsar/core.py | PulsarApp.only_manager | def only_manager(self):
"""Convience accessor for tests and contexts with sole manager."""
assert len(self.managers) == 1, MULTIPLE_MANAGERS_MESSAGE
return list(self.managers.values())[0] | python | def only_manager(self):
"""Convience accessor for tests and contexts with sole manager."""
assert len(self.managers) == 1, MULTIPLE_MANAGERS_MESSAGE
return list(self.managers.values())[0] | [
"def",
"only_manager",
"(",
"self",
")",
":",
"assert",
"len",
"(",
"self",
".",
"managers",
")",
"==",
"1",
",",
"MULTIPLE_MANAGERS_MESSAGE",
"return",
"list",
"(",
"self",
".",
"managers",
".",
"values",
"(",
")",
")",
"[",
"0",
"]"
] | Convience accessor for tests and contexts with sole manager. | [
"Convience",
"accessor",
"for",
"tests",
"and",
"contexts",
"with",
"sole",
"manager",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/core.py#L138-L141 |
galaxyproject/pulsar | pulsar/web/wsgi.py | app_factory | def app_factory(global_conf, **local_conf):
"""
Returns the Pulsar WSGI application.
"""
configuration_file = global_conf.get("__file__", None)
webapp = init_webapp(ini_path=configuration_file, local_conf=local_conf)
return webapp | python | def app_factory(global_conf, **local_conf):
"""
Returns the Pulsar WSGI application.
"""
configuration_file = global_conf.get("__file__", None)
webapp = init_webapp(ini_path=configuration_file, local_conf=local_conf)
return webapp | [
"def",
"app_factory",
"(",
"global_conf",
",",
"*",
"*",
"local_conf",
")",
":",
"configuration_file",
"=",
"global_conf",
".",
"get",
"(",
"\"__file__\"",
",",
"None",
")",
"webapp",
"=",
"init_webapp",
"(",
"ini_path",
"=",
"configuration_file",
",",
"local_... | Returns the Pulsar WSGI application. | [
"Returns",
"the",
"Pulsar",
"WSGI",
"application",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/web/wsgi.py#L14-L20 |
galaxyproject/pulsar | pulsar/managers/queued.py | QueueManager.run_next | def run_next(self):
"""
Run the next item in the queue (a job waiting to run).
"""
while 1:
(op, obj) = self.work_queue.get()
if op is STOP_SIGNAL:
return
try:
(job_id, command_line) = obj
try:
... | python | def run_next(self):
"""
Run the next item in the queue (a job waiting to run).
"""
while 1:
(op, obj) = self.work_queue.get()
if op is STOP_SIGNAL:
return
try:
(job_id, command_line) = obj
try:
... | [
"def",
"run_next",
"(",
"self",
")",
":",
"while",
"1",
":",
"(",
"op",
",",
"obj",
")",
"=",
"self",
".",
"work_queue",
".",
"get",
"(",
")",
"if",
"op",
"is",
"STOP_SIGNAL",
":",
"return",
"try",
":",
"(",
"job_id",
",",
"command_line",
")",
"=... | Run the next item in the queue (a job waiting to run). | [
"Run",
"the",
"next",
"item",
"in",
"the",
"queue",
"(",
"a",
"job",
"waiting",
"to",
"run",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/queued.py#L77-L95 |
galaxyproject/pulsar | tools/install_venv.py | check_dependencies | def check_dependencies():
"""Make sure virtualenv is in the path."""
print 'Checking dependencies...'
if not HAS_VIRTUALENV:
print 'Virtual environment not found.'
# Try installing it via easy_install...
if HAS_EASY_INSTALL:
print 'Installing virtualenv via easy_install.... | python | def check_dependencies():
"""Make sure virtualenv is in the path."""
print 'Checking dependencies...'
if not HAS_VIRTUALENV:
print 'Virtual environment not found.'
# Try installing it via easy_install...
if HAS_EASY_INSTALL:
print 'Installing virtualenv via easy_install.... | [
"def",
"check_dependencies",
"(",
")",
":",
"print",
"'Checking dependencies...'",
"if",
"not",
"HAS_VIRTUALENV",
":",
"print",
"'Virtual environment not found.'",
"# Try installing it via easy_install...",
"if",
"HAS_EASY_INSTALL",
":",
"print",
"'Installing virtualenv via easy_... | Make sure virtualenv is in the path. | [
"Make",
"sure",
"virtualenv",
"is",
"in",
"the",
"path",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/tools/install_venv.py#L66-L89 |
galaxyproject/pulsar | tools/install_venv.py | create_virtualenv | def create_virtualenv(venv=VENV):
"""Creates the virtual environment and installs PIP only into the
virtual environment
"""
print 'Creating venv...',
run_command(['virtualenv', '-q', '--no-site-packages', VENV])
print 'done.'
print 'Installing pip in virtualenv...',
if not run_command([W... | python | def create_virtualenv(venv=VENV):
"""Creates the virtual environment and installs PIP only into the
virtual environment
"""
print 'Creating venv...',
run_command(['virtualenv', '-q', '--no-site-packages', VENV])
print 'done.'
print 'Installing pip in virtualenv...',
if not run_command([W... | [
"def",
"create_virtualenv",
"(",
"venv",
"=",
"VENV",
")",
":",
"print",
"'Creating venv...'",
",",
"run_command",
"(",
"[",
"'virtualenv'",
",",
"'-q'",
",",
"'--no-site-packages'",
",",
"VENV",
"]",
")",
"print",
"'done.'",
"print",
"'Installing pip in virtualen... | Creates the virtual environment and installs PIP only into the
virtual environment | [
"Creates",
"the",
"virtual",
"environment",
"and",
"installs",
"PIP",
"only",
"into",
"the",
"virtual",
"environment"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/tools/install_venv.py#L92-L105 |
galaxyproject/pulsar | pulsar/client/path_mapper.py | PathMapper.__remote_path_rewrite | def __remote_path_rewrite(self, dataset_path, dataset_path_type, name=None):
""" Return remote path of this file (if staging is required) else None.
"""
path = str(dataset_path) # Use false_path if needed.
action = self.action_mapper.action(path, dataset_path_type)
if action.sta... | python | def __remote_path_rewrite(self, dataset_path, dataset_path_type, name=None):
""" Return remote path of this file (if staging is required) else None.
"""
path = str(dataset_path) # Use false_path if needed.
action = self.action_mapper.action(path, dataset_path_type)
if action.sta... | [
"def",
"__remote_path_rewrite",
"(",
"self",
",",
"dataset_path",
",",
"dataset_path_type",
",",
"name",
"=",
"None",
")",
":",
"path",
"=",
"str",
"(",
"dataset_path",
")",
"# Use false_path if needed.",
"action",
"=",
"self",
".",
"action_mapper",
".",
"action... | Return remote path of this file (if staging is required) else None. | [
"Return",
"remote",
"path",
"of",
"this",
"file",
"(",
"if",
"staging",
"is",
"required",
")",
"else",
"None",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/path_mapper.py#L67-L82 |
galaxyproject/pulsar | pulsar/managers/util/retry.py | _retry_over_time | def _retry_over_time(fun, catch, args=[], kwargs={}, errback=None,
max_retries=None, interval_start=2, interval_step=2,
interval_max=30):
"""Retry the function over and over until max retries is exceeded.
For each retry we sleep a for a while before we try again, this ... | python | def _retry_over_time(fun, catch, args=[], kwargs={}, errback=None,
max_retries=None, interval_start=2, interval_step=2,
interval_max=30):
"""Retry the function over and over until max retries is exceeded.
For each retry we sleep a for a while before we try again, this ... | [
"def",
"_retry_over_time",
"(",
"fun",
",",
"catch",
",",
"args",
"=",
"[",
"]",
",",
"kwargs",
"=",
"{",
"}",
",",
"errback",
"=",
"None",
",",
"max_retries",
"=",
"None",
",",
"interval_start",
"=",
"2",
",",
"interval_step",
"=",
"2",
",",
"interv... | Retry the function over and over until max retries is exceeded.
For each retry we sleep a for a while before we try again, this interval
is increased for every retry until the max seconds is reached.
:param fun: The function to try
:param catch: Exceptions to catch, can be either tuple or a single
... | [
"Retry",
"the",
"function",
"over",
"and",
"over",
"until",
"max",
"retries",
"is",
"exceeded",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/retry.py#L65-L100 |
galaxyproject/pulsar | pulsar/client/manager.py | ClientManager.get_client | def get_client(self, destination_params, job_id, **kwargs):
"""Build a client given specific destination parameters and job_id."""
destination_params = _parse_destination_params(destination_params)
destination_params.update(**kwargs)
job_manager_interface_class = self.job_manager_interfa... | python | def get_client(self, destination_params, job_id, **kwargs):
"""Build a client given specific destination parameters and job_id."""
destination_params = _parse_destination_params(destination_params)
destination_params.update(**kwargs)
job_manager_interface_class = self.job_manager_interfa... | [
"def",
"get_client",
"(",
"self",
",",
"destination_params",
",",
"job_id",
",",
"*",
"*",
"kwargs",
")",
":",
"destination_params",
"=",
"_parse_destination_params",
"(",
"destination_params",
")",
"destination_params",
".",
"update",
"(",
"*",
"*",
"kwargs",
"... | Build a client given specific destination parameters and job_id. | [
"Build",
"a",
"client",
"given",
"specific",
"destination",
"parameters",
"and",
"job_id",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/manager.py#L83-L90 |
galaxyproject/pulsar | pulsar/managers/util/cli/__init__.py | CliInterface.get_plugins | def get_plugins(self, shell_params, job_params):
"""
Return shell and job interface defined by and configured via
specified params.
"""
shell = self.get_shell_plugin(shell_params)
job_interface = self.get_job_interface(job_params)
return shell, job_interface | python | def get_plugins(self, shell_params, job_params):
"""
Return shell and job interface defined by and configured via
specified params.
"""
shell = self.get_shell_plugin(shell_params)
job_interface = self.get_job_interface(job_params)
return shell, job_interface | [
"def",
"get_plugins",
"(",
"self",
",",
"shell_params",
",",
"job_params",
")",
":",
"shell",
"=",
"self",
".",
"get_shell_plugin",
"(",
"shell_params",
")",
"job_interface",
"=",
"self",
".",
"get_job_interface",
"(",
"job_params",
")",
"return",
"shell",
","... | Return shell and job interface defined by and configured via
specified params. | [
"Return",
"shell",
"and",
"job",
"interface",
"defined",
"by",
"and",
"configured",
"via",
"specified",
"params",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/cli/__init__.py#L49-L56 |
galaxyproject/pulsar | pulsar/cache/util.py | atomicish_move | def atomicish_move(source, destination, tmp_suffix="_TMP"):
"""Move source to destination without risk of partial moves.
> from tempfile import mkdtemp
> from os.path import join, exists
> temp_dir = mkdtemp()
> source = join(temp_dir, "the_source")
> destination = join(temp_dir, "the_dest")
... | python | def atomicish_move(source, destination, tmp_suffix="_TMP"):
"""Move source to destination without risk of partial moves.
> from tempfile import mkdtemp
> from os.path import join, exists
> temp_dir = mkdtemp()
> source = join(temp_dir, "the_source")
> destination = join(temp_dir, "the_dest")
... | [
"def",
"atomicish_move",
"(",
"source",
",",
"destination",
",",
"tmp_suffix",
"=",
"\"_TMP\"",
")",
":",
"destination_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"destination",
")",
"destination_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | Move source to destination without risk of partial moves.
> from tempfile import mkdtemp
> from os.path import join, exists
> temp_dir = mkdtemp()
> source = join(temp_dir, "the_source")
> destination = join(temp_dir, "the_dest")
> open(source, "wb").write(b"Hello World!")
> assert exists(s... | [
"Move",
"source",
"to",
"destination",
"without",
"risk",
"of",
"partial",
"moves",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/cache/util.py#L8-L27 |
galaxyproject/pulsar | pulsar/managers/util/env.py | env_to_statement | def env_to_statement(env):
''' Return the abstraction description of an environment variable definition
into a statement for shell script.
>>> env_to_statement(dict(name='X', value='Y'))
'X="Y"; export X'
>>> env_to_statement(dict(name='X', value='Y', raw=True))
'X=Y; export X'
>>> env_to_s... | python | def env_to_statement(env):
''' Return the abstraction description of an environment variable definition
into a statement for shell script.
>>> env_to_statement(dict(name='X', value='Y'))
'X="Y"; export X'
>>> env_to_statement(dict(name='X', value='Y', raw=True))
'X=Y; export X'
>>> env_to_s... | [
"def",
"env_to_statement",
"(",
"env",
")",
":",
"source_file",
"=",
"env",
".",
"get",
"(",
"'file'",
",",
"None",
")",
"if",
"source_file",
":",
"return",
"'. %s'",
"%",
"__escape",
"(",
"source_file",
",",
"env",
")",
"execute",
"=",
"env",
".",
"ge... | Return the abstraction description of an environment variable definition
into a statement for shell script.
>>> env_to_statement(dict(name='X', value='Y'))
'X="Y"; export X'
>>> env_to_statement(dict(name='X', value='Y', raw=True))
'X=Y; export X'
>>> env_to_statement(dict(name='X', value='"A",... | [
"Return",
"the",
"abstraction",
"description",
"of",
"an",
"environment",
"variable",
"definition",
"into",
"a",
"statement",
"for",
"shell",
"script",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/env.py#L5-L33 |
galaxyproject/pulsar | pulsar/util/__init__.py | copy_to_temp | def copy_to_temp(object):
"""
Copy file-like object to temp file and return
path.
"""
temp_file = NamedTemporaryFile(delete=False)
_copy_and_close(object, temp_file)
return temp_file.name | python | def copy_to_temp(object):
"""
Copy file-like object to temp file and return
path.
"""
temp_file = NamedTemporaryFile(delete=False)
_copy_and_close(object, temp_file)
return temp_file.name | [
"def",
"copy_to_temp",
"(",
"object",
")",
":",
"temp_file",
"=",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"_copy_and_close",
"(",
"object",
",",
"temp_file",
")",
"return",
"temp_file",
".",
"name"
] | Copy file-like object to temp file and return
path. | [
"Copy",
"file",
"-",
"like",
"object",
"to",
"temp",
"file",
"and",
"return",
"path",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/__init__.py#L27-L34 |
galaxyproject/pulsar | pulsar/managers/util/condor/__init__.py | build_submit_description | def build_submit_description(executable, output, error, user_log, query_params):
"""
Build up the contents of a condor submit description file.
>>> submit_args = dict(executable='/path/to/script', output='o', error='e', user_log='ul')
>>> submit_args['query_params'] = dict()
>>> default_description... | python | def build_submit_description(executable, output, error, user_log, query_params):
"""
Build up the contents of a condor submit description file.
>>> submit_args = dict(executable='/path/to/script', output='o', error='e', user_log='ul')
>>> submit_args['query_params'] = dict()
>>> default_description... | [
"def",
"build_submit_description",
"(",
"executable",
",",
"output",
",",
"error",
",",
"user_log",
",",
"query_params",
")",
":",
"all_query_params",
"=",
"DEFAULT_QUERY_CLASSAD",
".",
"copy",
"(",
")",
"all_query_params",
".",
"update",
"(",
"query_params",
")",... | Build up the contents of a condor submit description file.
>>> submit_args = dict(executable='/path/to/script', output='o', error='e', user_log='ul')
>>> submit_args['query_params'] = dict()
>>> default_description = build_submit_description(**submit_args)
>>> assert 'executable = /path/to/script' in d... | [
"Build",
"up",
"the",
"contents",
"of",
"a",
"condor",
"submit",
"description",
"file",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/condor/__init__.py#L39-L68 |
galaxyproject/pulsar | pulsar/managers/util/condor/__init__.py | condor_submit | def condor_submit(submit_file):
"""
Submit a condor job described by the given file. Parse an external id for
the submission or return None and a reason for the failure.
"""
external_id = None
try:
submit = Popen(('condor_submit', submit_file), stdout=PIPE, stderr=STDOUT)
message... | python | def condor_submit(submit_file):
"""
Submit a condor job described by the given file. Parse an external id for
the submission or return None and a reason for the failure.
"""
external_id = None
try:
submit = Popen(('condor_submit', submit_file), stdout=PIPE, stderr=STDOUT)
message... | [
"def",
"condor_submit",
"(",
"submit_file",
")",
":",
"external_id",
"=",
"None",
"try",
":",
"submit",
"=",
"Popen",
"(",
"(",
"'condor_submit'",
",",
"submit_file",
")",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"STDOUT",
")",
"message",
",",
"_"... | Submit a condor job described by the given file. Parse an external id for
the submission or return None and a reason for the failure. | [
"Submit",
"a",
"condor",
"job",
"described",
"by",
"the",
"given",
"file",
".",
"Parse",
"an",
"external",
"id",
"for",
"the",
"submission",
"or",
"return",
"None",
"and",
"a",
"reason",
"for",
"the",
"failure",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/condor/__init__.py#L71-L86 |
galaxyproject/pulsar | pulsar/managers/util/condor/__init__.py | condor_stop | def condor_stop(external_id):
"""
Stop running condor job and return a failure_message if this
fails.
"""
failure_message = None
try:
check_call(('condor_rm', external_id))
except CalledProcessError:
failure_message = "condor_rm failed"
except Exception as e:
"err... | python | def condor_stop(external_id):
"""
Stop running condor job and return a failure_message if this
fails.
"""
failure_message = None
try:
check_call(('condor_rm', external_id))
except CalledProcessError:
failure_message = "condor_rm failed"
except Exception as e:
"err... | [
"def",
"condor_stop",
"(",
"external_id",
")",
":",
"failure_message",
"=",
"None",
"try",
":",
"check_call",
"(",
"(",
"'condor_rm'",
",",
"external_id",
")",
")",
"except",
"CalledProcessError",
":",
"failure_message",
"=",
"\"condor_rm failed\"",
"except",
"Exc... | Stop running condor job and return a failure_message if this
fails. | [
"Stop",
"running",
"condor",
"job",
"and",
"return",
"a",
"failure_message",
"if",
"this",
"fails",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/condor/__init__.py#L89-L101 |
galaxyproject/pulsar | pulsar/locks.py | LockManager.get_lock | def get_lock(self, path):
""" Get a job lock corresponding to the path - assumes parent
directory exists but the file itself does not.
"""
if self.lockfile:
return self.lockfile.LockFile(path)
else:
with self.job_locks_lock:
if path not in ... | python | def get_lock(self, path):
""" Get a job lock corresponding to the path - assumes parent
directory exists but the file itself does not.
"""
if self.lockfile:
return self.lockfile.LockFile(path)
else:
with self.job_locks_lock:
if path not in ... | [
"def",
"get_lock",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"lockfile",
":",
"return",
"self",
".",
"lockfile",
".",
"LockFile",
"(",
"path",
")",
"else",
":",
"with",
"self",
".",
"job_locks_lock",
":",
"if",
"path",
"not",
"in",
"self... | Get a job lock corresponding to the path - assumes parent
directory exists but the file itself does not. | [
"Get",
"a",
"job",
"lock",
"corresponding",
"to",
"the",
"path",
"-",
"assumes",
"parent",
"directory",
"exists",
"but",
"the",
"file",
"itself",
"does",
"not",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/locks.py#L23-L36 |
galaxyproject/pulsar | pulsar/managers/__init__.py | ManagerProxy.shutdown | def shutdown(self, timeout=None):
""" Optional. """
try:
shutdown_method = self._proxied_manager.shutdown
except AttributeError:
return
shutdown_method(timeout) | python | def shutdown(self, timeout=None):
""" Optional. """
try:
shutdown_method = self._proxied_manager.shutdown
except AttributeError:
return
shutdown_method(timeout) | [
"def",
"shutdown",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"shutdown_method",
"=",
"self",
".",
"_proxied_manager",
".",
"shutdown",
"except",
"AttributeError",
":",
"return",
"shutdown_method",
"(",
"timeout",
")"
] | Optional. | [
"Optional",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/__init__.py#L113-L119 |
galaxyproject/pulsar | pulsar/client/setup_handler.py | build | def build(client, destination_args):
""" Build a SetupHandler object for client from destination parameters.
"""
# Have defined a remote job directory, lets do the setup locally.
if client.job_directory:
handler = LocalSetupHandler(client, destination_args)
else:
handler = RemoteSetu... | python | def build(client, destination_args):
""" Build a SetupHandler object for client from destination parameters.
"""
# Have defined a remote job directory, lets do the setup locally.
if client.job_directory:
handler = LocalSetupHandler(client, destination_args)
else:
handler = RemoteSetu... | [
"def",
"build",
"(",
"client",
",",
"destination_args",
")",
":",
"# Have defined a remote job directory, lets do the setup locally.",
"if",
"client",
".",
"job_directory",
":",
"handler",
"=",
"LocalSetupHandler",
"(",
"client",
",",
"destination_args",
")",
"else",
":... | Build a SetupHandler object for client from destination parameters. | [
"Build",
"a",
"SetupHandler",
"object",
"for",
"client",
"from",
"destination",
"parameters",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/setup_handler.py#L10-L18 |
galaxyproject/pulsar | pulsar/managers/util/drmaa/__init__.py | DrmaaSession.run_job | def run_job(self, **kwds):
"""
Create a DRMAA job template, populate with specified properties,
run the job, and return the external_job_id.
"""
template = DrmaaSession.session.createJobTemplate()
try:
for key in kwds:
setattr(template, key, kw... | python | def run_job(self, **kwds):
"""
Create a DRMAA job template, populate with specified properties,
run the job, and return the external_job_id.
"""
template = DrmaaSession.session.createJobTemplate()
try:
for key in kwds:
setattr(template, key, kw... | [
"def",
"run_job",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"template",
"=",
"DrmaaSession",
".",
"session",
".",
"createJobTemplate",
"(",
")",
"try",
":",
"for",
"key",
"in",
"kwds",
":",
"setattr",
"(",
"template",
",",
"key",
",",
"kwds",
"["... | Create a DRMAA job template, populate with specified properties,
run the job, and return the external_job_id. | [
"Create",
"a",
"DRMAA",
"job",
"template",
"populate",
"with",
"specified",
"properties",
"run",
"the",
"job",
"and",
"return",
"the",
"external_job_id",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/util/drmaa/__init__.py#L57-L69 |
galaxyproject/pulsar | pulsar/client/destination.py | url_to_destination_params | def url_to_destination_params(url):
"""Convert a legacy runner URL to a job destination
>>> params_simple = url_to_destination_params("http://localhost:8913/")
>>> params_simple["url"]
'http://localhost:8913/'
>>> params_simple["private_token"] is None
True
>>> advanced_url = "https://1234x... | python | def url_to_destination_params(url):
"""Convert a legacy runner URL to a job destination
>>> params_simple = url_to_destination_params("http://localhost:8913/")
>>> params_simple["url"]
'http://localhost:8913/'
>>> params_simple["private_token"] is None
True
>>> advanced_url = "https://1234x... | [
"def",
"url_to_destination_params",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"\"pulsar://\"",
")",
":",
"url",
"=",
"url",
"[",
"len",
"(",
"\"pulsar://\"",
")",
":",
"]",
"if",
"not",
"url",
".",
"endswith",
"(",
"\"/\"",
")",
":",
... | Convert a legacy runner URL to a job destination
>>> params_simple = url_to_destination_params("http://localhost:8913/")
>>> params_simple["url"]
'http://localhost:8913/'
>>> params_simple["private_token"] is None
True
>>> advanced_url = "https://1234x@example.com:8914/managers/longqueue"
>... | [
"Convert",
"a",
"legacy",
"runner",
"URL",
"to",
"a",
"job",
"destination"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/destination.py#L9-L48 |
galaxyproject/pulsar | pulsar/util/pastescript/serve.py | ensure_port_cleanup | def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
"""
This makes sure any open ports are closed.
Does this by connecting to them until they give connection
refused. Servers should call like::
import paste.script
ensure_port_cleanup([80, 443])
"""
atexit.regis... | python | def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
"""
This makes sure any open ports are closed.
Does this by connecting to them until they give connection
refused. Servers should call like::
import paste.script
ensure_port_cleanup([80, 443])
"""
atexit.regis... | [
"def",
"ensure_port_cleanup",
"(",
"bound_addresses",
",",
"maxtries",
"=",
"30",
",",
"sleeptime",
"=",
"2",
")",
":",
"atexit",
".",
"register",
"(",
"_cleanup_ports",
",",
"bound_addresses",
",",
"maxtries",
"=",
"maxtries",
",",
"sleeptime",
"=",
"sleeptim... | This makes sure any open ports are closed.
Does this by connecting to them until they give connection
refused. Servers should call like::
import paste.script
ensure_port_cleanup([80, 443]) | [
"This",
"makes",
"sure",
"any",
"open",
"ports",
"are",
"closed",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/serve.py#L963-L974 |
galaxyproject/pulsar | pulsar/util/pastescript/serve.py | Command.standard_parser | def standard_parser(cls, verbose=True,
interactive=False,
no_interactive=False,
simulate=False,
quiet=False,
overwrite=False):
"""
Create a standard ``OptionParser`` instance.
... | python | def standard_parser(cls, verbose=True,
interactive=False,
no_interactive=False,
simulate=False,
quiet=False,
overwrite=False):
"""
Create a standard ``OptionParser`` instance.
... | [
"def",
"standard_parser",
"(",
"cls",
",",
"verbose",
"=",
"True",
",",
"interactive",
"=",
"False",
",",
"no_interactive",
"=",
"False",
",",
"simulate",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"overwrite",
"=",
"False",
")",
":",
"parser",
"=",
... | Create a standard ``OptionParser`` instance.
Typically used like::
class MyCommand(Command):
parser = Command.standard_parser()
Subclasses may redefine ``standard_parser``, so use the
nearest superclass's class method. | [
"Create",
"a",
"standard",
"OptionParser",
"instance",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/serve.py#L256-L304 |
galaxyproject/pulsar | pulsar/util/pastescript/serve.py | Command.quote_first_command_arg | def quote_first_command_arg(self, arg):
"""
There's a bug in Windows when running an executable that's
located inside a path with a space in it. This method handles
that case, or on non-Windows systems or an executable with no
spaces, it just leaves well enough alone.
""... | python | def quote_first_command_arg(self, arg):
"""
There's a bug in Windows when running an executable that's
located inside a path with a space in it. This method handles
that case, or on non-Windows systems or an executable with no
spaces, it just leaves well enough alone.
""... | [
"def",
"quote_first_command_arg",
"(",
"self",
",",
"arg",
")",
":",
"if",
"(",
"sys",
".",
"platform",
"!=",
"'win32'",
"or",
"' '",
"not",
"in",
"arg",
")",
":",
"# Problem does not apply:",
"return",
"arg",
"try",
":",
"import",
"win32api",
"except",
"I... | There's a bug in Windows when running an executable that's
located inside a path with a space in it. This method handles
that case, or on non-Windows systems or an executable with no
spaces, it just leaves well enough alone. | [
"There",
"s",
"a",
"bug",
"in",
"Windows",
"when",
"running",
"an",
"executable",
"that",
"s",
"located",
"inside",
"a",
"path",
"with",
"a",
"space",
"in",
"it",
".",
"This",
"method",
"handles",
"that",
"case",
"or",
"on",
"non",
"-",
"Windows",
"sys... | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/serve.py#L308-L327 |
galaxyproject/pulsar | pulsar/util/pastescript/serve.py | Command.logging_file_config | def logging_file_config(self, config_file):
"""
Setup logging via the logging module's fileConfig function with the
specified ``config_file``, if applicable.
ConfigParser defaults are specified for the special ``__file__``
and ``here`` variables, similar to PasteDeploy config lo... | python | def logging_file_config(self, config_file):
"""
Setup logging via the logging module's fileConfig function with the
specified ``config_file``, if applicable.
ConfigParser defaults are specified for the special ``__file__``
and ``here`` variables, similar to PasteDeploy config lo... | [
"def",
"logging_file_config",
"(",
"self",
",",
"config_file",
")",
":",
"parser",
"=",
"ConfigParser",
".",
"ConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"[",
"config_file",
"]",
")",
"if",
"parser",
".",
"has_section",
"(",
"'loggers'",
")",
":",... | Setup logging via the logging module's fileConfig function with the
specified ``config_file``, if applicable.
ConfigParser defaults are specified for the special ``__file__``
and ``here`` variables, similar to PasteDeploy config loading. | [
"Setup",
"logging",
"via",
"the",
"logging",
"module",
"s",
"fileConfig",
"function",
"with",
"the",
"specified",
"config_file",
"if",
"applicable",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/serve.py#L345-L358 |
galaxyproject/pulsar | pulsar/client/staging/down.py | finish_job | def finish_job(client, cleanup_job, job_completed_normally, client_outputs, pulsar_outputs):
"""Process for "un-staging" a complete Pulsar job.
This function is responsible for downloading results from remote
server and cleaning up Pulsar staging directory (if needed.)
"""
collection_failure_except... | python | def finish_job(client, cleanup_job, job_completed_normally, client_outputs, pulsar_outputs):
"""Process for "un-staging" a complete Pulsar job.
This function is responsible for downloading results from remote
server and cleaning up Pulsar staging directory (if needed.)
"""
collection_failure_except... | [
"def",
"finish_job",
"(",
"client",
",",
"cleanup_job",
",",
"job_completed_normally",
",",
"client_outputs",
",",
"pulsar_outputs",
")",
":",
"collection_failure_exceptions",
"=",
"[",
"]",
"if",
"job_completed_normally",
":",
"output_collector",
"=",
"ClientOutputColl... | Process for "un-staging" a complete Pulsar job.
This function is responsible for downloading results from remote
server and cleaning up Pulsar staging directory (if needed.) | [
"Process",
"for",
"un",
"-",
"staging",
"a",
"complete",
"Pulsar",
"job",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/staging/down.py#L13-L26 |
galaxyproject/pulsar | pulsar/client/util.py | copy | def copy(source, destination):
""" Copy file from source to destination if needed (skip if source
is destination).
"""
source = os.path.abspath(source)
destination = os.path.abspath(destination)
if source != destination:
if not os.path.exists(os.path.dirname(destination)):
os... | python | def copy(source, destination):
""" Copy file from source to destination if needed (skip if source
is destination).
"""
source = os.path.abspath(source)
destination = os.path.abspath(destination)
if source != destination:
if not os.path.exists(os.path.dirname(destination)):
os... | [
"def",
"copy",
"(",
"source",
",",
"destination",
")",
":",
"source",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"source",
")",
"destination",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"destination",
")",
"if",
"source",
"!=",
"destination",
":",
... | Copy file from source to destination if needed (skip if source
is destination). | [
"Copy",
"file",
"from",
"source",
"to",
"destination",
"if",
"needed",
"(",
"skip",
"if",
"source",
"is",
"destination",
")",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/util.py#L76-L85 |
galaxyproject/pulsar | pulsar/managers/base/base_drmaa.py | BaseDrmaaManager.shutdown | def shutdown(self, timeout=None):
"""Cleanup DRMAA session and call shutdown of parent."""
try:
super(BaseDrmaaManager, self).shutdown(timeout)
except Exception:
pass
self.drmaa_session.close() | python | def shutdown(self, timeout=None):
"""Cleanup DRMAA session and call shutdown of parent."""
try:
super(BaseDrmaaManager, self).shutdown(timeout)
except Exception:
pass
self.drmaa_session.close() | [
"def",
"shutdown",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"super",
"(",
"BaseDrmaaManager",
",",
"self",
")",
".",
"shutdown",
"(",
"timeout",
")",
"except",
"Exception",
":",
"pass",
"self",
".",
"drmaa_session",
".",
"close",
... | Cleanup DRMAA session and call shutdown of parent. | [
"Cleanup",
"DRMAA",
"session",
"and",
"call",
"shutdown",
"of",
"parent",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/managers/base/base_drmaa.py#L31-L37 |
galaxyproject/pulsar | pulsar/cache/__init__.py | Cache.cache_file | def cache_file(self, local_path, ip, path):
"""
Move a file from a temporary staging area into the cache.
"""
destination = self.__destination(ip, path)
atomicish_move(local_path, destination) | python | def cache_file(self, local_path, ip, path):
"""
Move a file from a temporary staging area into the cache.
"""
destination = self.__destination(ip, path)
atomicish_move(local_path, destination) | [
"def",
"cache_file",
"(",
"self",
",",
"local_path",
",",
"ip",
",",
"path",
")",
":",
"destination",
"=",
"self",
".",
"__destination",
"(",
"ip",
",",
"path",
")",
"atomicish_move",
"(",
"local_path",
",",
"destination",
")"
] | Move a file from a temporary staging area into the cache. | [
"Move",
"a",
"file",
"from",
"a",
"temporary",
"staging",
"area",
"into",
"the",
"cache",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/cache/__init__.py#L41-L46 |
galaxyproject/pulsar | pulsar/manager_factory.py | build_managers | def build_managers(app, conf):
"""
Takes in a config file as outlined in job_managers.ini.sample and builds
a dictionary of job manager objects from them.
"""
# Load default options from config file that apply to all
# managers.
default_options = _get_default_options(conf)
manager_descr... | python | def build_managers(app, conf):
"""
Takes in a config file as outlined in job_managers.ini.sample and builds
a dictionary of job manager objects from them.
"""
# Load default options from config file that apply to all
# managers.
default_options = _get_default_options(conf)
manager_descr... | [
"def",
"build_managers",
"(",
"app",
",",
"conf",
")",
":",
"# Load default options from config file that apply to all",
"# managers.",
"default_options",
"=",
"_get_default_options",
"(",
"conf",
")",
"manager_descriptions",
"=",
"ManagerDescriptions",
"(",
")",
"if",
"\... | Takes in a config file as outlined in job_managers.ini.sample and builds
a dictionary of job manager objects from them. | [
"Takes",
"in",
"a",
"config",
"file",
"as",
"outlined",
"in",
"job_managers",
".",
"ini",
".",
"sample",
"and",
"builds",
"a",
"dictionary",
"of",
"job",
"manager",
"objects",
"from",
"them",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/manager_factory.py#L17-L50 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | fix_type_error | def fix_type_error(exc_info, callable, varargs, kwargs):
"""
Given an exception, this will test if the exception was due to a
signature error, and annotate the error with better information if
so.
Usage::
try:
val = callable(*args, **kw)
except TypeError:
exc_info =... | python | def fix_type_error(exc_info, callable, varargs, kwargs):
"""
Given an exception, this will test if the exception was due to a
signature error, and annotate the error with better information if
so.
Usage::
try:
val = callable(*args, **kw)
except TypeError:
exc_info =... | [
"def",
"fix_type_error",
"(",
"exc_info",
",",
"callable",
",",
"varargs",
",",
"kwargs",
")",
":",
"if",
"exc_info",
"is",
"None",
":",
"exc_info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"(",
"exc_info",
"[",
"0",
"]",
"!=",
"TypeError",
"or",
... | Given an exception, this will test if the exception was due to a
signature error, and annotate the error with better information if
so.
Usage::
try:
val = callable(*args, **kw)
except TypeError:
exc_info = fix_type_error(None, callable, args, kw)
raise exc_info[0]... | [
"Given",
"an",
"exception",
"this",
"will",
"test",
"if",
"the",
"exception",
"was",
"due",
"to",
"a",
"signature",
"error",
"and",
"annotate",
"the",
"error",
"with",
"better",
"information",
"if",
"so",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L50-L82 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | fix_call | def fix_call(callable, *args, **kw):
"""
Call ``callable(*args, **kw)`` fixing any type errors that come out.
"""
try:
val = callable(*args, **kw)
except TypeError:
exc_info = fix_type_error(None, callable, args, kw)
reraise(*exc_info)
return val | python | def fix_call(callable, *args, **kw):
"""
Call ``callable(*args, **kw)`` fixing any type errors that come out.
"""
try:
val = callable(*args, **kw)
except TypeError:
exc_info = fix_type_error(None, callable, args, kw)
reraise(*exc_info)
return val | [
"def",
"fix_call",
"(",
"callable",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"try",
":",
"val",
"=",
"callable",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"except",
"TypeError",
":",
"exc_info",
"=",
"fix_type_error",
"(",
"None",
",",
... | Call ``callable(*args, **kw)`` fixing any type errors that come out. | [
"Call",
"callable",
"(",
"*",
"args",
"**",
"kw",
")",
"fixing",
"any",
"type",
"errors",
"that",
"come",
"out",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L92-L101 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | lookup_object | def lookup_object(spec):
"""
Looks up a module or object from a some.module:func_name specification.
To just look up a module, omit the colon and everything after it.
"""
parts, target = spec.split(':') if ':' in spec else (spec, None)
module = __import__(parts)
for part in parts.split('.')... | python | def lookup_object(spec):
"""
Looks up a module or object from a some.module:func_name specification.
To just look up a module, omit the colon and everything after it.
"""
parts, target = spec.split(':') if ':' in spec else (spec, None)
module = __import__(parts)
for part in parts.split('.')... | [
"def",
"lookup_object",
"(",
"spec",
")",
":",
"parts",
",",
"target",
"=",
"spec",
".",
"split",
"(",
"':'",
")",
"if",
"':'",
"in",
"spec",
"else",
"(",
"spec",
",",
"None",
")",
"module",
"=",
"__import__",
"(",
"parts",
")",
"for",
"part",
"in"... | Looks up a module or object from a some.module:func_name specification.
To just look up a module, omit the colon and everything after it. | [
"Looks",
"up",
"a",
"module",
"or",
"object",
"from",
"a",
"some",
".",
"module",
":",
"func_name",
"specification",
".",
"To",
"just",
"look",
"up",
"a",
"module",
"omit",
"the",
"colon",
"and",
"everything",
"after",
"it",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L104-L115 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | _flatten | def _flatten(lst):
"""
Flatten a nested list.
"""
if not isinstance(lst, (list, tuple)):
return [lst]
result = []
for item in lst:
result.extend(_flatten(item))
return result | python | def _flatten(lst):
"""
Flatten a nested list.
"""
if not isinstance(lst, (list, tuple)):
return [lst]
result = []
for item in lst:
result.extend(_flatten(item))
return result | [
"def",
"_flatten",
"(",
"lst",
")",
":",
"if",
"not",
"isinstance",
"(",
"lst",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"[",
"lst",
"]",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"lst",
":",
"result",
".",
"extend",
"(",
"_... | Flatten a nested list. | [
"Flatten",
"a",
"nested",
"list",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L141-L150 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | NicerConfigParser.defaults | def defaults(self):
"""Return the defaults, with their values interpolated (with the
defaults dict itself)
Mainly to support defaults using values such as %(here)s
"""
defaults = ConfigParser.defaults(self).copy()
for key, val in iteritems(defaults):
defaults... | python | def defaults(self):
"""Return the defaults, with their values interpolated (with the
defaults dict itself)
Mainly to support defaults using values such as %(here)s
"""
defaults = ConfigParser.defaults(self).copy()
for key, val in iteritems(defaults):
defaults... | [
"def",
"defaults",
"(",
"self",
")",
":",
"defaults",
"=",
"ConfigParser",
".",
"defaults",
"(",
"self",
")",
".",
"copy",
"(",
")",
"for",
"key",
",",
"val",
"in",
"iteritems",
"(",
"defaults",
")",
":",
"defaults",
"[",
"key",
"]",
"=",
"self",
"... | Return the defaults, with their values interpolated (with the
defaults dict itself)
Mainly to support defaults using values such as %(here)s | [
"Return",
"the",
"defaults",
"with",
"their",
"values",
"interpolated",
"(",
"with",
"the",
"defaults",
"dict",
"itself",
")"
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L163-L172 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | ConfigLoader.find_config_section | def find_config_section(self, object_type, name=None):
"""
Return the section name with the given name prefix (following the
same pattern as ``protocol_desc`` in ``config``. It must have the
given name, or for ``'main'`` an empty name is allowed. The
prefix must be followed by ... | python | def find_config_section(self, object_type, name=None):
"""
Return the section name with the given name prefix (following the
same pattern as ``protocol_desc`` in ``config``. It must have the
given name, or for ``'main'`` an empty name is allowed. The
prefix must be followed by ... | [
"def",
"find_config_section",
"(",
"self",
",",
"object_type",
",",
"name",
"=",
"None",
")",
":",
"possible",
"=",
"[",
"]",
"for",
"name_options",
"in",
"object_type",
".",
"config_prefixes",
":",
"for",
"name_prefix",
"in",
"name_options",
":",
"found",
"... | Return the section name with the given name prefix (following the
same pattern as ``protocol_desc`` in ``config``. It must have the
given name, or for ``'main'`` an empty name is allowed. The
prefix must be followed by a ``:``.
Case is *not* ignored. | [
"Return",
"the",
"section",
"name",
"with",
"the",
"given",
"name",
"prefix",
"(",
"following",
"the",
"same",
"pattern",
"as",
"protocol_desc",
"in",
"config",
".",
"It",
"must",
"have",
"the",
"given",
"name",
"or",
"for",
"main",
"an",
"empty",
"name",
... | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L668-L698 |
galaxyproject/pulsar | pulsar/util/pastescript/loadwsgi.py | EggLoader.find_egg_entry_point | def find_egg_entry_point(self, object_type, name=None):
"""
Returns the (entry_point, protocol) for the with the given
``name``.
"""
if name is None:
name = 'main'
possible = []
for protocol_options in object_type.egg_protocols:
for protoco... | python | def find_egg_entry_point(self, object_type, name=None):
"""
Returns the (entry_point, protocol) for the with the given
``name``.
"""
if name is None:
name = 'main'
possible = []
for protocol_options in object_type.egg_protocols:
for protoco... | [
"def",
"find_egg_entry_point",
"(",
"self",
",",
"object_type",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"'main'",
"possible",
"=",
"[",
"]",
"for",
"protocol_options",
"in",
"object_type",
".",
"egg_protocols",
":"... | Returns the (entry_point, protocol) for the with the given
``name``. | [
"Returns",
"the",
"(",
"entry_point",
"protocol",
")",
"for",
"the",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/pastescript/loadwsgi.py#L733-L767 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.