project_name
string | class_name
string | class_modifiers
string | class_implements
int64 | class_extends
int64 | function_name
string | function_body
string | cyclomatic_complexity
int64 | NLOC
int64 | num_parameter
int64 | num_token
int64 | num_variable
int64 | start_line
int64 | end_line
int64 | function_index
int64 | function_params
string | function_variable
string | function_return_type
string | function_body_line_type
string | function_num_functions
int64 | function_num_lines
int64 | outgoing_function_count
int64 | outgoing_function_names
string | incoming_function_count
int64 | incoming_function_names
string | lexical_representation
string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
process
|
def process(self, tup):word = tup.values[0]self._increment(word, 10 if word == "dog" else 1)if self.total % 1000 == 0:self.logger.info("counted %i words", self.total)self.emit([word, self.counter[word]])
| 3
| 6
| 2
| 65
| 0
| 19
| 24
| 19
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (process) defined within the public class called public.The function start at line 19 and ends at 24. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [19.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
initialize
|
def initialize(self, conf, ctx):self.counter = Counter()self.total = 0
| 1
| 3
| 3
| 21
| 0
| 30
| 32
| 11
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (initialize) defined within the public class called public.The function start at line 30 and ends at 32. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [11.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_increment
|
def _increment(self, word, inc_by):self.total += inc_byreturn self.redis.zincrby("words", word, inc_by)
| 1
| 3
| 3
| 27
| 0
| 34
| 36
| 34
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_increment) defined within the public class called public.The function start at line 34 and ends at 36. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [34.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
process
|
def process(self, tup):word = tup.values[0]count = self._increment(word, 10 if word == "dog" else 1)if self.total % 1000 == 0:self.logger.info("counted %i words", self.total)self.emit([word, count])
| 3
| 6
| 2
| 62
| 0
| 38
| 43
| 38
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (process) defined within the public class called public.The function start at line 38 and ends at 43. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [38.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
initialize
|
def initialize(self, stormconf, context):self.words = cycle(["dog", "cat", "zebra", "elephant"])
| 1
| 2
| 3
| 25
| 0
| 9
| 10
| 9
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (initialize) defined within the public class called public.The function start at line 9 and ends at 10. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [9.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
next_tuple
|
def next_tuple(self):word = next(self.words)self.emit([word])
| 1
| 3
| 1
| 21
| 0
| 12
| 14
| 12
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (next_tuple) defined within the public class called public.The function start at line 12 and ends at 14. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
pidmonitor
|
def pidmonitor():processes = ["redis-server", "streamparse.run", "java"]for pid in psutil.pids():proc = psutil.Process(pid)for process in processes:if process in proc.cmdline():cmdline = proc.cmdline()main_proc = cmdline[0]details = []if main_proc == "java":details.append("[storm]")elif main_proc == "python":details.extend(cmdline[2:4])for detail in details:if "Spout" in detail:details.append("[spout]")if "Bolt" in detail:details.append("[bolt]")elif main_proc == "redis-server":details.append("[redis]")print(main_proc, " ".join(details))print(f"=> CPU% {proc.cpu_percent(interval=0.2)}")
| 10
| 22
| 0
| 142
| 5
| 4
| 25
| 4
| null |
['proc', 'details', 'main_proc', 'cmdline', 'processes']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (pidmonitor) defined within the public class called public.The function start at line 4 and ends at 25. It contains 22 lines of code and it has a cyclomatic complexity of 10. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main():"""main entry point for Python bolts and spouts"""parser = argparse.ArgumentParser(description="Run a bolt/spout class",epilog="This is internal to streamparse ""and is used to run spout and bolt ""classes via ``python -m ""streamparse.run <class name>``.",)parser.add_argument("target_class", help="The bolt/spout class to start.")parser.add_argument("-s","--serializer",help="The serialization protocol to use to talk to " "Storm.",choices=_SERIALIZERS.keys(),default="json",)# Storm sends everything as one string, which is not greatif len(sys.argv) == 2:sys.argv = [sys.argv[0]] + sys.argv[1].split()args = parser.parse_args()mod_name, cls_name = args.target_class.rsplit(".", 1)# Add current directory to sys.path so imports will workimport_path = os.getcwd()# Storm <= 1.0.2if RESOURCES_PATH in next(os.walk(import_path))[1] and os.path.isfile(os.path.join(import_path, RESOURCES_PATH, mod_name.replace(".", os.path.sep) + ".py")):import_path = os.path.join(import_path, RESOURCES_PATH)# Storm >= 1.0.3sys.path.append(import_path)# Import modulemod = importlib.import_module(mod_name)# Get class from module and run itcls = getattr(mod, cls_name)cls(serializer=args.serializer).run()
| 4
| 31
| 0
| 217
| 5
| 15
| 50
| 15
| null |
['parser', 'args', 'mod', 'cls', 'import_path']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 15 and ends at 50. It contains 31 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_port_in_use
|
def _port_in_use(port, server_type="tcp"):"""Check to see whether a given port is already in use on localhost."""if server_type == "tcp":server = TCPServerelif server_type == "udp":server = UDPServerelse:raise ValueError("Server type can only be: udp or tcp.")try:server(("localhost", port), None)except SocketError:return Truereturn False
| 4
| 12
| 2
| 52
| 1
| 30
| 44
| 30
| null |
['server']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_port_in_use) defined within the public class called public.The function start at line 30 and ends at 44. It contains 12 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [30.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
ssh_tunnel
|
def ssh_tunnel(env_config, local_port=6627, remote_port=None, quiet=False):"""Setup an optional ssh_tunnel to Nimbus.If use_ssh_for_nimbus is False, no tunnel will be created."""host, nimbus_port = get_nimbus_host_port(env_config)if remote_port is None:remote_port = nimbus_portif is_ssh_for_nimbus(env_config):need_setup = Truewhile _port_in_use(local_port):if local_port in _active_tunnels:active_remote_port = _active_tunnels[local_port]if active_remote_port == remote_port:need_setup = Falsebreaklocal_port += 1if need_setup:user = env_config.get("user")port = env_config.get("ssh_port")if user:user_at_host = f"{user}@{host}"else:user_at_host = host# Rely on SSH default or config to connect.ssh_cmd = ["ssh","-NL",f"{local_port}:localhost:{remote_port}",user_at_host,]# Specify port if in configif port:ssh_cmd.insert(-1, "-p")ssh_cmd.insert(-1, str(port))ssh_proc = subprocess.Popen(ssh_cmd, shell=False)# Validate that the tunnel is actually running before yieldingwhile not _port_in_use(local_port):# Periodically check to see if the ssh command failed and returned a# value, then raise an Exceptionif ssh_proc.poll() is not None:raise OSError(f"Unable to open ssh tunnel via: \"{' '.join(ssh_cmd)}\"")time.sleep(0.2)if not quiet:print(f"ssh tunnel to Nimbus {host}:{remote_port} established.")_active_tunnels[local_port] = remote_portyield "localhost", local_port# Clean up after we exit contextif need_setup:ssh_proc.kill()del _active_tunnels[local_port]# Do nothing if we're not supposed to use sshelse:yield host, remote_port
| 13
| 47
| 4
| 221
| 8
| 51
| 110
| 51
| null |
['ssh_proc', 'ssh_cmd', 'port', 'active_remote_port', 'remote_port', 'user_at_host', 'need_setup', 'user']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (ssh_tunnel) defined within the public class called public.The function start at line 51 and ends at 110. It contains 47 lines of code and it has a cyclomatic complexity of 13. It takes 4 parameters, represented as [51.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
activate_env
|
def activate_env(env_name=None, options=None, config_file=None):"""Activate a particular environment from a streamparse project'sconfig.json file and populate fabric's env dictionary with appropriatevalues.:param env_name: a `str` corresponding to the key within the config file's "envs" dictionary.:param config_file: a `file`-like object that contains the config.jsoncontents. If `None`, we look for a file named``config.json`` in the working directory."""env_name, env_config = get_env_config(env_name, config_file=config_file)if options and options.get("storm.workers.list"):env.storm_workers = options["storm.workers.list"]else:env.storm_workers = get_storm_workers(env_config)env.user = env_config.get("user")env.log_path = (env_config.get("log_path")or env_config.get("log", {}).get("path")or get_nimbus_config(env_config).get("storm.log.dir"))env.virtualenv_root = env_config.get("virtualenv_root") or env_config.get("virtualenv_path")env.disable_known_hosts = Trueenv.forward_agent = Trueenv.use_ssh_config = True# fix for config file load issueif env_config.get("ssh_password"):env.password = env_config.get("ssh_password")
| 7
| 20
| 3
| 153
| 0
| 113
| 144
| 113
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (activate_env) defined within the public class called public.The function start at line 113 and ends at 144. It contains 20 lines of code and it has a cyclomatic complexity of 7. It takes 3 parameters, represented as [113.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
die
|
def die(msg, error_code=1):print(f"{red('error')}: {msg}")sys.exit(error_code)
| 1
| 3
| 2
| 20
| 0
| 147
| 149
| 147
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (die) defined within the public class called public.The function start at line 147 and ends at 149. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [147.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
warn
|
def warn(msg, error_code=1):print(f"{yellow('warning')}: {msg}")
| 1
| 2
| 2
| 14
| 0
| 152
| 153
| 152
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (warn) defined within the public class called public.The function start at line 152 and ends at 153. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [152.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_config
|
def get_config(config_file=None):"""Parses the config file and returns it as a `dict`.:param config_file: a `file`-like object that contains the config.jsoncontents. If `None`, we look for a file named``config.json`` in the working directory.:returns: a `dict` representing the parsed `config_file`."""global _configif _config is not None:return _configif config_file is None:if not os.path.exists("config.json"):die("No config.json found. You must run this command inside a ""streamparse project directory.")with open("config.json") as fp:config = json.load(fp)else:config = json.load(config_file)_config = configreturn config
| 4
| 16
| 1
| 70
| 2
| 159
| 185
| 159
| null |
['config', '_config']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_config) defined within the public class called public.The function start at line 159 and ends at 185. It contains 16 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_topology_definition
|
def get_topology_definition(topology_name=None, config_file=None):"""Fetch a topology name and definition file.If the topology_name isNone, and there's only one topology definiton listed, we'll select thatone, otherwise we'll die to avoid ambiguity.:param topology_name: a `str`, the topology_name of the topology (without.py extension).:param config_file: a `file`-like object that contains the config.jsoncontents. If `None`, we look for a file named``config.json`` in the working directory.:returns: a `tuple` containing (topology_name, topology_file)."""config = get_config(config_file=config_file)topology_path = config["topology_specs"]if topology_name is None:topology_files = glob(f"{topology_path}/*.py")if not topology_files:die(f"No topology definitions are defined in {topology_path}.")if len(topology_files) > 1:die("Found more than one topology definition file in {specs_dir}. ""When more than one topology definition file exists, you must ""explicitly specify the topology by name using the -n or ""--name flags.".format(specs_dir=topology_path))topology_file = topology_files[0]topology_name = re.sub(fr"(^{topology_path}|\.py$)", "", topology_file)else:topology_file = f"{os.path.join(topology_path, topology_name)}.py"if not os.path.exists(topology_file):die("Topology definition file not found {}. You need to ""create a topology definition file first.".format(topology_file))return (topology_name, topology_file)
| 5
| 24
| 2
| 121
| 5
| 188
| 224
| 188
| null |
['config', 'topology_file', 'topology_name', 'topology_path', 'topology_files']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_topology_definition) defined within the public class called public.The function start at line 188 and ends at 224. It contains 24 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [188.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_env_config
|
def get_env_config(env_name=None, config_file=None):"""Fetch an environment name and config object from the config.json file.If the name is None and there's only one environment, we'll select thefirst, otherwise we'll die to avoid ambiguity.:param config_file: a `file`-like object that contains the config.jsoncontents. If `None`, we look for a file named``config.json`` in the working directory.:returns: a `tuple` containing (env_name, env_config)."""config = get_config(config_file=config_file)if env_name is None and len(config["envs"]) == 1:env_name = list(config["envs"].keys())[0]elif env_name is None and len(config["envs"]) > 1:die("Found more than one environment in config.json.When more than ""one environment exists, you must explicitly specify the ""environment name via the -e or --environment flags.")if env_name not in config["envs"]:die(f'Could not find a "{env_name}" in config.json, have you specified one?')return (env_name, config["envs"][env_name])
| 6
| 15
| 2
| 98
| 2
| 227
| 252
| 227
| null |
['config', 'env_name']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_env_config) defined within the public class called public.The function start at line 227 and ends at 252. It contains 15 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [227.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_nimbus_host_port
|
def get_nimbus_host_port(env_config):"""Get the Nimbus server's hostname and port from environment variablesor from a streamparse project's config file.:param env_config: The project's parsed config.:type env_config: `dict`:returns: (host, port)"""env_config["nimbus"] = os.environ.get("STREAMPARSE_NIMBUS", env_config["nimbus"])if not env_config["nimbus"]:die("No Nimbus server configured in config.json.")if ":" in env_config["nimbus"]:host, port = env_config["nimbus"].split(":", 1)port = int(port)else:host = env_config["nimbus"]port = 6627return (host, port)
| 3
| 11
| 1
| 81
| 2
| 255
| 275
| 255
| null |
['port', 'host']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_nimbus_host_port) defined within the public class called public.The function start at line 255 and ends at 275. It contains 11 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_nimbus_client
|
def get_nimbus_client(env_config=None, host=None, port=None, timeout=7000):"""Get a Thrift RPC client for Nimbus given project's config file.:param env_config: The project's parsed config.:type env_config: `dict`:param host: The host to use for Nimbus.If specified, `env_config` will not be consulted.:type host: `str`:param port: The port to use for Nimbus.If specified, `env_config` will not be consulted.:type port: `int`:param timeout: The time to wait (in milliseconds) for a response fromNimbus.:param timeout: `int`:returns: a ThriftPy RPC client to use to communicate with Nimbus"""if host is None:host, port = get_nimbus_host_port(env_config)nimbus_client = make_client(Nimbus,host=host,port=port,proto_factory=TBinaryProtocolFactory(),trans_factory=TFramedTransportFactory(),timeout=timeout,)return nimbus_client
| 2
| 12
| 4
| 66
| 1
| 278
| 305
| 278
| null |
['nimbus_client']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_nimbus_client) defined within the public class called public.The function start at line 278 and ends at 305. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [278.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_storm_workers
|
def get_storm_workers(env_config):"""Retrieves list of workers, optionally from nimbus.This function will look up the list of current workers from nimbus ifworkers have not been defined in config.json.:param env_config: The project's parsed config.:type env_config: `dict`:returns: List of workers"""nimbus_info = get_nimbus_host_port(env_config)if nimbus_info in _storm_workers:return _storm_workers[nimbus_info]worker_list = env_config.get("workers")if not worker_list:with ssh_tunnel(env_config) as (host, port):nimbus_client = get_nimbus_client(env_config, host=host, port=port)cluster_info = nimbus_client.getClusterInfo()worker_list = [supervisor.host for supervisor in cluster_info.supervisors]_storm_workers[nimbus_info] = worker_listreturn worker_list
| 4
| 12
| 1
| 88
| 4
| 311
| 334
| 311
| null |
['nimbus_client', 'cluster_info', 'nimbus_info', 'worker_list']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_storm_workers) defined within the public class called public.The function start at line 311 and ends at 334. It contains 12 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_nimbus_config
|
def get_nimbus_config(env_config):"""Retrieves a dict with all the config info stored in Nimbus:param env_config: The project's parsed config.:type env_config: `dict`:returns: dict of Nimbus settings"""nimbus_info = get_nimbus_host_port(env_config)if nimbus_info not in _nimbus_configs:with ssh_tunnel(env_config) as (host, port):nimbus_client = get_nimbus_client(env_config, host=host, port=port)nimbus_json = nimbus_client.getNimbusConf()nimbus_conf = json.loads(nimbus_json)_nimbus_configs[nimbus_info] = nimbus_confreturn _nimbus_configs[nimbus_info]
| 2
| 9
| 1
| 70
| 4
| 340
| 355
| 340
| null |
['nimbus_client', 'nimbus_json', 'nimbus_info', 'nimbus_conf']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_nimbus_config) defined within the public class called public.The function start at line 340 and ends at 355. It contains 9 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
is_ssh_for_nimbus
|
def is_ssh_for_nimbus(env_config):"""Check if we need to use SSH access to Nimbus or not."""return env_config.get("use_ssh_for_nimbus", True)
| 1
| 2
| 1
| 15
| 0
| 358
| 360
| 358
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (is_ssh_for_nimbus) defined within the public class called public.The function start at line 358 and ends at 360. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
local_storm_version
|
def local_storm_version():"""Get the Storm version available on the users PATH.:returns: The Storm library available on the users PATH:rtype: pkg_resources.Version"""with hide("running"), settings(warn_only=True):cmd = "storm version"res = local(cmd, capture=True)if not res.succeeded:raise RuntimeError(f"Unable to run '{cmd}'!\nSTDOUT:\n{res.stdout}\nSTDERR:\n{res.stderr}")pattern = r"Storm ([0-9.]+)"return parse_version(re.findall(pattern, res.stdout, flags=re.MULTILINE)[0])
| 2
| 10
| 0
| 70
| 3
| 363
| 378
| 363
| null |
['res', 'pattern', 'cmd']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (local_storm_version) defined within the public class called public.The function start at line 363 and ends at 378. It contains 10 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
nimbus_storm_version
|
def nimbus_storm_version(nimbus_client):"""Get the Storm version that Nimbus is reporting, if it's reporting it.:returns: Storm version that Nimbus is reporting, if it's reporting it.Will return `Version('0.0.0')` if it's not reporting anything.:rtype: pkg_resources.Version"""version = "0.0.0"nimbuses = nimbus_client.getClusterInfo().nimbusesif nimbuses is not None:for nimbus in nimbuses:if nimbus.version != "VERSION_NOT_PROVIDED":version = nimbus.versionbreakreturn parse_version(version)
| 4
| 9
| 1
| 47
| 2
| 381
| 395
| 381
| null |
['version', 'nimbuses']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (nimbus_storm_version) defined within the public class called public.The function start at line 381 and ends at 395. It contains 9 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
storm_lib_version
|
def storm_lib_version():"""Get the Storm library version being used by Leiningen.:returns: The Storm library version specified in project.clj:rtype: pkg_resources.Version"""with hide("running"), settings(warn_only=True):cmd = "lein deps :tree"res = local(cmd, capture=True)if not res.succeeded:raise RuntimeError(f"Unable to run '{cmd}'!\nSTDOUT:\n{res.stdout}\nSTDERR:\n{res.stderr}")deps_tree = res.stdoutpattern = r'\[org\.apache\.storm/storm-core "([^"]+)"\]'versions = set(re.findall(pattern, deps_tree))if len(versions) > 1:raise RuntimeError("Multiple Storm Versions Detected.")elif len(versions) == 0:raise RuntimeError("No Storm version specified in project.clj " "dependencies.")else:return parse_version(versions.pop())
| 4
| 17
| 0
| 103
| 5
| 398
| 420
| 398
| null |
['res', 'pattern', 'cmd', 'versions', 'deps_tree']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (storm_lib_version) defined within the public class called public.The function start at line 398 and ends at 420. It contains 17 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_ui_jsons
|
def get_ui_jsons(env_name, api_paths, config_file=None):"""Take env_name as a string and api_paths that shouldbe a list of strings like '/api/v1/topology/summary'"""_, env_config = get_env_config(env_name, config_file=config_file)host, _ = get_nimbus_host_port(env_config)# TODO: Get remote_ui_port from storm?remote_ui_port = env_config.get("ui.port", 8080)# SSH tunnel can take a while to close. Check multiples if necessary.local_ports = list(range(8081, 8090))shuffle(local_ports)for local_port in local_ports:try:data = {}with ssh_tunnel(env_config, local_port=local_port, remote_port=remote_ui_port) as (host, local_port):for api_path in api_paths:url = f"http://{host}:{local_port}{api_path}"r = requests.get(url)data[api_path] = r.json()error = data[api_path].get("error")if error:error_msg = data[api_path].get("errorMessage")raise RuntimeError(f"Received bad response from {url}: {error}\n{error_msg}")return dataexcept Exception as e:if "already in use" in str(e):continueraiseraise RuntimeError("Cannot find local port for SSH tunnel to Storm Head.")
| 6
| 28
| 3
| 168
| 7
| 423
| 455
| 423
| null |
['r', 'error_msg', 'local_ports', 'url', 'remote_ui_port', 'data', 'error']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_ui_jsons) defined within the public class called public.The function start at line 423 and ends at 455. It contains 28 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [423.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_ui_json
|
def get_ui_json(env_name, api_path, config_file=None):"""Take env_name as a string and api_path that shouldbe a string like '/api/v1/topology/summary'"""return get_ui_jsons(env_name, [api_path], config_file=config_file)[api_path]
| 1
| 2
| 3
| 28
| 0
| 458
| 462
| 458
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_ui_json) defined within the public class called public.The function start at line 458 and ends at 462. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [458.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
prepare_topology
|
def prepare_topology():"""Prepare a topology for JAR creation"""resources_dir = join("_resources", "resources")if os.path.isdir(resources_dir):shutil.rmtree(resources_dir)if os.path.exists("src"):shutil.copytree("src", resources_dir)else:raise FileNotFoundError('Your project must have a "src" directory.')
| 3
| 8
| 0
| 54
| 1
| 465
| 473
| 465
| null |
['resources_dir']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (prepare_topology) defined within the public class called public.The function start at line 465 and ends at 473. It contains 8 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_get_file_names_command
|
def _get_file_names_command(path, patterns):"""Given a list of bash `find` patterns, return a string for thebash command that will find those pystorm log files"""if path is None:raise ValueError("path cannot be None")patterns = "' -o -type f -wholename '".join(patterns)return ("cd {path} && " "find . -maxdepth 4 -type f -wholename '{patterns}'").format(path=path, patterns=patterns)
| 2
| 7
| 2
| 42
| 1
| 476
| 485
| 476
| null |
['patterns']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_get_file_names_command) defined within the public class called public.The function start at line 476 and ends at 485. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [476.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_logfiles_cmd
|
def get_logfiles_cmd(topology_name=None,pattern=None,include_worker_logs=True,is_old_storm=False,include_all_artifacts=False,):"""Returns a string representing a command to run on the Storm workers thatwill yield all of the logfiles for the given topology that meet the givenpattern (if specified)."""log_name_patterns = [f"*{topology_name}*"]if not include_all_artifacts:log_name_patterns[0] += ".log"# The worker logs are separated by topology in Storm 1.0+, so no need to do# this except on old versions of Stormif not is_old_storm:include_worker_logs = False# list log files foundif include_worker_logs:log_name_patterns.extend(["worker*", "supervisor*", "access*", "metrics*"])if env.log_path is None:raise ValueError("Cannot find log files if you do not set `log_path` ""or the `path` key in the `log` dict for your ""environment in your config.json.")ls_cmd = _get_file_names_command(env.log_path, log_name_patterns)if pattern is not None:ls_cmd += f" | egrep '{pattern}'"return ls_cmd
| 6
| 24
| 5
| 101
| 3
| 488
| 518
| 488
| null |
['log_name_patterns', 'include_worker_logs', 'ls_cmd']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_logfiles_cmd) defined within the public class called public.The function start at line 488 and ends at 518. It contains 24 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [488.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
print_stats_table
|
def print_stats_table(header, data, columns, default_alignment="l", custom_alignment=None):"""Print out a list of dictionaries (or objects) as a table.If given a list of objects, will print out the contents of objects'`__dict__` attributes.:param header: Header that will be printed above table.:type header:`str`:param data: List of dictionaries (or objects )"""print(f"# {header}")table = Texttable(max_width=115)table.header(columns)table.set_cols_align(default_alignment * len(columns))if not isinstance(data, list):data = [data]for row in data:# Treat all non-list/tuple objects like dicts to make life easierif not isinstance(row, (list, tuple, dict)):row = vars(row)if isinstance(row, dict):row = [row.get(key, "MISSING") for key in columns]table.add_row(row)if custom_alignment:table.set_cols_align([custom_alignment.get(column, default_alignment) for column in columns])print(table.draw())
| 8
| 20
| 5
| 148
| 3
| 521
| 550
| 521
| null |
['row', 'table', 'data']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (print_stats_table) defined within the public class called public.The function start at line 521 and ends at 550. It contains 20 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [521.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
get_topology_from_file
|
def get_topology_from_file(topology_file):"""Given a filename for a topology, import the topology and return the class"""topology_dir, mod_name = os.path.split(topology_file)# Remove .py extension before trying to importmod_name = mod_name[:-3]sys.path.append(os.path.join(topology_dir, "..", "src"))sys.path.append(topology_dir)mod = importlib.import_module(mod_name)for attr in mod.__dict__.values():if isinstance(attr, TopologyType) and attr != Topology:topology_class = attrbreakelse:raise ValueError("Could not find topology subclass in topology module.")return topology_class
| 4
| 13
| 1
| 97
| 3
| 553
| 569
| 553
| null |
['mod_name', 'topology_class', 'mod']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (get_topology_from_file) defined within the public class called public.The function start at line 553 and ends at 569. It contains 13 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
set_topology_serializer
|
def set_topology_serializer(env_config, config, topology_class):"""Go through the components in a `Topology` and set the serializer.This is necessary because the `Topology` class has no information about theuser-specified serializer, but it needs to be passed as an argument to``streamparse_run``."""serializer = env_config.get("serializer", config.get("serializer", None))if serializer is not None:# Set serializer arg in boltsfor thrift_bolt in topology_class.thrift_bolts.values():inner_shell = thrift_bolt.bolt_object.shellif inner_shell is not None:inner_shell.script = f"-s {serializer} {inner_shell.script}"# Set serializer arg in spoutsfor thrift_spout in topology_class.thrift_spouts.values():inner_shell = thrift_spout.spout_object.shellif inner_shell is not None:inner_shell.script = f"-s {serializer} {inner_shell.script}"
| 6
| 11
| 3
| 93
| 2
| 572
| 590
| 572
| null |
['serializer', 'inner_shell']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (set_topology_serializer) defined within the public class called public.The function start at line 572 and ends at 590. It contains 11 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [572.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
run_cmd
|
def run_cmd(cmd, user, **kwargs):with show("everything"):with settings(warn_only=True):command_result = (run(cmd, **kwargs)if user == env.userelse sudo(cmd, user=user, **kwargs))if command_result.return_code != 0:raise RuntimeError('Command failed to run: %s' % cmd)return command_result
| 3
| 11
| 3
| 69
| 1
| 593
| 603
| 593
| null |
['command_result']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (run_cmd) defined within the public class called public.The function start at line 593 and ends at 603. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [593.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_safe_int
|
def _safe_int(string):"""Simple function to convert strings into ints without dying."""try:return int(string)except ValueError:return string
| 2
| 5
| 1
| 18
| 0
| 23
| 28
| 23
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_safe_int) defined within the public class called public.The function start at line 23 and ends at 28. It contains 5 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_here
|
def _here(*paths):path = os.path.join(*paths)filename = pkg_resources.resource_filename(__name__, path)return filename
| 1
| 4
| 1
| 29
| 2
| 19
| 22
| 19
| null |
['filename', 'path']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_here) defined within the public class called public.The function start at line 19 and ends at 22. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_cd
|
def _cd(path):global _path_prefixesglobal _path_prefix_path_prefixes.append(path)_path_prefix = "/".join(_path_prefixes)yield_path_prefixes.pop()_path_prefix = "/".join(_path_prefixes)
| 1
| 8
| 1
| 37
| 1
| 29
| 36
| 29
| null |
['_path_prefix']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_cd) defined within the public class called public.The function start at line 29 and ends at 36. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_mkdir
|
def _mkdir(path):path = f"{_path_prefix}/{path}" if _path_prefix != "" else pathprint(f"{green('create'):<18} {path}")os.makedirs(path)
| 2
| 4
| 1
| 26
| 1
| 39
| 42
| 39
| null |
['path']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_mkdir) defined within the public class called public.The function start at line 39 and ends at 42. It contains 4 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_cp
|
def _cp(src, dest):dest = f"{_path_prefix}/{dest}" if _path_prefix != "" else destprint(f"{green('create'):<18} {dest}")shutil.copy(src, dest)
| 2
| 4
| 2
| 30
| 1
| 45
| 48
| 45
| null |
['dest']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_cp) defined within the public class called public.The function start at line 45 and ends at 48. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [45.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_touch
|
def _touch(filename):filename = (f"{_path_prefix}/{filename}" if _path_prefix != "" else filename)print(f"{green('create'):<18} {filename}")with open(filename, "w"):pass
| 2
| 7
| 1
| 31
| 1
| 51
| 57
| 51
| null |
['filename']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_touch) defined within the public class called public.The function start at line 51 and ends at 57. It contains 7 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_generate
|
def _generate(template_filename, dest):dest = f"{_path_prefix}/{dest}" if _path_prefix != "" else destprint(f"{green('create'):<18} {dest}")template = _env.get_template(template_filename)with open(dest, "w") as fp:fp.write(template.render())
| 2
| 6
| 2
| 50
| 2
| 60
| 65
| 60
| null |
['template', 'dest']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_generate) defined within the public class called public.The function start at line 60 and ends at 65. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [60.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
quickstart
|
def quickstart(project_name):# TODO: alternate way maybe to do all of this is do something like# glob.glob('project/**/*') and then we copy everything that's doesn't have# jinja2 in filename, generate the jinja2 stuffif os.path.exists(project_name):print(f"{red('error')}: folder \"{project_name}\" already exists")sys.exit(1)print(f"\nCreating your {blue(project_name)} streamparse project...")_env.globals["project_name"] = project_name_mkdir(project_name)with _cd(project_name):_cp(_here("project", "gitignore"), ".gitignore")_generate("config.jinja2.json", "config.json")_cp(_here("project", "fabfile.py"), "fabfile.py")_generate("project.jinja2.clj", "project.clj")_touch("README.md")_mkdir("src")with _cd("src"):_mkdir("bolts")with _cd("bolts"):_cp(_here("project", "src", "bolts", "__init__.py"), "__init__.py")_cp(_here("project", "src", "bolts", "wordcount.py"), "wordcount.py")_mkdir("spouts")with _cd("spouts"):_cp(_here("project", "src", "spouts", "__init__.py"), "__init__.py")_cp(_here("project", "src", "spouts", "words.py"), "words.py")_mkdir("topologies")with _cd("topologies"):_cp(_here("project", "topologies", "wordcount.py"), "wordcount.py")_mkdir("virtualenvs")with _cd("virtualenvs"):_cp(_here("project", "virtualenvs", "wordcount.txt"), "wordcount.txt")print("Done.\n")print(("Try running your topology locally with:\n\n" "\tcd {}\n" "\tsparse run").format(project_name))
| 2
| 35
| 1
| 240
| 0
| 68
| 108
| 68
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (quickstart) defined within the public class called public.The function start at line 68 and ends at 108. It contains 35 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
pre_submit
|
def pre_submit(topology_name, env_name, env_config, options):"""Override this function to perform custom actions prior to topologysubmission. No SSH tunnels will be active when this function is called."""pass
| 1
| 2
| 4
| 13
| 0
| 1
| 4
| 1
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (pre_submit) defined within the public class called public.The function start at line 1 and ends at 4. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [1.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
post_submit
|
def post_submit(topo_name, env_name, env_config, options):"""Override this function to perform custom actions after topologysubmission. Note that the SSH tunnel to Nimbus will still be activewhen this function is called."""pass
| 1
| 2
| 4
| 13
| 0
| 7
| 11
| 7
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (post_submit) defined within the public class called public.The function start at line 7 and ends at 11. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [7.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
initialize
|
def initialize(self, conf, ctx):self.counter = Counter()self.pid = os.getpid()self.total = 0
| 1
| 4
| 3
| 30
| 0
| 10
| 13
| 10
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (initialize) defined within the public class called public.The function start at line 10 and ends at 13. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [10.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_increment
|
def _increment(self, word, inc_by):self.counter[word] += inc_byself.total += inc_by
| 1
| 3
| 3
| 22
| 0
| 15
| 17
| 15
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_increment) defined within the public class called public.The function start at line 15 and ends at 17. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [15.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
process
|
def process(self, tup):word = tup.values[0]self._increment(word, 10 if word == "dog" else 1)if self.total % 1000 == 0:self.logger.info(f"counted [{self.total:,}] words [pid={self.pid}]")self.emit([word, self.counter[word]])
| 3
| 8
| 2
| 62
| 0
| 19
| 26
| 19
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (process) defined within the public class called public.The function start at line 19 and ends at 26. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [19.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
initialize
|
def initialize(self, stormconf, context):self.words = cycle(["dog", "cat", "zebra", "elephant"])
| 1
| 2
| 3
| 25
| 0
| 9
| 10
| 9
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (initialize) defined within the public class called public.The function start at line 9 and ends at 10. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [9.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
next_tuple
|
def next_tuple(self):word = next(self.words)self.emit([word])
| 1
| 3
| 1
| 21
| 0
| 12
| 14
| 12
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (next_tuple) defined within the public class called public.The function start at line 12 and ends at 14. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
__init__
|
def __init__(self,option_strings,dest,nargs=None,const=None,default=None,type=None,choices=None,required=False,help=None,metavar=None,):if nargs == 0:raise ValueError("nargs for store_dict actions must be > 0")if const is not None and nargs != "?":raise ValueError('nargs must be "?" to supply const')super().__init__(option_strings=option_strings,dest=dest,nargs=nargs,const=const,default=default,type=type,choices=choices,required=required,help=help,metavar=metavar,)
| 4
| 29
| 11
| 114
| 0
| 16
| 44
| 16
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (__init__) defined within the public class called public.The function start at line 16 and ends at 44. It contains 29 lines of code and it has a cyclomatic complexity of 4. It takes 11 parameters, represented as [16.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
__call__
|
def __call__(self, parser, namespace, values, option_string=None):if getattr(namespace, self.dest, None) is None:setattr(namespace, self.dest, {})# Only doing a copy here because that's what _AppendAction doesitems = copy.copy(getattr(namespace, self.dest))key, val = values.split("=", 1)if yaml.version_info < (0, 15):items[key] = yaml.safe_load(val)else:yml = yaml.YAML(typ="safe", pure=True)items[key] = yml.load(val)setattr(namespace, self.dest, items)
| 3
| 11
| 5
| 126
| 0
| 46
| 57
| 46
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (__call__) defined within the public class called public.The function start at line 46 and ends at 57. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [46.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
option_alias._create_key_val_str
|
def _create_key_val_str(val):return f"{option}={val}"
| 1
| 2
| 1
| 8
| 0
| 63
| 64
| 63
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (option_alias._create_key_val_str) defined within the public class called public.The function start at line 63 and ends at 64. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
option_alias
|
def option_alias(option):"""Returns a function that will create option=val for _StoreDictAction."""def _create_key_val_str(val):return f"{option}={val}"return _create_key_val_str
| 1
| 3
| 1
| 10
| 0
| 60
| 66
| 60
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (option_alias) defined within the public class called public.The function start at line 60 and ends at 66. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_ackers
|
def add_ackers(parser):""" Add --ackers option to parser """parser.add_argument("-a","--ackers",help="Set number of acker executors for your topology. ""Defaults to the number of worker nodes in your ""Storm environment.",type=option_alias("topology.acker.executors"),action=_StoreDictAction,dest="options",)
| 1
| 11
| 1
| 36
| 0
| 69
| 80
| 69
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_ackers) defined within the public class called public.The function start at line 69 and ends at 80. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_config
|
def add_config(parser):""" Add --config option to parser """parser.add_argument("--config", help="Specify path to config.json", type=argparse.FileType("r"))
| 1
| 4
| 1
| 25
| 0
| 83
| 87
| 83
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_config) defined within the public class called public.The function start at line 83 and ends at 87. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_debug
|
def add_debug(parser):""" Add --debug option to parser """parser.add_argument("-d","--debug",help="Set topology.debug and produce debugging output.",type=option_alias("topology.debug"),action=_StoreDictAction,dest="options",const="true",nargs="?",)
| 1
| 11
| 1
| 42
| 0
| 90
| 101
| 90
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_debug) defined within the public class called public.The function start at line 90 and ends at 101. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_environment
|
def add_environment(parser):""" Add --environment option to parser """parser.add_argument("-e","--environment",help="The environment to use for the command.""Corresponds to an environment in your "'"envs" dictionary in config.json.If you '"only have one environment specified, ""streamparse will automatically use this.",)
| 1
| 10
| 1
| 23
| 0
| 104
| 114
| 104
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_environment) defined within the public class called public.The function start at line 104 and ends at 114. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_name
|
def add_name(parser):""" Add --name option to parser """parser.add_argument("-n","--name",help="The name of the topology to act on.If you have "'only one topology defined in your "topologies" '"directory, streamparse will use it ""automatically.",)
| 1
| 9
| 1
| 22
| 0
| 117
| 126
| 117
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_name) defined within the public class called public.The function start at line 117 and ends at 126. It contains 9 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_options
|
def add_options(parser):""" Add --option options to parser """parser.add_argument("-o","--option",dest="options",action=_StoreDictAction,help="Topology option to pass on to Storm. For example,"' "-o topology.debug=true" is equivalent to ''"--debug".May be repeated multiple for multiple'" options.",)
| 1
| 11
| 1
| 30
| 0
| 129
| 140
| 129
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_options) defined within the public class called public.The function start at line 129 and ends at 140. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_override_name
|
def add_override_name(parser):""" Add --override_name option to parser """parser.add_argument("-N","--override_name",help="For operations such as creating virtualenvs and ""killing/submitting topologies, use this value ""instead of NAME.This is useful if you want to ""submit the same topology twice without having to ""duplicate the topology file.",)
| 1
| 10
| 1
| 23
| 0
| 143
| 153
| 143
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_override_name) defined within the public class called public.The function start at line 143 and ends at 153. It contains 10 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_overwrite_virtualenv
|
def add_overwrite_virtualenv(parser):""" Add --overwrite_virtualenv option to parser """parser.add_argument("--overwrite_virtualenv",help="Create the virtualenv even if it already exists."" This is useful when you have changed your ""virtualenv_flags.",action="store_true",)
| 1
| 8
| 1
| 23
| 0
| 156
| 164
| 156
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_overwrite_virtualenv) defined within the public class called public.The function start at line 156 and ends at 164. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_pattern
|
def add_pattern(parser):""" Add --pattern option to parser """parser.add_argument("--pattern", help="Pattern of log files to operate on.")
| 1
| 2
| 1
| 16
| 0
| 167
| 169
| 167
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_pattern) defined within the public class called public.The function start at line 167 and ends at 169. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_pool_size
|
def add_pool_size(parser):""" Add --pool_size option to parser """parser.add_argument("--pool_size",help="Number of simultaneous SSH connections to use when updating ""virtualenvs, removing logs, or tailing logs.",default=10,type=int,)
| 1
| 8
| 1
| 26
| 0
| 172
| 180
| 172
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_pool_size) defined within the public class called public.The function start at line 172 and ends at 180. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_requirements
|
def add_requirements(parser):""" Add --requirements option to parser """parser.add_argument("-r","--requirements",nargs="*",help="Path to pip-style requirements file specifying ""the dependencies to use for creating the ""virtualenv for this topology.If unspecified, ""streamparse will look for a file called NAME.txt ""in the directory specified by the ""virtualenv_specs setting in config.json.",)
| 1
| 12
| 1
| 28
| 0
| 183
| 195
| 183
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_requirements) defined within the public class called public.The function start at line 183 and ends at 195. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_simple_jar
|
def add_simple_jar(parser):""" Add --simple_jar option to parser. """parser.add_argument("-s","--simple_jar",action="store_true",help="Instead of creating an Uber-JAR for the ""topology, which contains all of its JVM ""dependencies, create a simple JAR with just the ""code for the project.This is useful when your ""project is pure Python and has no JVM ""dependencies.",)
| 1
| 12
| 1
| 28
| 0
| 198
| 210
| 198
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_simple_jar) defined within the public class called public.The function start at line 198 and ends at 210. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_timeout
|
def add_timeout(parser):""" Add --timeout option to parser """parser.add_argument("--timeout",type=int,default=7000,help="Milliseconds to wait for Nimbus to respond. " "(default: %(default)s)",)
| 1
| 7
| 1
| 26
| 0
| 213
| 220
| 213
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_timeout) defined within the public class called public.The function start at line 213 and ends at 220. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_user
|
def add_user(parser, allow_short=False):"""Add --user option to parserSet allow_short to add -u as well."""args = ["--user"]if allow_short:args.insert(0, "-u")kwargs = {"help": "User argument to sudo when creating and deleting virtualenvs.","default": None,"type": option_alias("sudo_user"),"dest": "options","action": _StoreDictAction,}parser.add_argument(*args, **kwargs)
| 2
| 12
| 2
| 63
| 2
| 223
| 240
| 223
| null |
['kwargs', 'args']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_user) defined within the public class called public.The function start at line 223 and ends at 240. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [223.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_wait
|
def add_wait(parser):""" Add --wait option to parser """parser.add_argument("--wait",type=int,default=5,help="Seconds to wait before killing topology. " "(default: %(default)s)",)
| 1
| 7
| 1
| 26
| 0
| 243
| 250
| 243
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_wait) defined within the public class called public.The function start at line 243 and ends at 250. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
add_workers
|
def add_workers(parser):""" Add --workers option to parser """parser.add_argument("-w","--workers",help="Set number of Storm workers for your topology. ""Defaults to the number of worker nodes in your ""Storm environment.",type=option_alias("topology.workers"),action=_StoreDictAction,dest="options",)
| 1
| 11
| 1
| 36
| 0
| 253
| 264
| 253
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (add_workers) defined within the public class called public.The function start at line 253 and ends at 264. It contains 11 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
resolve_options
|
def resolve_options(cli_options, env_config, topology_class, topology_name, local_only=False):"""Resolve potentially conflicting Storm options from three sources:CLI options > Topology options > config.json options:param local_only: Whether or not we should talk to Nimbus to get Storm workers and other info."""storm_options = {}# Start with environment optionsstorm_options.update(env_config.get("options", {}))# Set topology.python.pathif env_config.get("use_virtualenv", True):python_path = "/".join([env_config["virtualenv_root"], topology_name, "bin", "python"])# This setting is for information purposes only, and is not actually# read by any pystorm or streamparse code.storm_options["topology.python.path"] = python_path# Set logging options based on environment configlog_config = env_config.get("log", {})log_path = log_config.get("path") or env_config.get("log_path")log_file = log_config.get("file") or env_config.get("log_file")if log_path:storm_options["pystorm.log.path"] = log_pathif log_file:storm_options["pystorm.log.file"] = log_fileif isinstance(log_config.get("max_bytes"), int):storm_options["pystorm.log.max_bytes"] = log_config["max_bytes"]if isinstance(log_config.get("backup_count"), int):storm_options["pystorm.log.backup_count"] = log_config["backup_count"]if isinstance(log_config.get("level"), str):storm_options["pystorm.log.level"] = log_config["level"].lower()# Make sure virtualenv options are present herefor venv_option in VIRTUALENV_OPTIONS:if venv_option in env_config:storm_options[venv_option] = env_config[venv_option]# Set sudo_user default to SSH user if we have onestorm_options["sudo_user"] = env_config.get("user", None)# Override options with topology optionsstorm_options.update(topology_class.config)# Override options with CLI optionsstorm_options.update(cli_options or {})# Set log level to debug if topology.debug is setif storm_options.get("topology.debug", False):storm_options["pystorm.log.level"] = "debug"# If ackers and executors still aren't set, use number of worker nodesif not local_only:if not storm_options.get("storm.workers.list"):storm_options["storm.workers.list"] = get_storm_workers(env_config)elif isinstance(storm_options["storm.workers.list"], str):storm_options["storm.workers.list"] = storm_options["storm.workers.list"].split(",")num_storm_workers = len(storm_options["storm.workers.list"])else:storm_options["storm.workers.list"] = []num_storm_workers = 1if storm_options.get("topology.acker.executors") is None:storm_options["topology.acker.executors"] = num_storm_workersif storm_options.get("topology.workers") is None:storm_options["topology.workers"] = num_storm_workers# If sudo_user was not present anywhere, set it to "root"storm_options.setdefault("sudo_user", "root")return storm_options
| 18
| 48
| 5
| 373
| 6
| 276
| 353
| 276
| null |
['storm_options', 'log_file', 'python_path', 'log_path', 'log_config', 'num_storm_workers']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (resolve_options) defined within the public class called public.The function start at line 276 and ends at 353. It contains 48 lines of code and it has a cyclomatic complexity of 18. It takes 5 parameters, represented as [276.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
warn_about_deprecated_user
|
def warn_about_deprecated_user(user, func_name):if user is not None:warnings.warn(("The 'user' argument to '{}' will be removed in the next ""major release of streamparse. Provide the 'sudo_user' key to"" the 'options' dict argument instead.").format(func_name),DeprecationWarning,)
| 2
| 10
| 2
| 31
| 0
| 356
| 365
| 356
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (warn_about_deprecated_user) defined within the public class called public.The function start at line 356 and ends at 365. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [356.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
jar_for_deploy
|
def jar_for_deploy(simple_jar=False):""" Build a jar to use for deploying the topology. """# Create _resources folder which will contain Python code in JARprepare_topology()# Use Leiningen to clean up and build JARjar_type = "JAR" if simple_jar else "Uber-JAR"print("Cleaning from prior builds...")sys.stdout.flush()with hide("running", "stdout"):res = local("lein clean")if not res.succeeded:raise RuntimeError(f"Unable to run 'lein clean'!\nSTDOUT:\n{res.stdout}\nSTDERR:\n{res.stderr}")print(f"Creating topology {jar_type}...")sys.stdout.flush()cmd = "lein jar" if simple_jar else "lein uberjar"with hide("running"), settings(warn_only=True):res = local(cmd, capture=True)if not res.succeeded:raise RuntimeError(f"Unable to run '{cmd}'!\nSTDOUT:\n{res.stdout}\nSTDERR:\n{res.stderr}")# XXX: This will fail if more than one JAR is builtlines = res.stdout.splitlines()for line in lines:line = line.strip()if not line.startswith("Created"):continueline = line.replace("Created ", "")# != is XORif simple_jar != line.endswith("standalone.jar"):jar = linebreakelse:raise RuntimeError("Failed to find JAR in '{}' output\nSTDOUT:\n{}""STDERR:\n{}".format(cmd, res.stdout, res.stderr))print(f"{jar_type} created: {jar}")sys.stdout.flush()print("Removing _resources temporary directory...", end="")sys.stdout.flush()resources_dir = os.path.join("_resources", "resources")if os.path.isdir(resources_dir):shutil.rmtree(resources_dir)print("done")return jar
| 9
| 43
| 1
| 246
| 7
| 15
| 62
| 15
| null |
['line', 'res', 'jar_type', 'cmd', 'resources_dir', 'lines', 'jar']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (jar_for_deploy) defined within the public class called public.The function start at line 15 and ends at 62. It contains 43 lines of code and it has a cyclomatic complexity of 9. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("jar", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)add_simple_jar(subparser)
| 1
| 4
| 1
| 36
| 1
| 65
| 69
| 65
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 65 and ends at 69. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" Create a deployable JAR for a topology. """jar_for_deploy(simple_jar=args.simple_jar)
| 1
| 2
| 1
| 14
| 0
| 72
| 74
| 72
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 72 and ends at 74. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_kill_topology
|
def _kill_topology(topology_name, nimbus_client, wait=None):kill_opts = KillOptions(wait_secs=wait)nimbus_client.killTopologyWithOpts(name=topology_name, options=kill_opts)
| 1
| 3
| 3
| 31
| 1
| 15
| 17
| 15
| null |
['kill_opts']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_kill_topology) defined within the public class called public.The function start at line 15 and ends at 17. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [15.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
kill_topology
|
def kill_topology(topology_name=None, env_name=None, wait=None, timeout=None, config_file=None):# For kill, we allow any topology name to be specified, because people# should be able to kill topologies not in their local branchif topology_name is None:topology_name = get_topology_definition(topology_name, config_file=config_file)[0]env_name, env_config = get_env_config(env_name, config_file=config_file)# Use ssh tunnel with Nimbus if use_ssh_for_nimbus is unspecified or Truewith ssh_tunnel(env_config) as (host, port):nimbus_client = get_nimbus_client(env_config, host=host, port=port, timeout=timeout)return _kill_topology(topology_name, nimbus_client, wait=wait)
| 2
| 13
| 5
| 94
| 2
| 20
| 35
| 20
| null |
['nimbus_client', 'topology_name']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (kill_topology) defined within the public class called public.The function start at line 20 and ends at 35. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [20.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("kill", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)add_config(subparser)add_environment(subparser)add_name(subparser)add_timeout(subparser)add_wait(subparser)
| 1
| 8
| 1
| 52
| 1
| 38
| 46
| 38
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 38 and ends at 46. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" Kill the specified Storm topology """kill_topology(topology_name=args.name,env_name=args.environment,wait=args.wait,timeout=args.timeout,config_file=args.config,)
| 1
| 8
| 1
| 39
| 0
| 49
| 57
| 49
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 49 and ends at 57. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_list_topologies
|
def _list_topologies(nimbus_client):""":returns: A list of running Storm topologies"""cluster_summary = nimbus_client.getClusterInfo()return cluster_summary.topologies
| 1
| 3
| 1
| 17
| 1
| 10
| 13
| 10
| null |
['cluster_summary']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_list_topologies) defined within the public class called public.The function start at line 10 and ends at 13. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
list_topologies
|
def list_topologies(env_name, timeout=None, config_file=None):"""Prints out all running Storm topologies"""env_name, env_config = get_env_config(env_name, config_file=config_file)# Use ssh tunnel with Nimbus if use_ssh_for_nimbus is unspecified or Truewith ssh_tunnel(env_config) as (host, port):nimbus_client = get_nimbus_client(env_config, host=host, port=port, timeout=timeout)topologies = _list_topologies(nimbus_client)if not topologies:print("No topologies found.")else:columns = [field for field, default in TopologySummary.default_spec]# Find values that are the same for all topologies and list those# separately to prevent table from being too wideif len(topologies) > 1:identical_vals = dict(vars(topologies[0]))for topology in topologies:for column in columns:if column in identical_vals:cur_val = getattr(topology, column)if cur_val != identical_vals[column]:identical_vals.pop(column)if identical_vals:for key in identical_vals.keys():columns.remove(key)print_stats_table("Values identical for all topologies",identical_vals,list(identical_vals.keys()),"l",)print_stats_table("Topology-specific values", topologies, columns, "l")
| 10
| 29
| 3
| 188
| 5
| 16
| 49
| 16
| null |
['nimbus_client', 'identical_vals', 'topologies', 'columns', 'cur_val']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (list_topologies) defined within the public class called public.The function start at line 16 and ends at 49. It contains 29 lines of code and it has a cyclomatic complexity of 10. It takes 3 parameters, represented as [16.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("list", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)add_config(subparser)add_environment(subparser)add_timeout(subparser)
| 1
| 6
| 1
| 44
| 1
| 52
| 58
| 52
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 52 and ends at 58. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" List the currently running Storm topologies """list_topologies(args.environment, timeout=args.timeout, config_file=args.config)
| 1
| 2
| 1
| 24
| 0
| 61
| 63
| 61
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 61 and ends at 63. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("quickstart", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)subparser.add_argument("project_name", help="Name of new streamparse project.")
| 1
| 6
| 1
| 42
| 1
| 8
| 14
| 8
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 8 and ends at 14. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" Create new streamparse project template. """quickstart(args.project_name)
| 1
| 2
| 1
| 12
| 0
| 17
| 19
| 17
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 17 and ends at 19. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_remove_logs
|
def _remove_logs(topology_name, pattern, remove_worker_logs, user, remove_all_artifacts):"""Actual task to remove logs on all servers in parallel."""ls_cmd = get_logfiles_cmd(topology_name=topology_name,pattern=pattern,include_worker_logs=remove_worker_logs,include_all_artifacts=remove_all_artifacts,)rm_pipe = " | xargs rm -f"run_cmd(ls_cmd + rm_pipe, user, warn_only=True)
| 1
| 11
| 5
| 50
| 2
| 29
| 42
| 29
| null |
['rm_pipe', 'ls_cmd']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_remove_logs) defined within the public class called public.The function start at line 29 and ends at 42. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [29.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
remove_logs
|
def remove_logs(topology_name=None,env_name=None,pattern=None,remove_worker_logs=False,user=None,override_name=None,remove_all_artifacts=False,options=None,config_file=None,):"""Remove all Python logs on Storm workers in the log.path directory."""warn_about_deprecated_user(user, "remove_logs")topology_name, topology_file = get_topology_definition(override_name or topology_name, config_file=config_file)topology_class = get_topology_from_file(topology_file)env_name, env_config = get_env_config(env_name, config_file=config_file)storm_options = resolve_options(options, env_config, topology_class, topology_name)activate_env(env_name, storm_options, config_file=config_file)execute(_remove_logs,topology_name,pattern,remove_worker_logs,# TODO: Remove "user" in next major versionuser or storm_options["sudo_user"],remove_all_artifacts,hosts=env.storm_workers,)
| 3
| 28
| 9
| 127
| 2
| 45
| 74
| 45
| null |
['storm_options', 'topology_class']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (remove_logs) defined within the public class called public.The function start at line 45 and ends at 74. It contains 28 lines of code and it has a cyclomatic complexity of 3. It takes 9 parameters, represented as [45.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("remove_logs", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)subparser.add_argument("-A","--remove_all_artifacts",help="Remove not only topology-specific logs, but ""also any other files for the topology in its ""workers-artifacts subdirectories.",action="store_true",)add_config(subparser)add_environment(subparser)add_name(subparser)add_override_name(subparser)add_pattern(subparser)add_pool_size(subparser)add_user(subparser, allow_short=True)subparser.add_argument("-w","--remove_worker_logs",help="Remove not only topology-specific logs, but ""also worker logs that may be shared between ""topologies.",action="store_true",)
| 1
| 28
| 1
| 102
| 1
| 77
| 105
| 77
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 77 and ends at 105. It contains 28 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" Remove logs from Storm workers. """env.pool_size = args.pool_sizeremove_logs(topology_name=args.name,env_name=args.environment,pattern=args.pattern,remove_worker_logs=args.remove_worker_logs,options=args.options,override_name=args.override_name,remove_all_artifacts=args.remove_all_artifacts,config_file=args.config,)
| 1
| 12
| 1
| 64
| 0
| 108
| 120
| 108
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 108 and ends at 120. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
run_local_topology
|
def run_local_topology(name=None, env_name=None, time=0, options=None, config_file=None):"""Run a topology locally using Flux and `storm jar`."""name, topology_file = get_topology_definition(name, config_file=config_file)config = get_config(config_file=config_file)env_name, env_config = get_env_config(env_name, config_file=config_file)topology_class = get_topology_from_file(topology_file)set_topology_serializer(env_config, config, topology_class)storm_options = resolve_options(options, env_config, topology_class, name, local_only=True)if storm_options["topology.acker.executors"] != 0:storm_options["topology.acker.executors"] = 1storm_options["topology.workers"] = 1# Set parallelism based on env_name if necessaryfor spec in topology_class.specs:if isinstance(spec.par, dict):spec.par = spec.par.get(env_name)# Check Storm version is the samelocal_version = local_storm_version()project_version = storm_lib_version()if local_version != project_version:raise ValueError("Local Storm version, {}, is not the same as the ""version in your project.clj, {}. The versions must ""match.".format(local_version, project_version))# Prepare a JAR that has Storm dependencies packagedtopology_jar = jar_for_deploy(simple_jar=False)if time <= 0:time = 9223372036854775807# Max long value in Java# Write YAML filewith show("output"):with NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as yaml_file:topology_flux_dict = topology_class.to_flux_dict(name)topology_flux_dict["config"] = storm_optionsif yaml.version_info < (0, 15):yaml.safe_dump(topology_flux_dict, yaml_file, default_flow_style=False)else:yml = yaml.YAML(typ="safe", pure=True)yml.default_flow_style = Falseyml.dump(topology_flux_dict, yaml_file)cmd = ("storm jar {jar} org.apache.storm.flux.Flux --local --no-splash ""--sleep {time} {yaml}".format(jar=topology_jar, time=time, yaml=yaml_file.name))local(cmd)
| 7
| 45
| 5
| 297
| 10
| 37
| 93
| 37
| null |
['project_version', 'local_version', 'config', 'storm_options', 'topology_flux_dict', 'topology_class', 'time', 'cmd', 'topology_jar', 'yml']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (run_local_topology) defined within the public class called public.The function start at line 37 and ends at 93. It contains 45 lines of code and it has a cyclomatic complexity of 7. It takes 5 parameters, represented as [37.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("run",description=__doc__,help=main.__doc__,formatter_class=RawDescriptionHelpFormatter,)subparser.set_defaults(func=main)add_ackers(subparser)add_config(subparser)add_debug(subparser)add_environment(subparser)add_name(subparser)add_options(subparser)subparser.add_argument("-t","--time",default=0,type=int,help="Time (in seconds) to keep local cluster ""running. If time <= 0, run indefinitely. ""(default: %(default)s)",)add_workers(subparser)
| 1
| 24
| 1
| 88
| 1
| 96
| 120
| 96
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 96 and ends at 120. It contains 24 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):"""Run the local topology with the given arguments"""run_local_topology(name=args.name,time=args.time,options=args.options,env_name=args.environment,config_file=args.config,)
| 1
| 8
| 1
| 39
| 0
| 123
| 131
| 123
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 123 and ends at 131. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
subparser_hook
|
def subparser_hook(subparsers):""" Hook to add subparser for this command. """subparser = subparsers.add_parser("slot_usage", description=__doc__, help=main.__doc__)subparser.set_defaults(func=main)add_config(subparser)add_environment(subparser)
| 1
| 7
| 1
| 40
| 1
| 13
| 20
| 13
| null |
['subparser']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (subparser_hook) defined within the public class called public.The function start at line 13 and ends at 20. It contains 7 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
display_slot_usage
|
def display_slot_usage(env_name, config_file=None):print("Querying Storm UI REST service for slot usage stats (this can take a while)...")topology_summary_path = "/api/v1/topology/summary"topology_detail_path = "/api/v1/topology/{topology}"component_path = "/api/v1/topology/{topology}/component/{component}"topo_summary_json = get_ui_json(env_name, topology_summary_path, config_file=config_file)topology_ids = [x["id"] for x in topo_summary_json["topologies"]]# Keep track of the number of workers used by each topology on each machinetopology_worker_ports = defaultdict(lambda: defaultdict(set))topology_executor_counts = defaultdict(Counter)topology_names = set()topology_components = dict()topology_detail_jsons = get_ui_jsons(env_name,(topology_detail_path.format(topology=topology) for topology in topology_ids),config_file=config_file,)for topology in topology_ids:topology_detail_json = topology_detail_jsons[topology_detail_path.format(topology=topology)]spouts = [x["spoutId"] for x in topology_detail_json["spouts"]]bolts = [x["boltId"] for x in topology_detail_json["bolts"]]topology_components[topology] = spouts + boltscomp_details = get_ui_jsons(env_name,(component_path.format(topology=topology, component=comp)for topology, comp_list in topology_components.items()for comp in comp_list),config_file=config_file,)for request_url, comp_detail in comp_details.items():topology = request_url.split("/")[4]topology_detail_json = topology_detail_jsons[topology_detail_path.format(topology=topology)]for worker in comp_detail["executorStats"]:topology_worker_ports[worker["host"]][topology_detail_json["name"]].add(worker["port"])topology_executor_counts[worker["host"]][topology_detail_json["name"]] += 1topology_names.add(topology_detail_json["name"])topology_names = sorted(topology_names)columns = ["Host"] + topology_namesrows = [([host]+ ["{} ({})".format(len(host_dict.get(topology, set())),topology_executor_counts[host][topology],)for topology in topology_names])for host, host_dict in sorted(topology_worker_ports.items())]print_stats_table("Slot (and Executor) Counts by Topology", rows, columns)
| 12
| 63
| 2
| 363
| 17
| 23
| 90
| 23
| null |
['rows', 'topology_detail_jsons', 'topology_names', 'topology_worker_ports', 'bolts', 'topology_components', 'topology_detail_json', 'topology', 'topo_summary_json', 'spouts', 'topology_ids', 'columns', 'topology_detail_path', 'component_path', 'topology_summary_path', 'topology_executor_counts', 'comp_details']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (display_slot_usage) defined within the public class called public.The function start at line 23 and ends at 90. It contains 63 lines of code and it has a cyclomatic complexity of 12. It takes 2 parameters, represented as [23.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main(args):""" Display slots used by every topology on the cluster. """storm_version = storm_lib_version()if storm_version >= parse_version("0.9.2-incubating"):display_slot_usage(args.environment)else:print(f"ERROR: Storm {storm_version} does not support this command.")
| 2
| 6
| 1
| 32
| 1
| 93
| 99
| 93
| null |
['storm_version']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 93 and ends at 99. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
load_subparsers
|
def load_subparsers(subparsers):"""searches modules in streamparse/bin for a 'subparser_hook' method and callsthe 'subparser_hook' method on the sparse subparsers object."""for _, mod_name, is_pkg in pkgutil.iter_modules([os.path.dirname(__file__)]):if not is_pkg and mod_name not in sys.modules:module = importlib.import_module(f"streamparse.cli.{mod_name}")# check for the subparser hookif hasattr(module, "subparser_hook"):module.subparser_hook(subparsers)
| 5
| 6
| 1
| 63
| 1
| 19
| 29
| 19
| null |
['module']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (load_subparsers) defined within the public class called public.The function start at line 19 and ends at 29. It contains 6 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main._help_command
|
def _help_command(args):"""Print help information about other commands.Does the same thing as adding --help flag to sub-command calls."""subparsers.choices[args.sub_command].print_help()sys.exit(1)
| 1
| 3
| 1
| 24
| 0
| 54
| 60
| 54
| null |
[]
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main._help_command) defined within the public class called public.The function start at line 54 and ends at 60. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
main
|
def main():"""main entry point for sparse"""parser = argparse.ArgumentParser(description="Utilities for managing Storm" "/streamparse topologies.",epilog="sparse provides a front-end to ""streamparse, a framework for ""creating Python projects for ""running, debugging, and ""submitting computation topologies ""against real-time streams, using ""Apache Storm. It requires java and"" lein (Clojure build tool) to be ""on your $PATH, and uses lein and ""Clojure under the hood for JVM/""Thrift interop.",)subparsers = parser.add_subparsers(title="sub-commands")parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")load_subparsers(subparsers)def _help_command(args):"""Print help information about other commands.Does the same thing as adding --help flag to sub-command calls."""subparsers.choices[args.sub_command].print_help()sys.exit(1)help_parser = subparsers.add_parser("help",description=_help_command.__doc__,help=_help_command.__doc__.splitlines()[0],)help_parser.add_argument("sub_command",help="The command to provide help for.",choices=sorted(subparsers.choices.keys()),)help_parser.set_defaults(func=_help_command)args = parser.parse_args()if os.getuid() == 0 and not os.getenv("LEIN_ROOT"):die("Because streamparse relies on Leiningen, you cannot run ""streamparse as root without the LEIN_ROOT environment variable ""set. Otherwise, Leiningen would hang indefinitely under-the-hood ""waiting for user input.")# http://grokbase.com/t/python/python-bugs-list/12arsq9ayf/issue16308-undocumented-behaviour-change-in-argparse-from-3-2-3-to-3-3-0if hasattr(args, "func"):args.func(args)# python3.3+ argparse changeselse:parser.print_help()sys.exit(1)
| 4
| 45
| 0
| 180
| 4
| 32
| 89
| 32
| null |
['parser', 'args', 'help_parser', 'subparsers']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (main) defined within the public class called public.The function start at line 32 and ends at 89. It contains 45 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
display_stats
|
def display_stats(env_name,topology_name=None,component_name=None,all_components=None,config_file=None,):env_name = env_nameif topology_name and all_components:_print_all_components(env_name, topology_name, config_file=config_file)elif topology_name and component_name:_print_component_status(env_name, topology_name, component_name, config_file=config_file)elif topology_name:_print_topology_status(env_name, topology_name, config_file=config_file)else:_print_cluster_status(env_name, config_file=config_file)
| 6
| 18
| 5
| 80
| 1
| 20
| 37
| 20
| null |
['env_name']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (display_stats) defined within the public class called public.The function start at line 20 and ends at 37. It contains 18 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [20.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_print_cluster_status
|
def _print_cluster_status(env_name, config_file=None):jsons = get_ui_jsons(env_name,["/api/v1/cluster/summary","/api/v1/topology/summary","/api/v1/supervisor/summary",],config_file=config_file,)# Print Cluster Summaryui_cluster_summary = jsons["/api/v1/cluster/summary"]columns = ["stormVersion","nimbusUptime","supervisors","slotsTotal","slotsUsed","slotsFree","executorsTotal","tasksTotal",]print_stats_table("Cluster summary", ui_cluster_summary, columns, "r")# Print Topologies Summaryui_topologies_summary = jsons["/api/v1/topology/summary"]columns = ["name","id","status","uptime","workersTotal","executorsTotal","tasksTotal",]print_stats_table("Topology summary", ui_topologies_summary["topologies"], columns, "r")# Print Supervisor Summaryui_supervisor_summary = jsons["/api/v1/supervisor/summary"]columns = ["id", "host", "uptime", "slotsTotal", "slotsUsed"]print_stats_table("Supervisor summary",ui_supervisor_summary["supervisors"],columns,"r",{"host": "l", "uptime": "l"},)
| 1
| 44
| 2
| 145
| 5
| 40
| 86
| 40
| null |
['jsons', 'ui_topologies_summary', 'ui_cluster_summary', 'columns', 'ui_supervisor_summary']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_print_cluster_status) defined within the public class called public.The function start at line 40 and ends at 86. It contains 44 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [40.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_get_topology_ui_detail
|
def _get_topology_ui_detail(env_name, topology_name, config_file=None):env_name = get_env_config(env_name, config_file=config_file)[0]topology_id = _get_topology_id(env_name, topology_name)detail_url = f"/api/v1/topology/{topology_id}"detail = get_ui_json(env_name, detail_url, config_file=config_file)return detail
| 1
| 6
| 3
| 50
| 4
| 89
| 94
| 89
| null |
['detail', 'topology_id', 'detail_url', 'env_name']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_get_topology_ui_detail) defined within the public class called public.The function start at line 89 and ends at 94. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [89.0] and does not return any value..
|
pystorm_streamparse
|
public
|
public
| 0
| 0
|
_print_topology_status
|
def _print_topology_status(env_name, topology_name, config_file=None):ui_detail = _get_topology_ui_detail(env_name, topology_name, config_file=config_file)# Print topology summarycolumns = ["name","id","status","uptime","workersTotal","executorsTotal","tasksTotal",]print_stats_table("Topology summary", ui_detail, columns, "r")# Print topology statscolumns = ["windowPretty","emitted","transferred","completeLatency","acked","failed",]print_stats_table("Topology stats", ui_detail["topologyStats"], columns, "r")# Print spoutsif ui_detail.get("spouts"):columns = ["spoutId","emitted","transferred","completeLatency","acked","failed",]print_stats_table("Spouts (All time)", ui_detail["spouts"], columns, "r", {"spoutId": "l"})columns = ["boltId","executors","tasks","emitted","transferred","capacity","executeLatency","executed","processLatency","acked","failed","lastError",]print_stats_table("Bolt (All time)", ui_detail["bolts"], columns, "r", {"boltId": "l"})
| 2
| 52
| 3
| 170
| 2
| 97
| 152
| 97
| null |
['ui_detail', 'columns']
|
None
| null | 0
| 0
| 0
| null | 0
| null |
The function (_print_topology_status) defined within the public class called public.The function start at line 97 and ends at 152. It contains 52 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [97.0] and does not return any value..
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.