Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added virtualenv_name config #373

Merged
merged 4 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ If you would like to pass command-line flags to virtualenv, you can set
Note that this only applies when the virtualenv is created, not when an
existing virtualenv is used.

If you would like to share a single virtualenv across topologies, you can set
``"virtualenv_name"`` in ``config.json`` which overrides the default behaviour
of using the topology name for virtualenv. Updates to a shared virtualenv should
be done after shutting down topologies, as code changes in running topologies
may cause errors.

Using unofficial versions of Storm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 3 additions & 2 deletions streamparse/cli/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ def submit_topology(name=None, env_name=None, options=None, force=False,

# If using virtualenv, set it up, and make sure paths are correct in specs
if use_venv:
virtualenv_name = env_config.get('virtualenv_name', override_name)
if install_venv:
create_or_update_virtualenvs(env_name, name,
override_name=override_name,
virtualenv_name=virtualenv_name,
requirements_paths=requirements_paths)
streamparse_run_path = '/'.join([env.virtualenv_root, override_name,
streamparse_run_path = '/'.join([env.virtualenv_root, virtualenv_name,
'bin', 'streamparse_run'])
# Update python paths in bolts
for thrift_bolt in itervalues(topology_class.thrift_bolts):
Expand Down
12 changes: 6 additions & 6 deletions streamparse/cli/update_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@ def _create_or_update_virtualenv(virtualenv_root,
run("rm {}".format(temp_req))


def create_or_update_virtualenvs(env_name, topology_name, override_name=None,
def create_or_update_virtualenvs(env_name, topology_name, virtualenv_name=None,
requirements_paths=None):
"""Create or update virtualenvs on remote servers.

Assumes that virtualenv is on the path of the remote server(s).

:param env_name: the name of the environment in config.json.
:param topology_name: the name of the topology (and virtualenv).
:param override_name: the name that we should use for the virtualenv, even
:param virtualenv_name: the name that we should use for the virtualenv, even
though the topology file has a different name.
:param requirements_paths: a list of paths to requirements files to use to
create virtualenv
"""
config = get_config()
topology_name = get_topology_definition(topology_name)[0]
env_name, env_config = get_env_config(env_name)
if override_name is None:
override_name = topology_name
if virtualenv_name is None:
virtualenv_name = topology_name

config["virtualenv_specs"] = config["virtualenv_specs"].rstrip("/")

Expand All @@ -94,7 +94,7 @@ def create_or_update_virtualenvs(env_name, topology_name, override_name=None,
activate_env(env_name)

# Actually create or update virtualenv on worker nodes
execute(_create_or_update_virtualenv, env.virtualenv_root, override_name,
execute(_create_or_update_virtualenv, env.virtualenv_root, virtualenv_name,
requirements_paths,
virtualenv_flags=env_config.get('virtualenv_flags'),
hosts=env.storm_workers)
Expand All @@ -115,5 +115,5 @@ def subparser_hook(subparsers):
def main(args):
""" Create or update a virtualenv on Storm workers. """
create_or_update_virtualenvs(args.environment, args.name,
override_name=args.override_name,
virtualenv_name=args.override_name,
requirements_paths=args.requirements)