repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
mezz64/pyEight | pyeight/user.py | EightUser.last_room_temp | def last_room_temp(self):
"""Return avg room temperature for last session."""
try:
rmtemps = self.intervals[1]['timeseries']['tempRoomC']
except KeyError:
return None
tmp = 0
num_temps = len(rmtemps)
if num_temps == 0:
return None
... | python | def last_room_temp(self):
"""Return avg room temperature for last session."""
try:
rmtemps = self.intervals[1]['timeseries']['tempRoomC']
except KeyError:
return None
tmp = 0
num_temps = len(rmtemps)
if num_temps == 0:
return None
... | [
"def",
"last_room_temp",
"(",
"self",
")",
":",
"try",
":",
"rmtemps",
"=",
"self",
".",
"intervals",
"[",
"1",
"]",
"[",
"'timeseries'",
"]",
"[",
"'tempRoomC'",
"]",
"except",
"KeyError",
":",
"return",
"None",
"tmp",
"=",
"0",
"num_temps",
"=",
"len... | Return avg room temperature for last session. | [
"Return",
"avg",
"room",
"temperature",
"for",
"last",
"session",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L374-L389 |
mezz64/pyEight | pyeight/user.py | EightUser.last_heart_rate | def last_heart_rate(self):
"""Return avg heart rate for last session."""
try:
rates = self.intervals[1]['timeseries']['heartRate']
except KeyError:
return None
tmp = 0
num_rates = len(rates)
if num_rates == 0:
return None
for ... | python | def last_heart_rate(self):
"""Return avg heart rate for last session."""
try:
rates = self.intervals[1]['timeseries']['heartRate']
except KeyError:
return None
tmp = 0
num_rates = len(rates)
if num_rates == 0:
return None
for ... | [
"def",
"last_heart_rate",
"(",
"self",
")",
":",
"try",
":",
"rates",
"=",
"self",
".",
"intervals",
"[",
"1",
"]",
"[",
"'timeseries'",
"]",
"[",
"'heartRate'",
"]",
"except",
"KeyError",
":",
"return",
"None",
"tmp",
"=",
"0",
"num_rates",
"=",
"len"... | Return avg heart rate for last session. | [
"Return",
"avg",
"heart",
"rate",
"for",
"last",
"session",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L419-L434 |
mezz64/pyEight | pyeight/user.py | EightUser.last_values | def last_values(self):
"""Return a dict of all the 'last' parameters."""
last_dict = {
'date': self.last_session_date,
'score': self.last_sleep_score,
'breakdown': self.last_sleep_breakdown,
'tnt': self.last_tnt,
'bed_temp': self.last_bed_temp,... | python | def last_values(self):
"""Return a dict of all the 'last' parameters."""
last_dict = {
'date': self.last_session_date,
'score': self.last_sleep_score,
'breakdown': self.last_sleep_breakdown,
'tnt': self.last_tnt,
'bed_temp': self.last_bed_temp,... | [
"def",
"last_values",
"(",
"self",
")",
":",
"last_dict",
"=",
"{",
"'date'",
":",
"self",
".",
"last_session_date",
",",
"'score'",
":",
"self",
".",
"last_sleep_score",
",",
"'breakdown'",
":",
"self",
".",
"last_sleep_breakdown",
",",
"'tnt'",
":",
"self"... | Return a dict of all the 'last' parameters. | [
"Return",
"a",
"dict",
"of",
"all",
"the",
"last",
"parameters",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L437-L450 |
mezz64/pyEight | pyeight/user.py | EightUser.heating_stats | def heating_stats(self):
"""Calculate some heating data stats."""
local_5 = []
local_10 = []
for i in range(0, 10):
level = self.past_heating_level(i)
if level == 0:
_LOGGER.debug('Cant calculate stats yet...')
return
i... | python | def heating_stats(self):
"""Calculate some heating data stats."""
local_5 = []
local_10 = []
for i in range(0, 10):
level = self.past_heating_level(i)
if level == 0:
_LOGGER.debug('Cant calculate stats yet...')
return
i... | [
"def",
"heating_stats",
"(",
"self",
")",
":",
"local_5",
"=",
"[",
"]",
"local_10",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"10",
")",
":",
"level",
"=",
"self",
".",
"past_heating_level",
"(",
"i",
")",
"if",
"level",
"==",
"0"... | Calculate some heating data stats. | [
"Calculate",
"some",
"heating",
"data",
"stats",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L452-L487 |
mezz64/pyEight | pyeight/user.py | EightUser.dynamic_presence | def dynamic_presence(self):
"""
Determine presence based on bed heating level and end presence
time reported by the api.
Idea originated from Alex Lee Yuk Cheung SmartThings Code.
"""
# self.heating_stats()
if not self.presence:
if self.heating_leve... | python | def dynamic_presence(self):
"""
Determine presence based on bed heating level and end presence
time reported by the api.
Idea originated from Alex Lee Yuk Cheung SmartThings Code.
"""
# self.heating_stats()
if not self.presence:
if self.heating_leve... | [
"def",
"dynamic_presence",
"(",
"self",
")",
":",
"# self.heating_stats()",
"if",
"not",
"self",
".",
"presence",
":",
"if",
"self",
".",
"heating_level",
">",
"50",
":",
"# Can likely make this better",
"if",
"not",
"self",
".",
"now_heating",
":",
"self",
".... | Determine presence based on bed heating level and end presence
time reported by the api.
Idea originated from Alex Lee Yuk Cheung SmartThings Code. | [
"Determine",
"presence",
"based",
"on",
"bed",
"heating",
"level",
"and",
"end",
"presence",
"time",
"reported",
"by",
"the",
"api",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L494-L542 |
mezz64/pyEight | pyeight/user.py | EightUser.set_heating_level | async def set_heating_level(self, level, duration=0):
"""Update heating data json."""
url = '{}/devices/{}'.format(API_URL, self.device.deviceid)
# Catch bad inputs
level = 10 if level < 10 else level
level = 100 if level > 100 else level
if self.side == 'left':
... | python | async def set_heating_level(self, level, duration=0):
"""Update heating data json."""
url = '{}/devices/{}'.format(API_URL, self.device.deviceid)
# Catch bad inputs
level = 10 if level < 10 else level
level = 100 if level > 100 else level
if self.side == 'left':
... | [
"async",
"def",
"set_heating_level",
"(",
"self",
",",
"level",
",",
"duration",
"=",
"0",
")",
":",
"url",
"=",
"'{}/devices/{}'",
".",
"format",
"(",
"API_URL",
",",
"self",
".",
"device",
".",
"deviceid",
")",
"# Catch bad inputs",
"level",
"=",
"10",
... | Update heating data json. | [
"Update",
"heating",
"data",
"json",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L555-L579 |
mezz64/pyEight | pyeight/user.py | EightUser.update_trend_data | async def update_trend_data(self, startdate, enddate):
"""Update trends data json for specified time period."""
url = '{}/users/{}/trends'.format(API_URL, self.userid)
params = {
'tz': self.device.tzone,
'from': startdate,
'to': enddate
}
... | python | async def update_trend_data(self, startdate, enddate):
"""Update trends data json for specified time period."""
url = '{}/users/{}/trends'.format(API_URL, self.userid)
params = {
'tz': self.device.tzone,
'from': startdate,
'to': enddate
}
... | [
"async",
"def",
"update_trend_data",
"(",
"self",
",",
"startdate",
",",
"enddate",
")",
":",
"url",
"=",
"'{}/users/{}/trends'",
".",
"format",
"(",
"API_URL",
",",
"self",
".",
"userid",
")",
"params",
"=",
"{",
"'tz'",
":",
"self",
".",
"device",
".",... | Update trends data json for specified time period. | [
"Update",
"trends",
"data",
"json",
"for",
"specified",
"time",
"period",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L581-L594 |
mezz64/pyEight | pyeight/user.py | EightUser.update_intervals_data | async def update_intervals_data(self):
"""Update intervals data json for specified time period."""
url = '{}/users/{}/intervals'.format(API_URL, self.userid)
intervals = await self.device.api_get(url)
if intervals is None:
_LOGGER.error('Unable to fetch eight intervals data.... | python | async def update_intervals_data(self):
"""Update intervals data json for specified time period."""
url = '{}/users/{}/intervals'.format(API_URL, self.userid)
intervals = await self.device.api_get(url)
if intervals is None:
_LOGGER.error('Unable to fetch eight intervals data.... | [
"async",
"def",
"update_intervals_data",
"(",
"self",
")",
":",
"url",
"=",
"'{}/users/{}/intervals'",
".",
"format",
"(",
"API_URL",
",",
"self",
".",
"userid",
")",
"intervals",
"=",
"await",
"self",
".",
"device",
".",
"api_get",
"(",
"url",
")",
"if",
... | Update intervals data json for specified time period. | [
"Update",
"intervals",
"data",
"json",
"for",
"specified",
"time",
"period",
"."
] | train | https://github.com/mezz64/pyEight/blob/e557e4e6876f490d0964298e9475d68b64222d4f/pyeight/user.py#L596-L604 |
erikvw/django-collect-offline | django_collect_offline/transaction/transaction_deserializer.py | save | def save(obj=None, m2m_data=None):
"""Saves a deserialized model object.
Uses save_base to avoid running code in model.save() and
to avoid triggering signals (if raw=True).
"""
m2m_data = {} if m2m_data is None else m2m_data
obj.save_base(raw=True)
for attr, values in m2m_data.items():
... | python | def save(obj=None, m2m_data=None):
"""Saves a deserialized model object.
Uses save_base to avoid running code in model.save() and
to avoid triggering signals (if raw=True).
"""
m2m_data = {} if m2m_data is None else m2m_data
obj.save_base(raw=True)
for attr, values in m2m_data.items():
... | [
"def",
"save",
"(",
"obj",
"=",
"None",
",",
"m2m_data",
"=",
"None",
")",
":",
"m2m_data",
"=",
"{",
"}",
"if",
"m2m_data",
"is",
"None",
"else",
"m2m_data",
"obj",
".",
"save_base",
"(",
"raw",
"=",
"True",
")",
"for",
"attr",
",",
"values",
"in"... | Saves a deserialized model object.
Uses save_base to avoid running code in model.save() and
to avoid triggering signals (if raw=True). | [
"Saves",
"a",
"deserialized",
"model",
"object",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/transaction/transaction_deserializer.py#L16-L26 |
erikvw/django-collect-offline | django_collect_offline/transaction/transaction_deserializer.py | TransactionDeserializer.deserialize_transactions | def deserialize_transactions(self, transactions=None, deserialize_only=None):
"""Deserializes the encrypted serialized model
instances, tx, in a queryset of transactions.
Note: each transaction instance contains encrypted JSON text
that represents just ONE model instance.
"""
... | python | def deserialize_transactions(self, transactions=None, deserialize_only=None):
"""Deserializes the encrypted serialized model
instances, tx, in a queryset of transactions.
Note: each transaction instance contains encrypted JSON text
that represents just ONE model instance.
"""
... | [
"def",
"deserialize_transactions",
"(",
"self",
",",
"transactions",
"=",
"None",
",",
"deserialize_only",
"=",
"None",
")",
":",
"if",
"(",
"not",
"self",
".",
"allow_self",
"and",
"transactions",
".",
"filter",
"(",
"producer",
"=",
"socket",
".",
"gethost... | Deserializes the encrypted serialized model
instances, tx, in a queryset of transactions.
Note: each transaction instance contains encrypted JSON text
that represents just ONE model instance. | [
"Deserializes",
"the",
"encrypted",
"serialized",
"model",
"instances",
"tx",
"in",
"a",
"queryset",
"of",
"transactions",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/transaction/transaction_deserializer.py#L49-L75 |
erikvw/django-collect-offline | django_collect_offline/transaction/transaction_deserializer.py | TransactionDeserializer.custom_parser | def custom_parser(self, json_text=None):
"""Runs json_text thru custom parsers.
"""
app_config = django_apps.get_app_config("django_collect_offline")
for json_parser in app_config.custom_json_parsers:
json_text = json_parser(json_text)
return json_text | python | def custom_parser(self, json_text=None):
"""Runs json_text thru custom parsers.
"""
app_config = django_apps.get_app_config("django_collect_offline")
for json_parser in app_config.custom_json_parsers:
json_text = json_parser(json_text)
return json_text | [
"def",
"custom_parser",
"(",
"self",
",",
"json_text",
"=",
"None",
")",
":",
"app_config",
"=",
"django_apps",
".",
"get_app_config",
"(",
"\"django_collect_offline\"",
")",
"for",
"json_parser",
"in",
"app_config",
".",
"custom_json_parsers",
":",
"json_text",
"... | Runs json_text thru custom parsers. | [
"Runs",
"json_text",
"thru",
"custom",
"parsers",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/transaction/transaction_deserializer.py#L77-L83 |
RedHatQE/python-stitches | stitches/connection.py | Connection.cli | def cli(self):
""" cli lazy property """
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=self.private_hostname,
username=self.username,
key_filename=self.key_filename,
... | python | def cli(self):
""" cli lazy property """
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=self.private_hostname,
username=self.username,
key_filename=self.key_filename,
... | [
"def",
"cli",
"(",
"self",
")",
":",
"client",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"client",
".",
"set_missing_host_key_policy",
"(",
"paramiko",
".",
"AutoAddPolicy",
"(",
")",
")",
"client",
".",
"connect",
"(",
"hostname",
"=",
"self",
".",
"... | cli lazy property | [
"cli",
"lazy",
"property"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L111-L124 |
RedHatQE/python-stitches | stitches/connection.py | Connection.channel | def channel(self):
""" channel lazy property """
# start shell, non-blocking channel
chan = self.cli.invoke_shell(width=360, height=80)
chan.setblocking(0)
# set channel timeout
chan.settimeout(10)
# now waiting for shell prompt ('username@')
result = ""
... | python | def channel(self):
""" channel lazy property """
# start shell, non-blocking channel
chan = self.cli.invoke_shell(width=360, height=80)
chan.setblocking(0)
# set channel timeout
chan.settimeout(10)
# now waiting for shell prompt ('username@')
result = ""
... | [
"def",
"channel",
"(",
"self",
")",
":",
"# start shell, non-blocking channel",
"chan",
"=",
"self",
".",
"cli",
".",
"invoke_shell",
"(",
"width",
"=",
"360",
",",
"height",
"=",
"80",
")",
"chan",
".",
"setblocking",
"(",
"0",
")",
"# set channel timeout",... | channel lazy property | [
"channel",
"lazy",
"property"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L127-L150 |
RedHatQE/python-stitches | stitches/connection.py | Connection.pbm | def pbm(self):
""" Plumbum lazy property """
if not self.disable_rpyc:
from plumbum import SshMachine
return SshMachine(host=self.private_hostname, user=self.username,
keyfile=self.key_filename,
ssh_opts=["-o", "UserKnow... | python | def pbm(self):
""" Plumbum lazy property """
if not self.disable_rpyc:
from plumbum import SshMachine
return SshMachine(host=self.private_hostname, user=self.username,
keyfile=self.key_filename,
ssh_opts=["-o", "UserKnow... | [
"def",
"pbm",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"disable_rpyc",
":",
"from",
"plumbum",
"import",
"SshMachine",
"return",
"SshMachine",
"(",
"host",
"=",
"self",
".",
"private_hostname",
",",
"user",
"=",
"self",
".",
"username",
",",
"key... | Plumbum lazy property | [
"Plumbum",
"lazy",
"property"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L158-L167 |
RedHatQE/python-stitches | stitches/connection.py | Connection.rpyc | def rpyc(self):
""" RPyC lazy property """
if not self.disable_rpyc:
try:
import rpyc
devnull_fd = open("/dev/null", "w")
rpyc_dirname = os.path.dirname(rpyc.__file__)
rnd_id = ''.join(random.choice(string.ascii_lowercase) for ... | python | def rpyc(self):
""" RPyC lazy property """
if not self.disable_rpyc:
try:
import rpyc
devnull_fd = open("/dev/null", "w")
rpyc_dirname = os.path.dirname(rpyc.__file__)
rnd_id = ''.join(random.choice(string.ascii_lowercase) for ... | [
"def",
"rpyc",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"disable_rpyc",
":",
"try",
":",
"import",
"rpyc",
"devnull_fd",
"=",
"open",
"(",
"\"/dev/null\"",
",",
"\"w\"",
")",
"rpyc_dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"rpyc",
... | RPyC lazy property | [
"RPyC",
"lazy",
"property"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L170-L219 |
RedHatQE/python-stitches | stitches/connection.py | Connection.disconnect | def disconnect(self):
"""
Close the connection
"""
if hasattr(self, '_lazy_sftp'):
if self.sftp is not None:
self.sftp.close()
delattr(self, '_lazy_sftp')
if hasattr(self, '_lazy_channel'):
if self.channel is not None:
... | python | def disconnect(self):
"""
Close the connection
"""
if hasattr(self, '_lazy_sftp'):
if self.sftp is not None:
self.sftp.close()
delattr(self, '_lazy_sftp')
if hasattr(self, '_lazy_channel'):
if self.channel is not None:
... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_lazy_sftp'",
")",
":",
"if",
"self",
".",
"sftp",
"is",
"not",
"None",
":",
"self",
".",
"sftp",
".",
"close",
"(",
")",
"delattr",
"(",
"self",
",",
"'_lazy_sftp'",
... | Close the connection | [
"Close",
"the",
"connection"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L227-L250 |
RedHatQE/python-stitches | stitches/connection.py | Connection.exec_command | def exec_command(self, command, bufsize=-1, get_pty=False):
"""
Execute a command in the connection
@param command: command to execute
@type command: str
@param bufsize: buffer size
@type bufsize: int
@param get_pty: get pty
@type get_pty: bool
... | python | def exec_command(self, command, bufsize=-1, get_pty=False):
"""
Execute a command in the connection
@param command: command to execute
@type command: str
@param bufsize: buffer size
@type bufsize: int
@param get_pty: get pty
@type get_pty: bool
... | [
"def",
"exec_command",
"(",
"self",
",",
"command",
",",
"bufsize",
"=",
"-",
"1",
",",
"get_pty",
"=",
"False",
")",
":",
"self",
".",
"last_command",
"=",
"command",
"return",
"self",
".",
"cli",
".",
"exec_command",
"(",
"command",
",",
"bufsize",
"... | Execute a command in the connection
@param command: command to execute
@type command: str
@param bufsize: buffer size
@type bufsize: int
@param get_pty: get pty
@type get_pty: bool
@return: the stdin, stdout, and stderr of the executing command
@rtype:... | [
"Execute",
"a",
"command",
"in",
"the",
"connection"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L252-L272 |
RedHatQE/python-stitches | stitches/connection.py | Connection.recv_exit_status | def recv_exit_status(self, command, timeout=10, get_pty=False):
"""
Execute a command and get its return value
@param command: command to execute
@type command: str
@param timeout: command execution timeout
@type timeout: int
@param get_pty: get pty
@ty... | python | def recv_exit_status(self, command, timeout=10, get_pty=False):
"""
Execute a command and get its return value
@param command: command to execute
@type command: str
@param timeout: command execution timeout
@type timeout: int
@param get_pty: get pty
@ty... | [
"def",
"recv_exit_status",
"(",
"self",
",",
"command",
",",
"timeout",
"=",
"10",
",",
"get_pty",
"=",
"False",
")",
":",
"status",
"=",
"None",
"self",
".",
"last_command",
"=",
"command",
"stdin",
",",
"stdout",
",",
"stderr",
"=",
"self",
".",
"cli... | Execute a command and get its return value
@param command: command to execute
@type command: str
@param timeout: command execution timeout
@type timeout: int
@param get_pty: get pty
@type get_pty: bool
@return: the exit code of the process or None in case of t... | [
"Execute",
"a",
"command",
"and",
"get",
"its",
"return",
"value"
] | train | https://github.com/RedHatQE/python-stitches/blob/957e9895e64ffd3b8157b38b9cce414969509288/stitches/connection.py#L274-L306 |
gwww/elkm1 | elkm1_lib/counters.py | Counter.set | def set(self, value):
"""(Helper) Set counter to value"""
self._elk.send(cx_encode(self._index, value)) | python | def set(self, value):
"""(Helper) Set counter to value"""
self._elk.send(cx_encode(self._index, value)) | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_elk",
".",
"send",
"(",
"cx_encode",
"(",
"self",
".",
"_index",
",",
"value",
")",
")"
] | (Helper) Set counter to value | [
"(",
"Helper",
")",
"Set",
"counter",
"to",
"value"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/counters.py#L13-L15 |
MonashBI/arcana | arcana/pipeline/provenance.py | Record.save | def save(self, path):
"""
Saves the provenance object to a JSON file, optionally including
checksums for inputs and outputs (which are initially produced mid-
run) to insert during the write
Parameters
----------
path : str
Path to save the generated ... | python | def save(self, path):
"""
Saves the provenance object to a JSON file, optionally including
checksums for inputs and outputs (which are initially produced mid-
run) to insert during the write
Parameters
----------
path : str
Path to save the generated ... | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"try",
":",
"json",
".",
"dump",
"(",
"self",
".",
"prov",
",",
"f",
",",
"indent",
"=",
"2",
")",
"except",
"TypeError",
":",
"r... | Saves the provenance object to a JSON file, optionally including
checksums for inputs and outputs (which are initially produced mid-
run) to insert during the write
Parameters
----------
path : str
Path to save the generated JSON file
inputs : dict[str, str |... | [
"Saves",
"the",
"provenance",
"object",
"to",
"a",
"JSON",
"file",
"optionally",
"including",
"checksums",
"for",
"inputs",
"and",
"outputs",
"(",
"which",
"are",
"initially",
"produced",
"mid",
"-",
"run",
")",
"to",
"insert",
"during",
"the",
"write"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/provenance.py#L112-L140 |
MonashBI/arcana | arcana/pipeline/provenance.py | Record.load | def load(cls, pipeline_name, frequency, subject_id, visit_id, from_study,
path):
"""
Loads a saved provenance object from a JSON file
Parameters
----------
path : str
Path to the provenance file
frequency : str
The frequency of the re... | python | def load(cls, pipeline_name, frequency, subject_id, visit_id, from_study,
path):
"""
Loads a saved provenance object from a JSON file
Parameters
----------
path : str
Path to the provenance file
frequency : str
The frequency of the re... | [
"def",
"load",
"(",
"cls",
",",
"pipeline_name",
",",
"frequency",
",",
"subject_id",
",",
"visit_id",
",",
"from_study",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"prov",
"=",
"json",
".",
"load",
"(",
"f",
")",
"ret... | Loads a saved provenance object from a JSON file
Parameters
----------
path : str
Path to the provenance file
frequency : str
The frequency of the record
subject_id : str | None
The subject ID of the provenance record
visit_id : str | ... | [
"Loads",
"a",
"saved",
"provenance",
"object",
"from",
"a",
"JSON",
"file"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/provenance.py#L143-L169 |
MonashBI/arcana | arcana/pipeline/provenance.py | Record.mismatches | def mismatches(self, other, include=None, exclude=None):
"""
Compares information stored within provenance objects with the
exception of version information to see if they match. Matches are
constrained to the paths passed to the 'include' kwarg, with the
exception of sub-paths p... | python | def mismatches(self, other, include=None, exclude=None):
"""
Compares information stored within provenance objects with the
exception of version information to see if they match. Matches are
constrained to the paths passed to the 'include' kwarg, with the
exception of sub-paths p... | [
"def",
"mismatches",
"(",
"self",
",",
"other",
",",
"include",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"if",
"include",
"is",
"not",
"None",
":",
"include_res",
"=",
"[",
"self",
".",
"_gen_prov_path_regex",
"(",
"p",
")",
"for",
"p",
"i... | Compares information stored within provenance objects with the
exception of version information to see if they match. Matches are
constrained to the paths passed to the 'include' kwarg, with the
exception of sub-paths passed to the 'exclude' kwarg
Parameters
----------
o... | [
"Compares",
"information",
"stored",
"within",
"provenance",
"objects",
"with",
"the",
"exception",
"of",
"version",
"information",
"to",
"see",
"if",
"they",
"match",
".",
"Matches",
"are",
"constrained",
"to",
"the",
"paths",
"passed",
"to",
"the",
"include",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/provenance.py#L171-L215 |
MonashBI/arcana | arcana/study/multi.py | MultiStudy.translate | def translate(cls, substudy_name, pipeline_getter, auto_added=False):
"""
A method for translating pipeline constructors from a sub-study to the
namespace of a multi-study. Returns a new method that calls the
sub-study pipeline constructor with appropriate keyword arguments
Para... | python | def translate(cls, substudy_name, pipeline_getter, auto_added=False):
"""
A method for translating pipeline constructors from a sub-study to the
namespace of a multi-study. Returns a new method that calls the
sub-study pipeline constructor with appropriate keyword arguments
Para... | [
"def",
"translate",
"(",
"cls",
",",
"substudy_name",
",",
"pipeline_getter",
",",
"auto_added",
"=",
"False",
")",
":",
"assert",
"isinstance",
"(",
"substudy_name",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"pipeline_getter",
",",
"basestring",
")",... | A method for translating pipeline constructors from a sub-study to the
namespace of a multi-study. Returns a new method that calls the
sub-study pipeline constructor with appropriate keyword arguments
Parameters
----------
substudy_name : str
Name of the sub-study
... | [
"A",
"method",
"for",
"translating",
"pipeline",
"constructors",
"from",
"a",
"sub",
"-",
"study",
"to",
"the",
"namespace",
"of",
"a",
"multi",
"-",
"study",
".",
"Returns",
"a",
"new",
"method",
"that",
"calls",
"the",
"sub",
"-",
"study",
"pipeline",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/multi.py#L169-L199 |
MonashBI/arcana | arcana/study/multi.py | SubStudySpec.auto_data_specs | def auto_data_specs(self):
"""
Data specs in the sub-study class that are not explicitly provided
in the name map
"""
for spec in self.study_class.data_specs():
if spec.name not in self._name_map:
yield spec | python | def auto_data_specs(self):
"""
Data specs in the sub-study class that are not explicitly provided
in the name map
"""
for spec in self.study_class.data_specs():
if spec.name not in self._name_map:
yield spec | [
"def",
"auto_data_specs",
"(",
"self",
")",
":",
"for",
"spec",
"in",
"self",
".",
"study_class",
".",
"data_specs",
"(",
")",
":",
"if",
"spec",
".",
"name",
"not",
"in",
"self",
".",
"_name_map",
":",
"yield",
"spec"
] | Data specs in the sub-study class that are not explicitly provided
in the name map | [
"Data",
"specs",
"in",
"the",
"sub",
"-",
"study",
"class",
"that",
"are",
"not",
"explicitly",
"provided",
"in",
"the",
"name",
"map"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/multi.py#L264-L271 |
MonashBI/arcana | arcana/study/multi.py | SubStudySpec.auto_param_specs | def auto_param_specs(self):
"""
Parameter pecs in the sub-study class that are not explicitly provided
in the name map
"""
for spec in self.study_class.parameter_specs():
if spec.name not in self._name_map:
yield spec | python | def auto_param_specs(self):
"""
Parameter pecs in the sub-study class that are not explicitly provided
in the name map
"""
for spec in self.study_class.parameter_specs():
if spec.name not in self._name_map:
yield spec | [
"def",
"auto_param_specs",
"(",
"self",
")",
":",
"for",
"spec",
"in",
"self",
".",
"study_class",
".",
"parameter_specs",
"(",
")",
":",
"if",
"spec",
".",
"name",
"not",
"in",
"self",
".",
"_name_map",
":",
"yield",
"spec"
] | Parameter pecs in the sub-study class that are not explicitly provided
in the name map | [
"Parameter",
"pecs",
"in",
"the",
"sub",
"-",
"study",
"class",
"that",
"are",
"not",
"explicitly",
"provided",
"in",
"the",
"name",
"map"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/study/multi.py#L274-L281 |
MonashBI/arcana | arcana/environment/base.py | MapNode._make_nodes | def _make_nodes(self, cwd=None):
"""
Cast generated nodes to be Arcana nodes
"""
for i, node in NipypeMapNode._make_nodes(self, cwd=cwd):
# "Cast" NiPype node to a Arcana Node and set Arcana Node
# parameters
node.__class__ = self.node_cls
... | python | def _make_nodes(self, cwd=None):
"""
Cast generated nodes to be Arcana nodes
"""
for i, node in NipypeMapNode._make_nodes(self, cwd=cwd):
# "Cast" NiPype node to a Arcana Node and set Arcana Node
# parameters
node.__class__ = self.node_cls
... | [
"def",
"_make_nodes",
"(",
"self",
",",
"cwd",
"=",
"None",
")",
":",
"for",
"i",
",",
"node",
"in",
"NipypeMapNode",
".",
"_make_nodes",
"(",
"self",
",",
"cwd",
"=",
"cwd",
")",
":",
"# \"Cast\" NiPype node to a Arcana Node and set Arcana Node",
"# parameters"... | Cast generated nodes to be Arcana nodes | [
"Cast",
"generated",
"nodes",
"to",
"be",
"Arcana",
"nodes"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/base.py#L107-L119 |
tym-xqo/nerium | nerium/query.py | get_query | def get_query(query_name):
"""Find file matching query_name, read and return query object
"""
query_file_match = list(
filter(lambda i: query_name == i.stem, FLAT_QUERIES))
if not query_file_match:
return None
# TODO: Log warning if more than one match
query_file = query_file_mat... | python | def get_query(query_name):
"""Find file matching query_name, read and return query object
"""
query_file_match = list(
filter(lambda i: query_name == i.stem, FLAT_QUERIES))
if not query_file_match:
return None
# TODO: Log warning if more than one match
query_file = query_file_mat... | [
"def",
"get_query",
"(",
"query_name",
")",
":",
"query_file_match",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"i",
":",
"query_name",
"==",
"i",
".",
"stem",
",",
"FLAT_QUERIES",
")",
")",
"if",
"not",
"query_file_match",
":",
"return",
"None",
"# TODO: ... | Find file matching query_name, read and return query object | [
"Find",
"file",
"matching",
"query_name",
"read",
"and",
"return",
"query",
"object"
] | train | https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/query.py#L19-L39 |
tym-xqo/nerium | nerium/query.py | get_result_set | def get_result_set(query_name, **kwargs):
""" Call get_query, then submit query from file to resultset module
"""
query = get_query(query_name)
if not query:
query = SimpleNamespace()
query.error = f"No query found matching '{query_name}'"
return query
try:
result_mod... | python | def get_result_set(query_name, **kwargs):
""" Call get_query, then submit query from file to resultset module
"""
query = get_query(query_name)
if not query:
query = SimpleNamespace()
query.error = f"No query found matching '{query_name}'"
return query
try:
result_mod... | [
"def",
"get_result_set",
"(",
"query_name",
",",
"*",
"*",
"kwargs",
")",
":",
"query",
"=",
"get_query",
"(",
"query_name",
")",
"if",
"not",
"query",
":",
"query",
"=",
"SimpleNamespace",
"(",
")",
"query",
".",
"error",
"=",
"f\"No query found matching '{... | Call get_query, then submit query from file to resultset module | [
"Call",
"get_query",
"then",
"submit",
"query",
"from",
"file",
"to",
"resultset",
"module"
] | train | https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/query.py#L49-L73 |
tym-xqo/nerium | nerium/query.py | results_to_csv | def results_to_csv(query_name, **kwargs):
""" Generate CSV from result data
"""
query = get_result_set(query_name, **kwargs)
result = query.result
columns = list(result[0].keys())
data = [tuple(row.values()) for row in result]
frame = tablib.Dataset()
frame.headers = columns
for row ... | python | def results_to_csv(query_name, **kwargs):
""" Generate CSV from result data
"""
query = get_result_set(query_name, **kwargs)
result = query.result
columns = list(result[0].keys())
data = [tuple(row.values()) for row in result]
frame = tablib.Dataset()
frame.headers = columns
for row ... | [
"def",
"results_to_csv",
"(",
"query_name",
",",
"*",
"*",
"kwargs",
")",
":",
"query",
"=",
"get_result_set",
"(",
"query_name",
",",
"*",
"*",
"kwargs",
")",
"result",
"=",
"query",
".",
"result",
"columns",
"=",
"list",
"(",
"result",
"[",
"0",
"]",... | Generate CSV from result data | [
"Generate",
"CSV",
"from",
"result",
"data"
] | train | https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/query.py#L76-L88 |
erikvw/django-collect-offline | django_collect_offline/site_offline_models.py | SiteOfflineModels.register | def register(self, models=None, wrapper_cls=None):
"""Registers with app_label.modelname, wrapper_cls.
"""
self.loaded = True
for model in models:
model = model.lower()
if model not in self.registry:
self.registry.update({model: wrapper_cls or self... | python | def register(self, models=None, wrapper_cls=None):
"""Registers with app_label.modelname, wrapper_cls.
"""
self.loaded = True
for model in models:
model = model.lower()
if model not in self.registry:
self.registry.update({model: wrapper_cls or self... | [
"def",
"register",
"(",
"self",
",",
"models",
"=",
"None",
",",
"wrapper_cls",
"=",
"None",
")",
":",
"self",
".",
"loaded",
"=",
"True",
"for",
"model",
"in",
"models",
":",
"model",
"=",
"model",
".",
"lower",
"(",
")",
"if",
"model",
"not",
"in... | Registers with app_label.modelname, wrapper_cls. | [
"Registers",
"with",
"app_label",
".",
"modelname",
"wrapper_cls",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/site_offline_models.py#L28-L42 |
erikvw/django-collect-offline | django_collect_offline/site_offline_models.py | SiteOfflineModels.register_for_app | def register_for_app(
self, app_label=None, exclude_models=None, exclude_model_classes=None
):
"""Registers all models for this app_label.
"""
models = []
exclude_models = exclude_models or []
app_config = django_apps.get_app_config(app_label)
for model in app... | python | def register_for_app(
self, app_label=None, exclude_models=None, exclude_model_classes=None
):
"""Registers all models for this app_label.
"""
models = []
exclude_models = exclude_models or []
app_config = django_apps.get_app_config(app_label)
for model in app... | [
"def",
"register_for_app",
"(",
"self",
",",
"app_label",
"=",
"None",
",",
"exclude_models",
"=",
"None",
",",
"exclude_model_classes",
"=",
"None",
")",
":",
"models",
"=",
"[",
"]",
"exclude_models",
"=",
"exclude_models",
"or",
"[",
"]",
"app_config",
"=... | Registers all models for this app_label. | [
"Registers",
"all",
"models",
"for",
"this",
"app_label",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/site_offline_models.py#L44-L59 |
erikvw/django-collect-offline | django_collect_offline/site_offline_models.py | SiteOfflineModels.get_wrapped_instance | def get_wrapped_instance(self, instance=None):
"""Returns a wrapped model instance.
"""
if instance._meta.label_lower not in self.registry:
raise ModelNotRegistered(f"{repr(instance)} is not registered with {self}.")
wrapper_cls = self.registry.get(instance._meta.label_lower)... | python | def get_wrapped_instance(self, instance=None):
"""Returns a wrapped model instance.
"""
if instance._meta.label_lower not in self.registry:
raise ModelNotRegistered(f"{repr(instance)} is not registered with {self}.")
wrapper_cls = self.registry.get(instance._meta.label_lower)... | [
"def",
"get_wrapped_instance",
"(",
"self",
",",
"instance",
"=",
"None",
")",
":",
"if",
"instance",
".",
"_meta",
".",
"label_lower",
"not",
"in",
"self",
".",
"registry",
":",
"raise",
"ModelNotRegistered",
"(",
"f\"{repr(instance)} is not registered with {self}.... | Returns a wrapped model instance. | [
"Returns",
"a",
"wrapped",
"model",
"instance",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/site_offline_models.py#L61-L69 |
erikvw/django-collect-offline | django_collect_offline/site_offline_models.py | SiteOfflineModels.site_models | def site_models(self, app_label=None):
"""Returns a dictionary of registered models.
"""
site_models = {}
app_configs = (
django_apps.get_app_configs()
if app_label is None
else [django_apps.get_app_config(app_label)]
)
for app_config i... | python | def site_models(self, app_label=None):
"""Returns a dictionary of registered models.
"""
site_models = {}
app_configs = (
django_apps.get_app_configs()
if app_label is None
else [django_apps.get_app_config(app_label)]
)
for app_config i... | [
"def",
"site_models",
"(",
"self",
",",
"app_label",
"=",
"None",
")",
":",
"site_models",
"=",
"{",
"}",
"app_configs",
"=",
"(",
"django_apps",
".",
"get_app_configs",
"(",
")",
"if",
"app_label",
"is",
"None",
"else",
"[",
"django_apps",
".",
"get_app_c... | Returns a dictionary of registered models. | [
"Returns",
"a",
"dictionary",
"of",
"registered",
"models",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/site_offline_models.py#L71-L89 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.get_fileset | def get_fileset(self, fileset):
"""
Set the path of the fileset from the repository
"""
# Don't need to cache fileset as it is already local as long
# as the path is set
if fileset._path is None:
primary_path = self.fileset_path(fileset)
aux_files ... | python | def get_fileset(self, fileset):
"""
Set the path of the fileset from the repository
"""
# Don't need to cache fileset as it is already local as long
# as the path is set
if fileset._path is None:
primary_path = self.fileset_path(fileset)
aux_files ... | [
"def",
"get_fileset",
"(",
"self",
",",
"fileset",
")",
":",
"# Don't need to cache fileset as it is already local as long",
"# as the path is set",
"if",
"fileset",
".",
"_path",
"is",
"None",
":",
"primary_path",
"=",
"self",
".",
"fileset_path",
"(",
"fileset",
")"... | Set the path of the fileset from the repository | [
"Set",
"the",
"path",
"of",
"the",
"fileset",
"from",
"the",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L94-L115 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.get_field | def get_field(self, field):
"""
Update the value of the field from the repository
"""
# Load fields JSON, locking to prevent read/write conflicts
# Would be better if only checked if locked to allow
# concurrent reads but not possible with multi-process
# locks (i... | python | def get_field(self, field):
"""
Update the value of the field from the repository
"""
# Load fields JSON, locking to prevent read/write conflicts
# Would be better if only checked if locked to allow
# concurrent reads but not possible with multi-process
# locks (i... | [
"def",
"get_field",
"(",
"self",
",",
"field",
")",
":",
"# Load fields JSON, locking to prevent read/write conflicts",
"# Would be better if only checked if locked to allow",
"# concurrent reads but not possible with multi-process",
"# locks (in my understanding at least).",
"fpath",
"=",... | Update the value of the field from the repository | [
"Update",
"the",
"value",
"of",
"the",
"field",
"from",
"the",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L117-L146 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.put_fileset | def put_fileset(self, fileset):
"""
Inserts or updates a fileset in the repository
"""
target_path = self.fileset_path(fileset)
if op.isfile(fileset.path):
shutil.copyfile(fileset.path, target_path)
# Copy side car files into repository
for aux... | python | def put_fileset(self, fileset):
"""
Inserts or updates a fileset in the repository
"""
target_path = self.fileset_path(fileset)
if op.isfile(fileset.path):
shutil.copyfile(fileset.path, target_path)
# Copy side car files into repository
for aux... | [
"def",
"put_fileset",
"(",
"self",
",",
"fileset",
")",
":",
"target_path",
"=",
"self",
".",
"fileset_path",
"(",
"fileset",
")",
"if",
"op",
".",
"isfile",
"(",
"fileset",
".",
"path",
")",
":",
"shutil",
".",
"copyfile",
"(",
"fileset",
".",
"path",... | Inserts or updates a fileset in the repository | [
"Inserts",
"or",
"updates",
"a",
"fileset",
"in",
"the",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L148-L164 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.put_field | def put_field(self, field):
"""
Inserts or updates a field in the repository
"""
fpath = self.fields_json_path(field)
# Open fields JSON, locking to prevent other processes
# reading or writing
with InterProcessLock(fpath + self.LOCK_SUFFIX, logger=logger):
... | python | def put_field(self, field):
"""
Inserts or updates a field in the repository
"""
fpath = self.fields_json_path(field)
# Open fields JSON, locking to prevent other processes
# reading or writing
with InterProcessLock(fpath + self.LOCK_SUFFIX, logger=logger):
... | [
"def",
"put_field",
"(",
"self",
",",
"field",
")",
":",
"fpath",
"=",
"self",
".",
"fields_json_path",
"(",
"field",
")",
"# Open fields JSON, locking to prevent other processes",
"# reading or writing",
"with",
"InterProcessLock",
"(",
"fpath",
"+",
"self",
".",
"... | Inserts or updates a field in the repository | [
"Inserts",
"or",
"updates",
"a",
"field",
"in",
"the",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L166-L187 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.find_data | def find_data(self, subject_ids=None, visit_ids=None, **kwargs):
"""
Find all data within a repository, registering filesets, fields and
provenance with the found_fileset, found_field and found_provenance
methods, respectively
Parameters
----------
subject_ids : ... | python | def find_data(self, subject_ids=None, visit_ids=None, **kwargs):
"""
Find all data within a repository, registering filesets, fields and
provenance with the found_fileset, found_field and found_provenance
methods, respectively
Parameters
----------
subject_ids : ... | [
"def",
"find_data",
"(",
"self",
",",
"subject_ids",
"=",
"None",
",",
"visit_ids",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"all_filesets",
"=",
"[",
"]",
"all_fields",
"=",
"[",
"]",
"all_records",
"=",
"[",
"]",
"for",
"session_path",
",",
... | Find all data within a repository, registering filesets, fields and
provenance with the found_fileset, found_field and found_provenance
methods, respectively
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. If
... | [
"Find",
"all",
"data",
"within",
"a",
"repository",
"registering",
"filesets",
"fields",
"and",
"provenance",
"with",
"the",
"found_fileset",
"found_field",
"and",
"found_provenance",
"methods",
"respectively"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L195-L295 |
MonashBI/arcana | arcana/repository/basic.py | BasicRepo.guess_depth | def guess_depth(self, root_dir):
"""
Try to guess the depth of a directory repository (i.e. whether it has
sub-folders for multiple subjects or visits, depending on where files
and/or derived label files are found in the hierarchy of
sub-directories under the root dir.
P... | python | def guess_depth(self, root_dir):
"""
Try to guess the depth of a directory repository (i.e. whether it has
sub-folders for multiple subjects or visits, depending on where files
and/or derived label files are found in the hierarchy of
sub-directories under the root dir.
P... | [
"def",
"guess_depth",
"(",
"self",
",",
"root_dir",
")",
":",
"deepest",
"=",
"-",
"1",
"for",
"path",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root_dir",
")",
":",
"depth",
"=",
"self",
".",
"path_depth",
"(",
"path",
")",
"filter... | Try to guess the depth of a directory repository (i.e. whether it has
sub-folders for multiple subjects or visits, depending on where files
and/or derived label files are found in the hierarchy of
sub-directories under the root dir.
Parameters
----------
root_dir : str
... | [
"Try",
"to",
"guess",
"the",
"depth",
"of",
"a",
"directory",
"repository",
"(",
"i",
".",
"e",
".",
"whether",
"it",
"has",
"sub",
"-",
"folders",
"for",
"multiple",
"subjects",
"or",
"visits",
"depending",
"on",
"where",
"files",
"and",
"/",
"or",
"d... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/basic.py#L376-L423 |
tym-xqo/nerium | nerium/data_source.py | get_data_source | def get_data_source(query):
""" Get data source connection metadata based on config. Prefer, in order:
- Query file frontmatter
- `db.yaml` file in query subdirectory
- DATABASE_URL in environment
To allow for possible non-SQL sources to be contributed, we only
return a config value... | python | def get_data_source(query):
""" Get data source connection metadata based on config. Prefer, in order:
- Query file frontmatter
- `db.yaml` file in query subdirectory
- DATABASE_URL in environment
To allow for possible non-SQL sources to be contributed, we only
return a config value... | [
"def",
"get_data_source",
"(",
"query",
")",
":",
"# *** GET CONNECTION PARAMS: ***",
"# from frontmatter",
"try",
":",
"return",
"query",
".",
"metadata",
"[",
"'data_source'",
"]",
"except",
"KeyError",
":",
"try",
":",
"return",
"dict",
"(",
"url",
"=",
"quer... | Get data source connection metadata based on config. Prefer, in order:
- Query file frontmatter
- `db.yaml` file in query subdirectory
- DATABASE_URL in environment
To allow for possible non-SQL sources to be contributed, we only
return a config value here, and leave connecting to concr... | [
"Get",
"data",
"source",
"connection",
"metadata",
"based",
"on",
"config",
".",
"Prefer",
"in",
"order",
":",
"-",
"Query",
"file",
"frontmatter",
"-",
"db",
".",
"yaml",
"file",
"in",
"query",
"subdirectory",
"-",
"DATABASE_URL",
"in",
"environment"
] | train | https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/data_source.py#L6-L43 |
MonashBI/arcana | arcana/data/collection.py | BaseCollection.item | def item(self, subject_id=None, visit_id=None):
"""
Returns a particular fileset|field in the collection corresponding to
the given subject and visit_ids. subject_id and visit_id must be
provided for relevant frequencies. Note that subject_id/visit_id can
also be provided for non... | python | def item(self, subject_id=None, visit_id=None):
"""
Returns a particular fileset|field in the collection corresponding to
the given subject and visit_ids. subject_id and visit_id must be
provided for relevant frequencies. Note that subject_id/visit_id can
also be provided for non... | [
"def",
"item",
"(",
"self",
",",
"subject_id",
"=",
"None",
",",
"visit_id",
"=",
"None",
")",
":",
"if",
"self",
".",
"frequency",
"==",
"'per_session'",
":",
"if",
"subject_id",
"is",
"None",
"or",
"visit_id",
"is",
"None",
":",
"raise",
"ArcanaError",... | Returns a particular fileset|field in the collection corresponding to
the given subject and visit_ids. subject_id and visit_id must be
provided for relevant frequencies. Note that subject_id/visit_id can
also be provided for non-relevant frequencies, they will just be
ignored.
P... | [
"Returns",
"a",
"particular",
"fileset|field",
"in",
"the",
"collection",
"corresponding",
"to",
"the",
"given",
"subject",
"and",
"visit_ids",
".",
"subject_id",
"and",
"visit_id",
"must",
"be",
"provided",
"for",
"relevant",
"frequencies",
".",
"Note",
"that",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/collection.py#L85-L159 |
MonashBI/arcana | arcana/data/collection.py | BaseCollection.bind | def bind(self, study, **kwargs): # @UnusedVariable
"""
Used for duck typing Collection objects with Spec and Match
in source and sink initiation. Checks IDs match sessions in study.
"""
if self.frequency == 'per_subject':
tree_subject_ids = list(study.tree.subject_id... | python | def bind(self, study, **kwargs): # @UnusedVariable
"""
Used for duck typing Collection objects with Spec and Match
in source and sink initiation. Checks IDs match sessions in study.
"""
if self.frequency == 'per_subject':
tree_subject_ids = list(study.tree.subject_id... | [
"def",
"bind",
"(",
"self",
",",
"study",
",",
"*",
"*",
"kwargs",
")",
":",
"# @UnusedVariable",
"if",
"self",
".",
"frequency",
"==",
"'per_subject'",
":",
"tree_subject_ids",
"=",
"list",
"(",
"study",
".",
"tree",
".",
"subject_ids",
")",
"subject_ids"... | Used for duck typing Collection objects with Spec and Match
in source and sink initiation. Checks IDs match sessions in study. | [
"Used",
"for",
"duck",
"typing",
"Collection",
"objects",
"with",
"Spec",
"and",
"Match",
"in",
"source",
"and",
"sink",
"initiation",
".",
"Checks",
"IDs",
"match",
"sessions",
"in",
"study",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/collection.py#L167-L205 |
MonashBI/arcana | arcana/repository/tree.py | TreeNode.fileset | def fileset(self, name, from_study=None, format=None): # @ReservedAssignment @IgnorePep8
"""
Gets the fileset named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is deriv... | python | def fileset(self, name, from_study=None, format=None): # @ReservedAssignment @IgnorePep8
"""
Gets the fileset named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is deriv... | [
"def",
"fileset",
"(",
"self",
",",
"name",
",",
"from_study",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"# @ReservedAssignment @IgnorePep8",
"if",
"isinstance",
"(",
"name",
",",
"BaseFileset",
")",
":",
"if",
"from_study",
"is",
"None",
"and",
"... | Gets the fileset named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is derived
Parameters
----------
name : str | FilesetSpec
The name of the fileset... | [
"Gets",
"the",
"fileset",
"named",
"name",
"produced",
"by",
"the",
"Study",
"named",
"study",
"if",
"provided",
".",
"If",
"a",
"spec",
"is",
"passed",
"instead",
"of",
"a",
"str",
"to",
"the",
"name",
"argument",
"then",
"the",
"study",
"will",
"be",
... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L114-L199 |
MonashBI/arcana | arcana/repository/tree.py | TreeNode.field | def field(self, name, from_study=None):
"""
Gets the field named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is derived
Parameters
----------
na... | python | def field(self, name, from_study=None):
"""
Gets the field named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is derived
Parameters
----------
na... | [
"def",
"field",
"(",
"self",
",",
"name",
",",
"from_study",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"BaseField",
")",
":",
"if",
"from_study",
"is",
"None",
"and",
"name",
".",
"derived",
":",
"from_study",
"=",
"name",
".",
"st... | Gets the field named 'name' produced by the Study named 'study' if
provided. If a spec is passed instead of a str to the name argument,
then the study will be set from the spec iff it is derived
Parameters
----------
name : str | BaseField
The name of the field or a ... | [
"Gets",
"the",
"field",
"named",
"name",
"produced",
"by",
"the",
"Study",
"named",
"study",
"if",
"provided",
".",
"If",
"a",
"spec",
"is",
"passed",
"instead",
"of",
"a",
"str",
"to",
"the",
"name",
"argument",
"then",
"the",
"study",
"will",
"be",
"... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L201-L241 |
MonashBI/arcana | arcana/repository/tree.py | TreeNode.record | def record(self, pipeline_name, from_study):
"""
Returns the provenance record for a given pipeline
Parameters
----------
pipeline_name : str
The name of the pipeline that generated the record
from_study : str
The name of the study that the pipeli... | python | def record(self, pipeline_name, from_study):
"""
Returns the provenance record for a given pipeline
Parameters
----------
pipeline_name : str
The name of the pipeline that generated the record
from_study : str
The name of the study that the pipeli... | [
"def",
"record",
"(",
"self",
",",
"pipeline_name",
",",
"from_study",
")",
":",
"try",
":",
"return",
"self",
".",
"_records",
"[",
"(",
"pipeline_name",
",",
"from_study",
")",
"]",
"except",
"KeyError",
":",
"found",
"=",
"[",
"]",
"for",
"sname",
"... | Returns the provenance record for a given pipeline
Parameters
----------
pipeline_name : str
The name of the pipeline that generated the record
from_study : str
The name of the study that the pipeline was generated from
Returns
-------
re... | [
"Returns",
"the",
"provenance",
"record",
"for",
"a",
"given",
"pipeline"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L243-L274 |
MonashBI/arcana | arcana/repository/tree.py | TreeNode.find_mismatch | def find_mismatch(self, other, indent=''):
"""
Highlights where two nodes differ in a human-readable form
Parameters
----------
other : TreeNode
The node to compare
indent : str
The white-space with which to indent output string
Returns
... | python | def find_mismatch(self, other, indent=''):
"""
Highlights where two nodes differ in a human-readable form
Parameters
----------
other : TreeNode
The node to compare
indent : str
The white-space with which to indent output string
Returns
... | [
"def",
"find_mismatch",
"(",
"self",
",",
"other",
",",
"indent",
"=",
"''",
")",
":",
"if",
"self",
"!=",
"other",
":",
"mismatch",
"=",
"\"\\n{}{}\"",
".",
"format",
"(",
"indent",
",",
"type",
"(",
"self",
")",
".",
"__name__",
")",
"else",
":",
... | Highlights where two nodes differ in a human-readable form
Parameters
----------
other : TreeNode
The node to compare
indent : str
The white-space with which to indent output string
Returns
-------
mismatch : str
The human-rea... | [
"Highlights",
"where",
"two",
"nodes",
"differ",
"in",
"a",
"human",
"-",
"readable",
"form"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L283-L328 |
MonashBI/arcana | arcana/repository/tree.py | Tree.nodes | def nodes(self, frequency=None):
"""
Returns an iterator over all nodes in the tree for the specified
frequency. If no frequency is specified then all nodes are returned
Parameters
----------
frequency : str | None
The frequency of the nodes to iterate over. ... | python | def nodes(self, frequency=None):
"""
Returns an iterator over all nodes in the tree for the specified
frequency. If no frequency is specified then all nodes are returned
Parameters
----------
frequency : str | None
The frequency of the nodes to iterate over. ... | [
"def",
"nodes",
"(",
"self",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"frequency",
"is",
"None",
":",
"nodes",
"=",
"chain",
"(",
"*",
"(",
"self",
".",
"_nodes",
"(",
"f",
")",
"for",
"f",
"in",
"(",
"'per_study'",
",",
"'per_subject'",
",",... | Returns an iterator over all nodes in the tree for the specified
frequency. If no frequency is specified then all nodes are returned
Parameters
----------
frequency : str | None
The frequency of the nodes to iterate over. If None all
frequencies are returned
... | [
"Returns",
"an",
"iterator",
"over",
"all",
"nodes",
"in",
"the",
"tree",
"for",
"the",
"specified",
"frequency",
".",
"If",
"no",
"frequency",
"is",
"specified",
"then",
"all",
"nodes",
"are",
"returned"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L488-L509 |
MonashBI/arcana | arcana/repository/tree.py | Tree.find_mismatch | def find_mismatch(self, other, indent=''):
"""
Used in debugging unittests
"""
mismatch = super(Tree, self).find_mismatch(other, indent)
sub_indent = indent + ' '
if len(list(self.subjects)) != len(list(other.subjects)):
mismatch += ('\n{indent}mismatching su... | python | def find_mismatch(self, other, indent=''):
"""
Used in debugging unittests
"""
mismatch = super(Tree, self).find_mismatch(other, indent)
sub_indent = indent + ' '
if len(list(self.subjects)) != len(list(other.subjects)):
mismatch += ('\n{indent}mismatching su... | [
"def",
"find_mismatch",
"(",
"self",
",",
"other",
",",
"indent",
"=",
"''",
")",
":",
"mismatch",
"=",
"super",
"(",
"Tree",
",",
"self",
")",
".",
"find_mismatch",
"(",
"other",
",",
"indent",
")",
"sub_indent",
"=",
"indent",
"+",
"' '",
"if",
"l... | Used in debugging unittests | [
"Used",
"in",
"debugging",
"unittests"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L524-L554 |
MonashBI/arcana | arcana/repository/tree.py | Tree._fill_empty_sessions | def _fill_empty_sessions(self, fill_subjects, fill_visits):
"""
Fill in tree with additional empty subjects and/or visits to
allow the study to pull its inputs from external repositories
"""
if fill_subjects is None:
fill_subjects = [s.id for s in self.subjects]
... | python | def _fill_empty_sessions(self, fill_subjects, fill_visits):
"""
Fill in tree with additional empty subjects and/or visits to
allow the study to pull its inputs from external repositories
"""
if fill_subjects is None:
fill_subjects = [s.id for s in self.subjects]
... | [
"def",
"_fill_empty_sessions",
"(",
"self",
",",
"fill_subjects",
",",
"fill_visits",
")",
":",
"if",
"fill_subjects",
"is",
"None",
":",
"fill_subjects",
"=",
"[",
"s",
".",
"id",
"for",
"s",
"in",
"self",
".",
"subjects",
"]",
"if",
"fill_visits",
"is",
... | Fill in tree with additional empty subjects and/or visits to
allow the study to pull its inputs from external repositories | [
"Fill",
"in",
"tree",
"with",
"additional",
"empty",
"subjects",
"and",
"/",
"or",
"visits",
"to",
"allow",
"the",
"study",
"to",
"pull",
"its",
"inputs",
"from",
"external",
"repositories"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L563-L589 |
MonashBI/arcana | arcana/repository/tree.py | Tree.construct | def construct(cls, repository, filesets=(), fields=(), records=(),
file_formats=(), **kwargs):
"""
Return the hierarchical tree of the filesets and fields stored in a
repository
Parameters
----------
respository : Repository
The repository t... | python | def construct(cls, repository, filesets=(), fields=(), records=(),
file_formats=(), **kwargs):
"""
Return the hierarchical tree of the filesets and fields stored in a
repository
Parameters
----------
respository : Repository
The repository t... | [
"def",
"construct",
"(",
"cls",
",",
"repository",
",",
"filesets",
"=",
"(",
")",
",",
"fields",
"=",
"(",
")",
",",
"records",
"=",
"(",
")",
",",
"file_formats",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"# Sort the data by subject and visit... | Return the hierarchical tree of the filesets and fields stored in a
repository
Parameters
----------
respository : Repository
The repository that the tree comes from
filesets : list[Fileset]
List of all filesets in the tree
fields : list[Field]
... | [
"Return",
"the",
"hierarchical",
"tree",
"of",
"the",
"filesets",
"and",
"fields",
"stored",
"in",
"a",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L592-L664 |
MonashBI/arcana | arcana/repository/tree.py | Session.nodes | def nodes(self, frequency=None):
"""
Returns all nodes of the specified frequency that are related to
the given Session
Parameters
----------
frequency : str | None
The frequency of the nodes to return
Returns
-------
nodes : iterable... | python | def nodes(self, frequency=None):
"""
Returns all nodes of the specified frequency that are related to
the given Session
Parameters
----------
frequency : str | None
The frequency of the nodes to return
Returns
-------
nodes : iterable... | [
"def",
"nodes",
"(",
"self",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"frequency",
"is",
"None",
":",
"[",
"]",
"elif",
"frequency",
"==",
"'per_session'",
":",
"return",
"[",
"self",
"]",
"elif",
"frequency",
"in",
"(",
"'per_visit'",
",",
"'per... | Returns all nodes of the specified frequency that are related to
the given Session
Parameters
----------
frequency : str | None
The frequency of the nodes to return
Returns
-------
nodes : iterable[TreeNode]
All nodes related to the Sessi... | [
"Returns",
"all",
"nodes",
"of",
"the",
"specified",
"frequency",
"that",
"are",
"related",
"to",
"the",
"given",
"Session"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/tree.py#L1015-L1037 |
gwww/elkm1 | elkm1_lib/proto.py | Connection.write_data | def write_data(self, data, response_required=None, timeout=5.0, raw=False):
"""Write data on the asyncio Protocol"""
if self._transport is None:
return
if self._paused:
return
if self._waiting_for_response:
LOG.debug("queueing write %s", data)
... | python | def write_data(self, data, response_required=None, timeout=5.0, raw=False):
"""Write data on the asyncio Protocol"""
if self._transport is None:
return
if self._paused:
return
if self._waiting_for_response:
LOG.debug("queueing write %s", data)
... | [
"def",
"write_data",
"(",
"self",
",",
"data",
",",
"response_required",
"=",
"None",
",",
"timeout",
"=",
"5.0",
",",
"raw",
"=",
"False",
")",
":",
"if",
"self",
".",
"_transport",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_paused",
":",
"re... | Write data on the asyncio Protocol | [
"Write",
"data",
"on",
"the",
"asyncio",
"Protocol"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/proto.py#L82-L108 |
tym-xqo/nerium | nerium/utils.py | unwrap_querystring_lists | def unwrap_querystring_lists(obj):
"""Convert responder querystring params, pulling values out of list
if there's only one.
"""
new_dict = {
key: (obj[key][0]
if len(obj[key]) == 1 else obj[key])
for key in obj.keys()
}
return new_dict | python | def unwrap_querystring_lists(obj):
"""Convert responder querystring params, pulling values out of list
if there's only one.
"""
new_dict = {
key: (obj[key][0]
if len(obj[key]) == 1 else obj[key])
for key in obj.keys()
}
return new_dict | [
"def",
"unwrap_querystring_lists",
"(",
"obj",
")",
":",
"new_dict",
"=",
"{",
"key",
":",
"(",
"obj",
"[",
"key",
"]",
"[",
"0",
"]",
"if",
"len",
"(",
"obj",
"[",
"key",
"]",
")",
"==",
"1",
"else",
"obj",
"[",
"key",
"]",
")",
"for",
"key",
... | Convert responder querystring params, pulling values out of list
if there's only one. | [
"Convert",
"responder",
"querystring",
"params",
"pulling",
"values",
"out",
"of",
"list",
"if",
"there",
"s",
"only",
"one",
"."
] | train | https://github.com/tym-xqo/nerium/blob/b234847d95f37c3a49dff15a189205fe5bbbc05f/nerium/utils.py#L1-L10 |
MonashBI/arcana | arcana/data/input.py | BaseInput.pipeline_getter | def pipeline_getter(self):
"For duck-typing with *Spec types"
if not self.derivable:
raise ArcanaUsageError(
"There is no pipeline getter for {} because it doesn't "
"fallback to a derived spec".format(self))
return self._fallback.pipeline_getter | python | def pipeline_getter(self):
"For duck-typing with *Spec types"
if not self.derivable:
raise ArcanaUsageError(
"There is no pipeline getter for {} because it doesn't "
"fallback to a derived spec".format(self))
return self._fallback.pipeline_getter | [
"def",
"pipeline_getter",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"derivable",
":",
"raise",
"ArcanaUsageError",
"(",
"\"There is no pipeline getter for {} because it doesn't \"",
"\"fallback to a derived spec\"",
".",
"format",
"(",
"self",
")",
")",
"return",... | For duck-typing with *Spec types | [
"For",
"duck",
"-",
"typing",
"with",
"*",
"Spec",
"types"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/input.py#L135-L141 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.prerequisites | def prerequisites(self):
"""
Iterates through the inputs of the pipelinen and determines the
all prerequisite pipelines
"""
# Loop through the inputs to the pipeline and add the instancemethods
# for the pipelines to generate each of the processed inputs
prereqs =... | python | def prerequisites(self):
"""
Iterates through the inputs of the pipelinen and determines the
all prerequisite pipelines
"""
# Loop through the inputs to the pipeline and add the instancemethods
# for the pipelines to generate each of the processed inputs
prereqs =... | [
"def",
"prerequisites",
"(",
"self",
")",
":",
"# Loop through the inputs to the pipeline and add the instancemethods",
"# for the pipelines to generate each of the processed inputs",
"prereqs",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"input",
"in",
"self",
".",
"inputs",
... | Iterates through the inputs of the pipelinen and determines the
all prerequisite pipelines | [
"Iterates",
"through",
"the",
"inputs",
"of",
"the",
"pipelinen",
"and",
"determines",
"the",
"all",
"prerequisite",
"pipelines"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L147-L160 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.study_inputs | def study_inputs(self):
"""
Returns all inputs of the study used by the pipeline, including inputs
of prerequisites (and their prerequisites recursively)
"""
return set(chain(
(i for i in self.inputs if not i.derived),
*(self.study.pipeline(p, required_out... | python | def study_inputs(self):
"""
Returns all inputs of the study used by the pipeline, including inputs
of prerequisites (and their prerequisites recursively)
"""
return set(chain(
(i for i in self.inputs if not i.derived),
*(self.study.pipeline(p, required_out... | [
"def",
"study_inputs",
"(",
"self",
")",
":",
"return",
"set",
"(",
"chain",
"(",
"(",
"i",
"for",
"i",
"in",
"self",
".",
"inputs",
"if",
"not",
"i",
".",
"derived",
")",
",",
"*",
"(",
"self",
".",
"study",
".",
"pipeline",
"(",
"p",
",",
"re... | Returns all inputs of the study used by the pipeline, including inputs
of prerequisites (and their prerequisites recursively) | [
"Returns",
"all",
"inputs",
"of",
"the",
"study",
"used",
"by",
"the",
"pipeline",
"including",
"inputs",
"of",
"prerequisites",
"(",
"and",
"their",
"prerequisites",
"recursively",
")"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L163-L171 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.add | def add(self, name, interface, inputs=None, outputs=None,
requirements=None, wall_time=None, annotations=None, **kwargs):
"""
Adds a processing Node to the pipeline
Parameters
----------
name : str
Name for the node
interface : nipype.Interface
... | python | def add(self, name, interface, inputs=None, outputs=None,
requirements=None, wall_time=None, annotations=None, **kwargs):
"""
Adds a processing Node to the pipeline
Parameters
----------
name : str
Name for the node
interface : nipype.Interface
... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"interface",
",",
"inputs",
"=",
"None",
",",
"outputs",
"=",
"None",
",",
"requirements",
"=",
"None",
",",
"wall_time",
"=",
"None",
",",
"annotations",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
... | Adds a processing Node to the pipeline
Parameters
----------
name : str
Name for the node
interface : nipype.Interface
The interface to use for the node
inputs : dict[str, (str, FileFormat) | (Node, str)]
Connections from inputs of the pipelin... | [
"Adds",
"a",
"processing",
"Node",
"to",
"the",
"pipeline"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L173-L281 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.connect_input | def connect_input(self, spec_name, node, node_input, format=None, **kwargs): # @ReservedAssignment @IgnorePep8
"""
Connects a study fileset_spec as an input to the provided node
Parameters
----------
spec_name : str
Name of the study data spec (or one of the IDs fro... | python | def connect_input(self, spec_name, node, node_input, format=None, **kwargs): # @ReservedAssignment @IgnorePep8
"""
Connects a study fileset_spec as an input to the provided node
Parameters
----------
spec_name : str
Name of the study data spec (or one of the IDs fro... | [
"def",
"connect_input",
"(",
"self",
",",
"spec_name",
",",
"node",
",",
"node_input",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# @ReservedAssignment @IgnorePep8",
"if",
"spec_name",
"in",
"self",
".",
"study",
".",
"ITERFIELDS",
":",
... | Connects a study fileset_spec as an input to the provided node
Parameters
----------
spec_name : str
Name of the study data spec (or one of the IDs from the iterator
nodes, 'subject_id' or 'visit_id') to connect to the node
node : arcana.Node
The node... | [
"Connects",
"a",
"study",
"fileset_spec",
"as",
"an",
"input",
"to",
"the",
"provided",
"node"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L283-L311 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.connect_output | def connect_output(self, spec_name, node, node_output, format=None, # @ReservedAssignment @IgnorePep8
**kwargs):
"""
Connects an output to a study fileset spec
Parameters
----------
spec_name : str
Name of the study fileset spec to connect to... | python | def connect_output(self, spec_name, node, node_output, format=None, # @ReservedAssignment @IgnorePep8
**kwargs):
"""
Connects an output to a study fileset spec
Parameters
----------
spec_name : str
Name of the study fileset spec to connect to... | [
"def",
"connect_output",
"(",
"self",
",",
"spec_name",
",",
"node",
",",
"node_output",
",",
"format",
"=",
"None",
",",
"# @ReservedAssignment @IgnorePep8",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"self",
".",
"_map_name",
"(",
"spec_name",
",",
"self",... | Connects an output to a study fileset spec
Parameters
----------
spec_name : str
Name of the study fileset spec to connect to
node : arcana.Node
The node to connect the output from
node_output : str
Name of the output on the node to connect to... | [
"Connects",
"an",
"output",
"to",
"a",
"study",
"fileset",
"spec"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L313-L344 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._map_name | def _map_name(self, name, mapper):
"""
Maps a spec name to a new value based on the provided mapper
"""
if mapper is not None:
if isinstance(mapper, basestring):
name = mapper + name
try:
name = mapper[name]
except KeyEr... | python | def _map_name(self, name, mapper):
"""
Maps a spec name to a new value based on the provided mapper
"""
if mapper is not None:
if isinstance(mapper, basestring):
name = mapper + name
try:
name = mapper[name]
except KeyEr... | [
"def",
"_map_name",
"(",
"self",
",",
"name",
",",
"mapper",
")",
":",
"if",
"mapper",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"mapper",
",",
"basestring",
")",
":",
"name",
"=",
"mapper",
"+",
"name",
"try",
":",
"name",
"=",
"mapper",
... | Maps a spec name to a new value based on the provided mapper | [
"Maps",
"a",
"spec",
"name",
"to",
"a",
"new",
"value",
"based",
"on",
"the",
"provided",
"mapper"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L346-L357 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.requires_conversion | def requires_conversion(cls, fileset, file_format):
"""Checks whether the fileset matches the requested file format"""
if file_format is None:
return False
try:
filset_format = fileset.format
except AttributeError:
return False # Field input
e... | python | def requires_conversion(cls, fileset, file_format):
"""Checks whether the fileset matches the requested file format"""
if file_format is None:
return False
try:
filset_format = fileset.format
except AttributeError:
return False # Field input
e... | [
"def",
"requires_conversion",
"(",
"cls",
",",
"fileset",
",",
"file_format",
")",
":",
"if",
"file_format",
"is",
"None",
":",
"return",
"False",
"try",
":",
"filset_format",
"=",
"fileset",
".",
"format",
"except",
"AttributeError",
":",
"return",
"False",
... | Checks whether the fileset matches the requested file format | [
"Checks",
"whether",
"the",
"fileset",
"matches",
"the",
"requested",
"file",
"format"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L449-L458 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.save_graph | def save_graph(self, fname, style='flat', format='png', **kwargs): # @ReservedAssignment @IgnorePep8
"""
Saves a graph of the pipeline to file
Parameters
----------
fname : str
The filename for the saved graph
style : str
The style of the graph, ... | python | def save_graph(self, fname, style='flat', format='png', **kwargs): # @ReservedAssignment @IgnorePep8
"""
Saves a graph of the pipeline to file
Parameters
----------
fname : str
The filename for the saved graph
style : str
The style of the graph, ... | [
"def",
"save_graph",
"(",
"self",
",",
"fname",
",",
"style",
"=",
"'flat'",
",",
"format",
"=",
"'png'",
",",
"*",
"*",
"kwargs",
")",
":",
"# @ReservedAssignment @IgnorePep8",
"fname",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"fname",
")",
"if",... | Saves a graph of the pipeline to file
Parameters
----------
fname : str
The filename for the saved graph
style : str
The style of the graph, can be one of can be one of
'orig', 'flat', 'exec', 'hierarchical'
plot : bool
Whether to ... | [
"Saves",
"a",
"graph",
"of",
"the",
"pipeline",
"to",
"file"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L473-L505 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.iterators | def iterators(self, frequency=None):
"""
Returns the iterators (i.e. subject_id, visit_id) that the pipeline
iterates over
Parameters
----------
frequency : str | None
A selected data frequency to use to determine which iterators are
required. If ... | python | def iterators(self, frequency=None):
"""
Returns the iterators (i.e. subject_id, visit_id) that the pipeline
iterates over
Parameters
----------
frequency : str | None
A selected data frequency to use to determine which iterators are
required. If ... | [
"def",
"iterators",
"(",
"self",
",",
"frequency",
"=",
"None",
")",
":",
"iterators",
"=",
"set",
"(",
")",
"if",
"frequency",
"is",
"None",
":",
"input_freqs",
"=",
"list",
"(",
"self",
".",
"input_frequencies",
")",
"else",
":",
"input_freqs",
"=",
... | Returns the iterators (i.e. subject_id, visit_id) that the pipeline
iterates over
Parameters
----------
frequency : str | None
A selected data frequency to use to determine which iterators are
required. If None, all input frequencies of the pipeline are
... | [
"Returns",
"the",
"iterators",
"(",
"i",
".",
"e",
".",
"subject_id",
"visit_id",
")",
"that",
"the",
"pipeline",
"iterates",
"over"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L507-L526 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._unwrap_maps | def _unwrap_maps(self, name_maps, name, study=None, **inner_maps):
"""
Unwraps potentially nested name-mapping dictionaries to get values
for name, input_map, output_map and study. Unsed in __init__.
Parameters
----------
name_maps : dict
A dictionary contain... | python | def _unwrap_maps(self, name_maps, name, study=None, **inner_maps):
"""
Unwraps potentially nested name-mapping dictionaries to get values
for name, input_map, output_map and study. Unsed in __init__.
Parameters
----------
name_maps : dict
A dictionary contain... | [
"def",
"_unwrap_maps",
"(",
"self",
",",
"name_maps",
",",
"name",
",",
"study",
"=",
"None",
",",
"*",
"*",
"inner_maps",
")",
":",
"# Set values of name and study",
"name",
"=",
"name_maps",
".",
"get",
"(",
"'name'",
",",
"name",
")",
"name",
"=",
"na... | Unwraps potentially nested name-mapping dictionaries to get values
for name, input_map, output_map and study. Unsed in __init__.
Parameters
----------
name_maps : dict
A dictionary containing the name_maps to apply to the values
name : str
Name passed fro... | [
"Unwraps",
"potentially",
"nested",
"name",
"-",
"mapping",
"dictionaries",
"to",
"get",
"values",
"for",
"name",
"input_map",
"output_map",
"and",
"study",
".",
"Unsed",
"in",
"__init__",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L542-L637 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.cap | def cap(self):
"""
"Caps" the construction of the pipeline, signifying that no more inputs
and outputs are expected to be added and therefore the input and output
nodes can be created along with the provenance.
"""
to_cap = (self._inputnodes, self._outputnodes, self._prov... | python | def cap(self):
"""
"Caps" the construction of the pipeline, signifying that no more inputs
and outputs are expected to be added and therefore the input and output
nodes can be created along with the provenance.
"""
to_cap = (self._inputnodes, self._outputnodes, self._prov... | [
"def",
"cap",
"(",
"self",
")",
":",
"to_cap",
"=",
"(",
"self",
".",
"_inputnodes",
",",
"self",
".",
"_outputnodes",
",",
"self",
".",
"_prov",
")",
"if",
"to_cap",
"==",
"(",
"None",
",",
"None",
",",
"None",
")",
":",
"self",
".",
"_inputnodes"... | "Caps" the construction of the pipeline, signifying that no more inputs
and outputs are expected to be added and therefore the input and output
nodes can be created along with the provenance. | [
"Caps",
"the",
"construction",
"of",
"the",
"pipeline",
"signifying",
"that",
"no",
"more",
"inputs",
"and",
"outputs",
"are",
"expected",
"to",
"be",
"added",
"and",
"therefore",
"the",
"input",
"and",
"output",
"nodes",
"can",
"be",
"created",
"along",
"wi... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L694-L710 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._make_inputnode | def _make_inputnode(self, frequency):
"""
Generates an input node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject' ... | python | def _make_inputnode(self, frequency):
"""
Generates an input node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject' ... | [
"def",
"_make_inputnode",
"(",
"self",
",",
"frequency",
")",
":",
"# Check to see whether there are any outputs for the given frequency",
"inputs",
"=",
"list",
"(",
"self",
".",
"frequency_inputs",
"(",
"frequency",
")",
")",
"# Get list of input names for the requested fre... | Generates an input node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject' or
'per_study') of the input node to retrieve | [
"Generates",
"an",
"input",
"node",
"for",
"the",
"given",
"frequency",
".",
"It",
"also",
"adds",
"implicit",
"file",
"format",
"conversion",
"nodes",
"to",
"the",
"pipeline",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L712-L781 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._make_outputnode | def _make_outputnode(self, frequency):
"""
Generates an output node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject... | python | def _make_outputnode(self, frequency):
"""
Generates an output node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject... | [
"def",
"_make_outputnode",
"(",
"self",
",",
"frequency",
")",
":",
"# Check to see whether there are any outputs for the given frequency",
"outputs",
"=",
"list",
"(",
"self",
".",
"frequency_outputs",
"(",
"frequency",
")",
")",
"if",
"not",
"outputs",
":",
"raise",... | Generates an output node for the given frequency. It also adds implicit
file format conversion nodes to the pipeline.
Parameters
----------
frequency : str
The frequency (i.e. 'per_session', 'per_visit', 'per_subject' or
'per_study') of the output node to retriev... | [
"Generates",
"an",
"output",
"node",
"for",
"the",
"given",
"frequency",
".",
"It",
"also",
"adds",
"implicit",
"file",
"format",
"conversion",
"nodes",
"to",
"the",
"pipeline",
"."
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L783-L825 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._gen_prov | def _gen_prov(self):
"""
Extracts provenance information from the pipeline into a PipelineProv
object
Returns
-------
prov : dict[str, *]
A dictionary containing the provenance information to record
for the pipeline
"""
# Export wo... | python | def _gen_prov(self):
"""
Extracts provenance information from the pipeline into a PipelineProv
object
Returns
-------
prov : dict[str, *]
A dictionary containing the provenance information to record
for the pipeline
"""
# Export wo... | [
"def",
"_gen_prov",
"(",
"self",
")",
":",
"# Export worfklow graph to node-link data format",
"wf_dict",
"=",
"nx_json",
".",
"node_link_data",
"(",
"self",
".",
"workflow",
".",
"_graph",
")",
"# Replace references to Node objects with the node's provenance",
"# information... | Extracts provenance information from the pipeline into a PipelineProv
object
Returns
-------
prov : dict[str, *]
A dictionary containing the provenance information to record
for the pipeline | [
"Extracts",
"provenance",
"information",
"from",
"the",
"pipeline",
"into",
"a",
"PipelineProv",
"object"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L827-L871 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline.expected_record | def expected_record(self, node):
"""
Constructs the provenance record that would be saved in the given node
if the pipeline was run on the current state of the repository
Parameters
----------
node : arcana.repository.tree.TreeNode
A node of the Tree represen... | python | def expected_record(self, node):
"""
Constructs the provenance record that would be saved in the given node
if the pipeline was run on the current state of the repository
Parameters
----------
node : arcana.repository.tree.TreeNode
A node of the Tree represen... | [
"def",
"expected_record",
"(",
"self",
",",
"node",
")",
":",
"exp_inputs",
"=",
"{",
"}",
"# Get checksums/values of all inputs that would have been used in",
"# previous runs of an equivalent pipeline to compare with that saved",
"# in provenance to see if any have been updated.",
"f... | Constructs the provenance record that would be saved in the given node
if the pipeline was run on the current state of the repository
Parameters
----------
node : arcana.repository.tree.TreeNode
A node of the Tree representation of the study data stored in the
re... | [
"Constructs",
"the",
"provenance",
"record",
"that",
"would",
"be",
"saved",
"in",
"the",
"given",
"node",
"if",
"the",
"pipeline",
"was",
"run",
"on",
"the",
"current",
"state",
"of",
"the",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L873-L935 |
MonashBI/arcana | arcana/pipeline/base.py | Pipeline._joined_ids | def _joined_ids(self):
"""
Adds the subjects/visits used to generate the derivatives iff there are
any joins over them in the pipeline
"""
joined_prov = {}
if self.joins_subjects:
joined_prov['subject_ids'] = list(self.study.subject_ids)
if self.joins_... | python | def _joined_ids(self):
"""
Adds the subjects/visits used to generate the derivatives iff there are
any joins over them in the pipeline
"""
joined_prov = {}
if self.joins_subjects:
joined_prov['subject_ids'] = list(self.study.subject_ids)
if self.joins_... | [
"def",
"_joined_ids",
"(",
"self",
")",
":",
"joined_prov",
"=",
"{",
"}",
"if",
"self",
".",
"joins_subjects",
":",
"joined_prov",
"[",
"'subject_ids'",
"]",
"=",
"list",
"(",
"self",
".",
"study",
".",
"subject_ids",
")",
"if",
"self",
".",
"joins_visi... | Adds the subjects/visits used to generate the derivatives iff there are
any joins over them in the pipeline | [
"Adds",
"the",
"subjects",
"/",
"visits",
"used",
"to",
"generate",
"the",
"derivatives",
"iff",
"there",
"are",
"any",
"joins",
"over",
"them",
"in",
"the",
"pipeline"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L937-L947 |
MonashBI/arcana | arcana/repository/base.py | Repository.tree | def tree(self, subject_ids=None, visit_ids=None, **kwargs):
"""
Return the tree of subject and sessions information within a
project in the XNAT repository
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. I... | python | def tree(self, subject_ids=None, visit_ids=None, **kwargs):
"""
Return the tree of subject and sessions information within a
project in the XNAT repository
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. I... | [
"def",
"tree",
"(",
"self",
",",
"subject_ids",
"=",
"None",
",",
"visit_ids",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Find all data present in the repository (filtered by the passed IDs)",
"return",
"Tree",
".",
"construct",
"(",
"self",
",",
"*",
"s... | Return the tree of subject and sessions information within a
project in the XNAT repository
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. If
None all are returned
visit_ids : list(str)
Li... | [
"Return",
"the",
"tree",
"of",
"subject",
"and",
"sessions",
"information",
"within",
"a",
"project",
"in",
"the",
"XNAT",
"repository"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/base.py#L167-L190 |
MonashBI/arcana | arcana/repository/base.py | Repository.cached_tree | def cached_tree(self, subject_ids=None, visit_ids=None, fill=False):
"""
Access the repository tree and caches it for subsequent
accesses
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. If
None... | python | def cached_tree(self, subject_ids=None, visit_ids=None, fill=False):
"""
Access the repository tree and caches it for subsequent
accesses
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. If
None... | [
"def",
"cached_tree",
"(",
"self",
",",
"subject_ids",
"=",
"None",
",",
"visit_ids",
"=",
"None",
",",
"fill",
"=",
"False",
")",
":",
"if",
"subject_ids",
"is",
"not",
"None",
":",
"subject_ids",
"=",
"frozenset",
"(",
"subject_ids",
")",
"if",
"visit_... | Access the repository tree and caches it for subsequent
accesses
Parameters
----------
subject_ids : list(str)
List of subject IDs with which to filter the tree with. If
None all are returned
visit_ids : list(str)
List of visit IDs with which ... | [
"Access",
"the",
"repository",
"tree",
"and",
"caches",
"it",
"for",
"subsequent",
"accesses"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/repository/base.py#L192-L236 |
MonashBI/arcana | arcana/data/file_format.py | FileFormat.resource_names | def resource_names(self, repo_type):
"""
Names of resources used to store the format on a given repository type.
Defaults to the name of the name of the format
"""
try:
names = self._resource_names[repo_type]
except KeyError:
names = [self.name, se... | python | def resource_names(self, repo_type):
"""
Names of resources used to store the format on a given repository type.
Defaults to the name of the name of the format
"""
try:
names = self._resource_names[repo_type]
except KeyError:
names = [self.name, se... | [
"def",
"resource_names",
"(",
"self",
",",
"repo_type",
")",
":",
"try",
":",
"names",
"=",
"self",
".",
"_resource_names",
"[",
"repo_type",
"]",
"except",
"KeyError",
":",
"names",
"=",
"[",
"self",
".",
"name",
",",
"self",
".",
"name",
".",
"upper"... | Names of resources used to store the format on a given repository type.
Defaults to the name of the name of the format | [
"Names",
"of",
"resources",
"used",
"to",
"store",
"the",
"format",
"on",
"a",
"given",
"repository",
"type",
".",
"Defaults",
"to",
"the",
"name",
"of",
"the",
"name",
"of",
"the",
"format"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L150-L159 |
MonashBI/arcana | arcana/data/file_format.py | FileFormat.default_aux_file_paths | def default_aux_file_paths(self, primary_path):
"""
Get the default paths for auxiliary files relative to the path of the
primary file, i.e. the same name as the primary path with a different
extension
Parameters
----------
primary_path : str
Path to ... | python | def default_aux_file_paths(self, primary_path):
"""
Get the default paths for auxiliary files relative to the path of the
primary file, i.e. the same name as the primary path with a different
extension
Parameters
----------
primary_path : str
Path to ... | [
"def",
"default_aux_file_paths",
"(",
"self",
",",
"primary_path",
")",
":",
"return",
"dict",
"(",
"(",
"n",
",",
"primary_path",
"[",
":",
"-",
"len",
"(",
"self",
".",
"ext",
")",
"]",
"+",
"ext",
")",
"for",
"n",
",",
"ext",
"in",
"self",
".",
... | Get the default paths for auxiliary files relative to the path of the
primary file, i.e. the same name as the primary path with a different
extension
Parameters
----------
primary_path : str
Path to the primary file in the fileset
Returns
-------
... | [
"Get",
"the",
"default",
"paths",
"for",
"auxiliary",
"files",
"relative",
"to",
"the",
"path",
"of",
"the",
"primary",
"file",
"i",
".",
"e",
".",
"the",
"same",
"name",
"as",
"the",
"primary",
"path",
"with",
"a",
"different",
"extension"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L161-L178 |
MonashBI/arcana | arcana/data/file_format.py | FileFormat.assort_files | def assort_files(self, candidates):
"""
Assorts candidate files into primary and auxiliary (and ignored) files
corresponding to the format by their file extensions. Can be overridden
in specialised subclasses to assort files based on other
characteristics
Parameters
... | python | def assort_files(self, candidates):
"""
Assorts candidate files into primary and auxiliary (and ignored) files
corresponding to the format by their file extensions. Can be overridden
in specialised subclasses to assort files based on other
characteristics
Parameters
... | [
"def",
"assort_files",
"(",
"self",
",",
"candidates",
")",
":",
"by_ext",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"path",
"in",
"candidates",
":",
"by_ext",
"[",
"split_extension",
"(",
"path",
")",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"]",
"... | Assorts candidate files into primary and auxiliary (and ignored) files
corresponding to the format by their file extensions. Can be overridden
in specialised subclasses to assort files based on other
characteristics
Parameters
----------
candidates : list[str]
... | [
"Assorts",
"candidate",
"files",
"into",
"primary",
"and",
"auxiliary",
"(",
"and",
"ignored",
")",
"files",
"corresponding",
"to",
"the",
"format",
"by",
"their",
"file",
"extensions",
".",
"Can",
"be",
"overridden",
"in",
"specialised",
"subclasses",
"to",
"... | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L214-L267 |
MonashBI/arcana | arcana/data/file_format.py | FileFormat.matches | def matches(self, fileset):
"""
Checks to see whether the format matches the given fileset
Parameters
----------
fileset : Fileset
The fileset to check
"""
if fileset._resource_name is not None:
return (fileset._resource_name in self.resou... | python | def matches(self, fileset):
"""
Checks to see whether the format matches the given fileset
Parameters
----------
fileset : Fileset
The fileset to check
"""
if fileset._resource_name is not None:
return (fileset._resource_name in self.resou... | [
"def",
"matches",
"(",
"self",
",",
"fileset",
")",
":",
"if",
"fileset",
".",
"_resource_name",
"is",
"not",
"None",
":",
"return",
"(",
"fileset",
".",
"_resource_name",
"in",
"self",
".",
"resource_names",
"(",
"fileset",
".",
"repository",
".",
"type",... | Checks to see whether the format matches the given fileset
Parameters
----------
fileset : Fileset
The fileset to check | [
"Checks",
"to",
"see",
"whether",
"the",
"format",
"matches",
"the",
"given",
"fileset"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L269-L302 |
MonashBI/arcana | arcana/data/file_format.py | FileFormat.set_converter | def set_converter(self, file_format, converter):
"""
Register a Converter and the FileFormat that it is able to convert from
Parameters
----------
converter : Converter
The converter to register
file_format : FileFormat
The file format that can be... | python | def set_converter(self, file_format, converter):
"""
Register a Converter and the FileFormat that it is able to convert from
Parameters
----------
converter : Converter
The converter to register
file_format : FileFormat
The file format that can be... | [
"def",
"set_converter",
"(",
"self",
",",
"file_format",
",",
"converter",
")",
":",
"self",
".",
"_converters",
"[",
"file_format",
".",
"name",
"]",
"=",
"(",
"file_format",
",",
"converter",
")"
] | Register a Converter and the FileFormat that it is able to convert from
Parameters
----------
converter : Converter
The converter to register
file_format : FileFormat
The file format that can be converted into this format | [
"Register",
"a",
"Converter",
"and",
"the",
"FileFormat",
"that",
"it",
"is",
"able",
"to",
"convert",
"from"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/data/file_format.py#L304-L315 |
gwww/elkm1 | elkm1_lib/util.py | parse_url | def parse_url(url):
"""Parse a Elk connection string """
scheme, dest = url.split('://')
host = None
ssl_context = None
if scheme == 'elk':
host, port = dest.split(':') if ':' in dest else (dest, 2101)
elif scheme == 'elks':
host, port = dest.split(':') if ':' in dest else (dest,... | python | def parse_url(url):
"""Parse a Elk connection string """
scheme, dest = url.split('://')
host = None
ssl_context = None
if scheme == 'elk':
host, port = dest.split(':') if ':' in dest else (dest, 2101)
elif scheme == 'elks':
host, port = dest.split(':') if ':' in dest else (dest,... | [
"def",
"parse_url",
"(",
"url",
")",
":",
"scheme",
",",
"dest",
"=",
"url",
".",
"split",
"(",
"'://'",
")",
"host",
"=",
"None",
"ssl_context",
"=",
"None",
"if",
"scheme",
"==",
"'elk'",
":",
"host",
",",
"port",
"=",
"dest",
".",
"split",
"(",
... | Parse a Elk connection string | [
"Parse",
"a",
"Elk",
"connection",
"string"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/util.py#L14-L29 |
gwww/elkm1 | elkm1_lib/util.py | pretty_const | def pretty_const(value):
"""Make a constant pretty for printing in GUI"""
words = value.split('_')
pretty = words[0].capitalize()
for word in words[1:]:
pretty += ' ' + word.lower()
return pretty | python | def pretty_const(value):
"""Make a constant pretty for printing in GUI"""
words = value.split('_')
pretty = words[0].capitalize()
for word in words[1:]:
pretty += ' ' + word.lower()
return pretty | [
"def",
"pretty_const",
"(",
"value",
")",
":",
"words",
"=",
"value",
".",
"split",
"(",
"'_'",
")",
"pretty",
"=",
"words",
"[",
"0",
"]",
".",
"capitalize",
"(",
")",
"for",
"word",
"in",
"words",
"[",
"1",
":",
"]",
":",
"pretty",
"+=",
"' '",... | Make a constant pretty for printing in GUI | [
"Make",
"a",
"constant",
"pretty",
"for",
"printing",
"in",
"GUI"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/util.py#L32-L38 |
gwww/elkm1 | elkm1_lib/util.py | username | def username(elk, user_number):
"""Return name of user."""
if user_number >= 0 and user_number < elk.users.max_elements:
return elk.users[user_number].name
if user_number == 201:
return "*Program*"
if user_number == 202:
return "*Elk RP*"
if user_number == 203:
return... | python | def username(elk, user_number):
"""Return name of user."""
if user_number >= 0 and user_number < elk.users.max_elements:
return elk.users[user_number].name
if user_number == 201:
return "*Program*"
if user_number == 202:
return "*Elk RP*"
if user_number == 203:
return... | [
"def",
"username",
"(",
"elk",
",",
"user_number",
")",
":",
"if",
"user_number",
">=",
"0",
"and",
"user_number",
"<",
"elk",
".",
"users",
".",
"max_elements",
":",
"return",
"elk",
".",
"users",
"[",
"user_number",
"]",
".",
"name",
"if",
"user_number... | Return name of user. | [
"Return",
"name",
"of",
"user",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/util.py#L40-L50 |
gwww/elkm1 | elkm1_lib/elk.py | Elk._connect | async def _connect(self, connection_lost_callbk=None):
"""Asyncio connection to Elk."""
self.connection_lost_callbk = connection_lost_callbk
url = self._config['url']
LOG.info("Connecting to ElkM1 at %s", url)
scheme, dest, param, ssl_context = parse_url(url)
conn = parti... | python | async def _connect(self, connection_lost_callbk=None):
"""Asyncio connection to Elk."""
self.connection_lost_callbk = connection_lost_callbk
url = self._config['url']
LOG.info("Connecting to ElkM1 at %s", url)
scheme, dest, param, ssl_context = parse_url(url)
conn = parti... | [
"async",
"def",
"_connect",
"(",
"self",
",",
"connection_lost_callbk",
"=",
"None",
")",
":",
"self",
".",
"connection_lost_callbk",
"=",
"connection_lost_callbk",
"url",
"=",
"self",
".",
"_config",
"[",
"'url'",
"]",
"LOG",
".",
"info",
"(",
"\"Connecting t... | Asyncio connection to Elk. | [
"Asyncio",
"connection",
"to",
"Elk",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elk.py#L50-L70 |
gwww/elkm1 | elkm1_lib/elk.py | Elk._connected | def _connected(self, transport, conn):
"""Login and sync the ElkM1 panel to memory."""
LOG.info("Connected to ElkM1")
self._conn = conn
self._transport = transport
self._connection_retry_timer = 1
if url_scheme_is_secure(self._config['url']):
self._conn.write_... | python | def _connected(self, transport, conn):
"""Login and sync the ElkM1 panel to memory."""
LOG.info("Connected to ElkM1")
self._conn = conn
self._transport = transport
self._connection_retry_timer = 1
if url_scheme_is_secure(self._config['url']):
self._conn.write_... | [
"def",
"_connected",
"(",
"self",
",",
"transport",
",",
"conn",
")",
":",
"LOG",
".",
"info",
"(",
"\"Connected to ElkM1\"",
")",
"self",
".",
"_conn",
"=",
"conn",
"self",
".",
"_transport",
"=",
"transport",
"self",
".",
"_connection_retry_timer",
"=",
... | Login and sync the ElkM1 panel to memory. | [
"Login",
"and",
"sync",
"the",
"ElkM1",
"panel",
"to",
"memory",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elk.py#L72-L83 |
gwww/elkm1 | elkm1_lib/elk.py | Elk._sd_handler | def _sd_handler(self, desc_type, unit, desc, show_on_keypad):
"""Text description"""
if desc_type not in self._descriptions_in_progress:
LOG.debug("Text description response ignored for " + str(desc_type))
return
(max_units, results, callback) = self._descriptions_in_pro... | python | def _sd_handler(self, desc_type, unit, desc, show_on_keypad):
"""Text description"""
if desc_type not in self._descriptions_in_progress:
LOG.debug("Text description response ignored for " + str(desc_type))
return
(max_units, results, callback) = self._descriptions_in_pro... | [
"def",
"_sd_handler",
"(",
"self",
",",
"desc_type",
",",
"unit",
",",
"desc",
",",
"show_on_keypad",
")",
":",
"if",
"desc_type",
"not",
"in",
"self",
".",
"_descriptions_in_progress",
":",
"LOG",
".",
"debug",
"(",
"\"Text description response ignored for \"",
... | Text description | [
"Text",
"description"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elk.py#L129-L142 |
gwww/elkm1 | elkm1_lib/elk.py | Elk.send | def send(self, msg):
"""Send a message to Elk panel."""
if self._conn:
self._conn.write_data(msg.message, msg.response_command) | python | def send(self, msg):
"""Send a message to Elk panel."""
if self._conn:
self._conn.write_data(msg.message, msg.response_command) | [
"def",
"send",
"(",
"self",
",",
"msg",
")",
":",
"if",
"self",
".",
"_conn",
":",
"self",
".",
"_conn",
".",
"write_data",
"(",
"msg",
".",
"message",
",",
"msg",
".",
"response_command",
")"
] | Send a message to Elk panel. | [
"Send",
"a",
"message",
"to",
"Elk",
"panel",
"."
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/elk.py#L156-L159 |
gwww/elkm1 | elkm1_lib/zones.py | Zones.sync | def sync(self):
"""Retrieve zones from ElkM1"""
self.elk.send(az_encode())
self.elk.send(zd_encode())
self.elk.send(zp_encode())
self.elk.send(zs_encode())
self.get_descriptions(TextDescriptions.ZONE.value) | python | def sync(self):
"""Retrieve zones from ElkM1"""
self.elk.send(az_encode())
self.elk.send(zd_encode())
self.elk.send(zp_encode())
self.elk.send(zs_encode())
self.get_descriptions(TextDescriptions.ZONE.value) | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"elk",
".",
"send",
"(",
"az_encode",
"(",
")",
")",
"self",
".",
"elk",
".",
"send",
"(",
"zd_encode",
"(",
")",
")",
"self",
".",
"elk",
".",
"send",
"(",
"zp_encode",
"(",
")",
")",
"self",
... | Retrieve zones from ElkM1 | [
"Retrieve",
"zones",
"from",
"ElkM1"
] | train | https://github.com/gwww/elkm1/blob/078d0de30840c3fab46f1f8534d98df557931e91/elkm1_lib/zones.py#L50-L56 |
erikvw/django-collect-offline | django_collect_offline/offline_model.py | OfflineModel.has_offline_historical_manager_or_raise | def has_offline_historical_manager_or_raise(self):
"""Raises an exception if model uses a history manager and
historical model history_id is not a UUIDField.
Note: expected to use edc_model.HistoricalRecords instead of
simple_history.HistoricalRecords.
"""
try:
... | python | def has_offline_historical_manager_or_raise(self):
"""Raises an exception if model uses a history manager and
historical model history_id is not a UUIDField.
Note: expected to use edc_model.HistoricalRecords instead of
simple_history.HistoricalRecords.
"""
try:
... | [
"def",
"has_offline_historical_manager_or_raise",
"(",
"self",
")",
":",
"try",
":",
"model",
"=",
"self",
".",
"instance",
".",
"__class__",
".",
"history",
".",
"model",
"except",
"AttributeError",
":",
"model",
"=",
"self",
".",
"instance",
".",
"__class__"... | Raises an exception if model uses a history manager and
historical model history_id is not a UUIDField.
Note: expected to use edc_model.HistoricalRecords instead of
simple_history.HistoricalRecords. | [
"Raises",
"an",
"exception",
"if",
"model",
"uses",
"a",
"history",
"manager",
"and",
"historical",
"model",
"history_id",
"is",
"not",
"a",
"UUIDField",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/offline_model.py#L71-L91 |
erikvw/django-collect-offline | django_collect_offline/offline_model.py | OfflineModel.primary_key_field | def primary_key_field(self):
"""Return the primary key field.
Is `id` in most cases. Is `history_id` for Historical models.
"""
return [field for field in self.instance._meta.fields if field.primary_key][0] | python | def primary_key_field(self):
"""Return the primary key field.
Is `id` in most cases. Is `history_id` for Historical models.
"""
return [field for field in self.instance._meta.fields if field.primary_key][0] | [
"def",
"primary_key_field",
"(",
"self",
")",
":",
"return",
"[",
"field",
"for",
"field",
"in",
"self",
".",
"instance",
".",
"_meta",
".",
"fields",
"if",
"field",
".",
"primary_key",
"]",
"[",
"0",
"]"
] | Return the primary key field.
Is `id` in most cases. Is `history_id` for Historical models. | [
"Return",
"the",
"primary",
"key",
"field",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/offline_model.py#L103-L108 |
erikvw/django-collect-offline | django_collect_offline/offline_model.py | OfflineModel.to_outgoing_transaction | def to_outgoing_transaction(self, using, created=None, deleted=None):
""" Serialize the model instance to an AES encrypted json object
and saves the json object to the OutgoingTransaction model.
"""
OutgoingTransaction = django_apps.get_model(
"django_collect_offline", "Outgo... | python | def to_outgoing_transaction(self, using, created=None, deleted=None):
""" Serialize the model instance to an AES encrypted json object
and saves the json object to the OutgoingTransaction model.
"""
OutgoingTransaction = django_apps.get_model(
"django_collect_offline", "Outgo... | [
"def",
"to_outgoing_transaction",
"(",
"self",
",",
"using",
",",
"created",
"=",
"None",
",",
"deleted",
"=",
"None",
")",
":",
"OutgoingTransaction",
"=",
"django_apps",
".",
"get_model",
"(",
"\"django_collect_offline\"",
",",
"\"OutgoingTransaction\"",
")",
"c... | Serialize the model instance to an AES encrypted json object
and saves the json object to the OutgoingTransaction model. | [
"Serialize",
"the",
"model",
"instance",
"to",
"an",
"AES",
"encrypted",
"json",
"object",
"and",
"saves",
"the",
"json",
"object",
"to",
"the",
"OutgoingTransaction",
"model",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/offline_model.py#L110-L139 |
erikvw/django-collect-offline | django_collect_offline/offline_model.py | OfflineModel.encrypted_json | def encrypted_json(self):
"""Returns an encrypted json serialized from self.
"""
json = serialize(objects=[self.instance])
encrypted_json = Cryptor().aes_encrypt(json, LOCAL_MODE)
return encrypted_json | python | def encrypted_json(self):
"""Returns an encrypted json serialized from self.
"""
json = serialize(objects=[self.instance])
encrypted_json = Cryptor().aes_encrypt(json, LOCAL_MODE)
return encrypted_json | [
"def",
"encrypted_json",
"(",
"self",
")",
":",
"json",
"=",
"serialize",
"(",
"objects",
"=",
"[",
"self",
".",
"instance",
"]",
")",
"encrypted_json",
"=",
"Cryptor",
"(",
")",
".",
"aes_encrypt",
"(",
"json",
",",
"LOCAL_MODE",
")",
"return",
"encrypt... | Returns an encrypted json serialized from self. | [
"Returns",
"an",
"encrypted",
"json",
"serialized",
"from",
"self",
"."
] | train | https://github.com/erikvw/django-collect-offline/blob/3d5efd66c68e2db4b060a82b070ae490dc399ca7/django_collect_offline/offline_model.py#L141-L146 |
MonashBI/arcana | arcana/environment/modules.py | ModulesEnv.map_req | def map_req(self, requirement):
"""
Maps the name of an Requirement class to the name of the corresponding
module in the environment
Parameters
----------
requirement : Requirement
The requirement to map to the name of a module on the system
"""
... | python | def map_req(self, requirement):
"""
Maps the name of an Requirement class to the name of the corresponding
module in the environment
Parameters
----------
requirement : Requirement
The requirement to map to the name of a module on the system
"""
... | [
"def",
"map_req",
"(",
"self",
",",
"requirement",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_packages_map",
",",
"dict",
")",
":",
"local_name",
"=",
"self",
".",
"_packages_map",
".",
"get",
"(",
"requirement",
",",
"requirement",
".",
"name",
"... | Maps the name of an Requirement class to the name of the corresponding
module in the environment
Parameters
----------
requirement : Requirement
The requirement to map to the name of a module on the system | [
"Maps",
"the",
"name",
"of",
"an",
"Requirement",
"class",
"to",
"the",
"name",
"of",
"the",
"corresponding",
"module",
"in",
"the",
"environment"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/modules.py#L169-L183 |
MonashBI/arcana | arcana/environment/modules.py | ModulesEnv.map_version | def map_version(self, requirement, local_version):
"""
Maps a local version name to one recognised by the Requirement class
Parameters
----------
requirement : str
Name of the requirement
version : str
version string
"""
if isinsta... | python | def map_version(self, requirement, local_version):
"""
Maps a local version name to one recognised by the Requirement class
Parameters
----------
requirement : str
Name of the requirement
version : str
version string
"""
if isinsta... | [
"def",
"map_version",
"(",
"self",
",",
"requirement",
",",
"local_version",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_versions_map",
",",
"dict",
")",
":",
"version",
"=",
"self",
".",
"_versions_map",
".",
"get",
"(",
"requirement",
",",
"{",
"... | Maps a local version name to one recognised by the Requirement class
Parameters
----------
requirement : str
Name of the requirement
version : str
version string | [
"Maps",
"a",
"local",
"version",
"name",
"to",
"one",
"recognised",
"by",
"the",
"Requirement",
"class"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/environment/modules.py#L185-L201 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytagfile.py | TagfileProcessor.init_tag_processors | def init_tag_processors(self):
'''Register the TagProcessors that are bundled with doxytag2zealdb.'''
register = self.register_tag_processor
register('class', classTagProcessor(**self.opts))
register('file', fileTagProcessor(**self.opts))
register('namespace', namespaceTagProces... | python | def init_tag_processors(self):
'''Register the TagProcessors that are bundled with doxytag2zealdb.'''
register = self.register_tag_processor
register('class', classTagProcessor(**self.opts))
register('file', fileTagProcessor(**self.opts))
register('namespace', namespaceTagProces... | [
"def",
"init_tag_processors",
"(",
"self",
")",
":",
"register",
"=",
"self",
".",
"register_tag_processor",
"register",
"(",
"'class'",
",",
"classTagProcessor",
"(",
"*",
"*",
"self",
".",
"opts",
")",
")",
"register",
"(",
"'file'",
",",
"fileTagProcessor",... | Register the TagProcessors that are bundled with doxytag2zealdb. | [
"Register",
"the",
"TagProcessors",
"that",
"are",
"bundled",
"with",
"doxytag2zealdb",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytagfile.py#L76-L90 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytagfile.py | TagfileProcessor.process | def process(self):
'''Run all tag processors.'''
for tag_proc in self.tag_procs:
before_count = self.entry_count
self.run_tag_processor(tag_proc)
after_count = self.entry_count
if self.verbose:
print('Inserted %d entries for "%s" tag proce... | python | def process(self):
'''Run all tag processors.'''
for tag_proc in self.tag_procs:
before_count = self.entry_count
self.run_tag_processor(tag_proc)
after_count = self.entry_count
if self.verbose:
print('Inserted %d entries for "%s" tag proce... | [
"def",
"process",
"(",
"self",
")",
":",
"for",
"tag_proc",
"in",
"self",
".",
"tag_procs",
":",
"before_count",
"=",
"self",
".",
"entry_count",
"self",
".",
"run_tag_processor",
"(",
"tag_proc",
")",
"after_count",
"=",
"self",
".",
"entry_count",
"if",
... | Run all tag processors. | [
"Run",
"all",
"tag",
"processors",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytagfile.py#L111-L124 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytagfile.py | TagfileProcessor.run_tag_processor | def run_tag_processor(self, tag_proc_name):
'''Run a tag processor.
Args:
tag_proc_name: A string key that maps to the TagProcessor to run.
'''
tag_processor = self.tag_procs[tag_proc_name]
for tag in tag_processor.find(self.soup):
self.process_tag(tag_p... | python | def run_tag_processor(self, tag_proc_name):
'''Run a tag processor.
Args:
tag_proc_name: A string key that maps to the TagProcessor to run.
'''
tag_processor = self.tag_procs[tag_proc_name]
for tag in tag_processor.find(self.soup):
self.process_tag(tag_p... | [
"def",
"run_tag_processor",
"(",
"self",
",",
"tag_proc_name",
")",
":",
"tag_processor",
"=",
"self",
".",
"tag_procs",
"[",
"tag_proc_name",
"]",
"for",
"tag",
"in",
"tag_processor",
".",
"find",
"(",
"self",
".",
"soup",
")",
":",
"self",
".",
"process_... | Run a tag processor.
Args:
tag_proc_name: A string key that maps to the TagProcessor to run. | [
"Run",
"a",
"tag",
"processor",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytagfile.py#L126-L135 |
vedvyas/doxytag2zealdb | doxytag2zealdb/doxytagfile.py | TagfileProcessor.process_tag | def process_tag(self, tag_proc_name, tag):
'''Process a tag with a tag processor and insert a DB entry.
Args:
tag_proc_name: A string key that maps to the TagProcessor to use.
tag: A BeautifulSoup Tag to process.
'''
tag_processor = self.tag_procs[tag_proc_name]
... | python | def process_tag(self, tag_proc_name, tag):
'''Process a tag with a tag processor and insert a DB entry.
Args:
tag_proc_name: A string key that maps to the TagProcessor to use.
tag: A BeautifulSoup Tag to process.
'''
tag_processor = self.tag_procs[tag_proc_name]
... | [
"def",
"process_tag",
"(",
"self",
",",
"tag_proc_name",
",",
"tag",
")",
":",
"tag_processor",
"=",
"self",
".",
"tag_procs",
"[",
"tag_proc_name",
"]",
"db_entry",
"=",
"(",
"tag_processor",
".",
"get_name",
"(",
"tag",
")",
",",
"tag_processor",
".",
"g... | Process a tag with a tag processor and insert a DB entry.
Args:
tag_proc_name: A string key that maps to the TagProcessor to use.
tag: A BeautifulSoup Tag to process. | [
"Process",
"a",
"tag",
"with",
"a",
"tag",
"processor",
"and",
"insert",
"a",
"DB",
"entry",
"."
] | train | https://github.com/vedvyas/doxytag2zealdb/blob/8b07a88af6794248f8cfdabb0fda9dd61c777127/doxytag2zealdb/doxytagfile.py#L137-L152 |
brentp/toolshed | toolshed/__init__.py | groupby | def groupby(iterable, key=0, filter=None):
"""
wrapper to itertools.groupby that returns a list of each group, rather
than a generator and accepts integers or strings as the key and
automatically converts them to callables with itemgetter(key)
Arguments:
iterable: iterable
key: stri... | python | def groupby(iterable, key=0, filter=None):
"""
wrapper to itertools.groupby that returns a list of each group, rather
than a generator and accepts integers or strings as the key and
automatically converts them to callables with itemgetter(key)
Arguments:
iterable: iterable
key: stri... | [
"def",
"groupby",
"(",
"iterable",
",",
"key",
"=",
"0",
",",
"filter",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"(",
"basestring",
",",
"int",
")",
")",
":",
"key",
"=",
"itemgetter",
"(",
"key",
")",
"elif",
"isinstance",
"(",
... | wrapper to itertools.groupby that returns a list of each group, rather
than a generator and accepts integers or strings as the key and
automatically converts them to callables with itemgetter(key)
Arguments:
iterable: iterable
key: string, int or callable that tells how to group
Return... | [
"wrapper",
"to",
"itertools",
".",
"groupby",
"that",
"returns",
"a",
"list",
"of",
"each",
"group",
"rather",
"than",
"a",
"generator",
"and",
"accepts",
"integers",
"or",
"strings",
"as",
"the",
"key",
"and",
"automatically",
"converts",
"them",
"to",
"cal... | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/__init__.py#L14-L35 |
brentp/toolshed | toolshed/__init__.py | groups_of | def groups_of(n, iterable):
"""
>>> groups_of(2, range(5))
"""
args = [iter(iterable)] * n
for x in izip_longest(*args):
yield [v for v in x if v is not None] | python | def groups_of(n, iterable):
"""
>>> groups_of(2, range(5))
"""
args = [iter(iterable)] * n
for x in izip_longest(*args):
yield [v for v in x if v is not None] | [
"def",
"groups_of",
"(",
"n",
",",
"iterable",
")",
":",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"n",
"for",
"x",
"in",
"izip_longest",
"(",
"*",
"args",
")",
":",
"yield",
"[",
"v",
"for",
"v",
"in",
"x",
"if",
"v",
"is",
"... | >>> groups_of(2, range(5)) | [
">>>",
"groups_of",
"(",
"2",
"range",
"(",
"5",
"))"
] | train | https://github.com/brentp/toolshed/blob/c9529d6872bf28207642896c3b416f68e79b1269/toolshed/__init__.py#L42-L48 |
MonashBI/arcana | arcana/processor/base.py | Processor.run | def run(self, *pipelines, **kwargs):
"""
Connects all pipelines to that study's repository and runs them
in the same NiPype workflow
Parameters
----------
pipeline(s) : Pipeline, ...
The pipeline to connect to repository
required_outputs : list[set[st... | python | def run(self, *pipelines, **kwargs):
"""
Connects all pipelines to that study's repository and runs them
in the same NiPype workflow
Parameters
----------
pipeline(s) : Pipeline, ...
The pipeline to connect to repository
required_outputs : list[set[st... | [
"def",
"run",
"(",
"self",
",",
"*",
"pipelines",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"pipelines",
":",
"raise",
"ArcanaUsageError",
"(",
"\"No pipelines provided to {}.run\"",
".",
"format",
"(",
"self",
")",
")",
"# Get filter kwargs (NB: in Pytho... | Connects all pipelines to that study's repository and runs them
in the same NiPype workflow
Parameters
----------
pipeline(s) : Pipeline, ...
The pipeline to connect to repository
required_outputs : list[set[str]]
A set of required outputs for each pipeli... | [
"Connects",
"all",
"pipelines",
"to",
"that",
"study",
"s",
"repository",
"and",
"runs",
"them",
"in",
"the",
"same",
"NiPype",
"workflow"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L147-L328 |
MonashBI/arcana | arcana/processor/base.py | Processor._connect_pipeline | def _connect_pipeline(self, pipeline, required_outputs, workflow,
subject_inds, visit_inds, filter_array, force=False):
"""
Connects a pipeline to a overarching workflow that sets up iterators
over subjects|visits present in the repository (if required) and
repo... | python | def _connect_pipeline(self, pipeline, required_outputs, workflow,
subject_inds, visit_inds, filter_array, force=False):
"""
Connects a pipeline to a overarching workflow that sets up iterators
over subjects|visits present in the repository (if required) and
repo... | [
"def",
"_connect_pipeline",
"(",
"self",
",",
"pipeline",
",",
"required_outputs",
",",
"workflow",
",",
"subject_inds",
",",
"visit_inds",
",",
"filter_array",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"reprocess",
"==",
"'force'",
":",
"forc... | Connects a pipeline to a overarching workflow that sets up iterators
over subjects|visits present in the repository (if required) and
repository source and sink nodes
Parameters
----------
pipeline : Pipeline
The pipeline to connect
required_outputs : set[str... | [
"Connects",
"a",
"pipeline",
"to",
"a",
"overarching",
"workflow",
"that",
"sets",
"up",
"iterators",
"over",
"subjects|visits",
"present",
"in",
"the",
"repository",
"(",
"if",
"required",
")",
"and",
"repository",
"source",
"and",
"sink",
"nodes"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L330-L536 |
MonashBI/arcana | arcana/processor/base.py | Processor._iterate | def _iterate(self, pipeline, to_process_array, subject_inds, visit_inds):
"""
Generate nodes that iterate over subjects and visits in the study that
need to be processed by the pipeline
Parameters
----------
pipeline : Pipeline
The pipeline to add iter_nodes ... | python | def _iterate(self, pipeline, to_process_array, subject_inds, visit_inds):
"""
Generate nodes that iterate over subjects and visits in the study that
need to be processed by the pipeline
Parameters
----------
pipeline : Pipeline
The pipeline to add iter_nodes ... | [
"def",
"_iterate",
"(",
"self",
",",
"pipeline",
",",
"to_process_array",
",",
"subject_inds",
",",
"visit_inds",
")",
":",
"# Check to see whether the subject/visit IDs to process (as specified",
"# by the 'to_process' array) can be factorized into indepdent nodes,",
"# i.e. all sub... | Generate nodes that iterate over subjects and visits in the study that
need to be processed by the pipeline
Parameters
----------
pipeline : Pipeline
The pipeline to add iter_nodes for
to_process_array : 2-D numpy.array[bool]
A two-dimensional boolean arr... | [
"Generate",
"nodes",
"that",
"iterate",
"over",
"subjects",
"and",
"visits",
"in",
"the",
"study",
"that",
"need",
"to",
"be",
"processed",
"by",
"the",
"pipeline"
] | train | https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L538-L658 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.