Skip to content

Commit

Permalink
Fix issue where update_virtualenv would ignore virtualenv flags
Browse files Browse the repository at this point in the history
This fixes #281.
  • Loading branch information
dan-blanchard committed Jul 26, 2016
1 parent 552c344 commit ebd3af1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions streamparse/cli/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ def submit_topology(name=None, env_name="prod", workers=None, ackers=None,
create_or_update_virtualenvs(
env_name,
name,
"{}/{}.txt".format(config["virtualenv_specs"], name),
virtualenv_flags=env_config.get('virtualenv_flags'))
"{}/{}.txt".format(config["virtualenv_specs"], name))
streamparse_run_path = '/'.join([env.virtualenv_root, name, 'bin',
'streamparse_run'])
# Update python paths in bolts
Expand Down
19 changes: 12 additions & 7 deletions streamparse/cli/update_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from fabric.contrib.files import exists

from .common import add_environment, add_name
from ..util import activate_env, die, get_config, get_topology_definition
from ..util import (activate_env, die, get_config, get_env_config,
get_topology_definition)


@parallel
Expand Down Expand Up @@ -42,8 +43,7 @@ def _create_or_update_virtualenv(virtualenv_root,
run("rm {}".format(tmpfile))


def create_or_update_virtualenvs(env_name, topology_name, requirements_file,
virtualenv_flags=None):
def create_or_update_virtualenvs(env_name, topology_name, requirements_file):
"""Create or update virtualenvs on remote servers.
Assumes that virtualenv is on the path of the remote server(s).
Expand All @@ -53,6 +53,10 @@ def create_or_update_virtualenvs(env_name, topology_name, requirements_file,
:param requirements_file: path to the requirements.txt file to use
to update/install this virtualenv.
"""
topology_name = get_topology_definition(topology_name)[0]
env_name, env_config = get_env_config(env_name)

# Setup the fabric env dictionary
activate_env(env_name)
# Check to ensure streamparse is in requirements
with open(requirements_file, "r") as fp:
Expand All @@ -68,7 +72,8 @@ def create_or_update_virtualenvs(env_name, topology_name, requirements_file,
.format(requirements_file))

execute(_create_or_update_virtualenv, env.virtualenv_root, topology_name,
requirements_file, virtualenv_flags=virtualenv_flags,
requirements_file,
virtualenv_flags=env_config.get('virtualenv_flags'),
hosts=env.storm_workers)


Expand All @@ -84,9 +89,9 @@ def subparser_hook(subparsers):

def main(args):
""" Create or update a virtualenv on Storm workers. """
name = get_topology_definition(args.name)[0]
topology_name = get_topology_definition(args.name)[0]
config = get_config()
config["virtualenv_specs"] = config["virtualenv_specs"].rstrip("/")
create_or_update_virtualenvs(args.environment, name,
create_or_update_virtualenvs(args.environment, topology_name,
"{}/{}.txt".format(config["virtualenv_specs"],
name))
topology_name))

0 comments on commit ebd3af1

Please sign in to comment.