RhodiumGroup / rhg_compute_tools

Tools for using compute.rhg.com and compute.impactlab.org
MIT License
1 stars 4 forks source link

Setting environment variables on remote cluster does not work #64

Closed dallen5 closed 4 years ago

dallen5 commented 4 years ago

Description

I'm trying to set an environment variable on a remote cluster. It appears that the dictionary implementation assigning values to names is slightly off (values() should be items()). Also, the handling for the deprecated list-of-dicts implementation has a typo (isintance should be isinstance) (I am submitting a PR to resolve both issues).

What I Did

client, cluster = rhg_compute_tools.kubernetes.get_standard_cluster(
    env_items = {
        'FOO':'/path/to/bar'
    }
)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-18c512dee399> in <module>
      1 client, cluster = rhg_compute_tools.kubernetes.get_standard_cluster(
      2     env_items = {
----> 3         'FOO':'/path/to/bar'
      4     }
      5 )

~/rhg_compute_tools/rhg_compute_tools/kubernetes.py in get_standard_cluster(*args, **kwargs)
    316     """
    317 
--> 318     return get_cluster(*args, scaling_factor=1, **kwargs)
    319 
    320 

~/rhg_compute_tools/rhg_compute_tools/kubernetes.py in get_cluster(name, extra_pip_packages, extra_conda_packages, memory_gb, nthreads, cpus, cred_name, cred_path, env_items, scaling_factor, dask_config_dict, deploy_mode, idle_timeout, template_path, extra_worker_labels, extra_pod_tolerations, keep_default_tolerations, **kwargs)
    221             [
    222                 container["env"].append({"name": k, "value": v})
--> 223                 for k, v in env_items.values()
    224             ]
    225         # allow deprecated passing of list of name/value pairs

~/rhg_compute_tools/rhg_compute_tools/kubernetes.py in <listcomp>(.0)
    221             [
    222                 container["env"].append({"name": k, "value": v})
--> 223                 for k, v in env_items.values()
    224             ]
    225         # allow deprecated passing of list of name/value pairs

ValueError: too many values to unpack (expected 2)