Esempio n. 1
0
def upload_conda_env(gist_slug):
    """Read and save the current Anaconda environment to server"""
    # Export environment to YML string
    env_str = read_conda_env(get_conda_env_name())

    # Upload environment.yml
    upload_file(gist_slug, ('environment.yml', env_str))

    # Check and include existing os-specific files
    platform = get_platform()
    for p in PLATFORMS:
        pfname = 'environment-' + p + '.yml'
        if p == platform:
            # Use the new environment for current platform
            upload_file(gist_slug, (pfname, env_str))
        elif os.path.exists(pfname):
            # Reuse old environments for other platforms
            upload_file(gist_slug, pfname)
Esempio n. 2
0
def identify_env_file(env_fname, folder_prefix=""):
    """Find the right conda environment file through trial and errors"""

    if env_fname is None:
        # Look for platform specific environment files (prefer current)
        platforms = [get_platform()] + ["", LINUX, WINDOWS, MACOS]
        for platform in platforms:
            if platform == "":
                expected_fname = os.path.join(folder_prefix, 'environment.yml')
            else:
                expected_fname = os.path.join(
                    folder_prefix, 'environment-' + platform + '.yml')

            if os.path.exists(expected_fname):
                env_fname = expected_fname
                break

    return env_fname
Esempio n. 3
0
def request_api_key():
    """Ask the user to provide the API key"""
    hide_api_key = in_notebook() or get_platform() != 'windows'
    log("Please enter your API key ( from " + read_webapp_url() + " ):")
    api_key = click.prompt("API KEY", hide_input=hide_api_key)
    return api_key
Esempio n. 4
0
 def test_get_platform_macos(self):
     self.assertEqual(get_platform(), MACOS)
Esempio n. 5
0
 def test_get_platform_linux(self):
     self.assertEqual(get_platform(), LINUX)
Esempio n. 6
0
 def test_get_platform_windows(self):
     self.assertEqual(get_platform(), WINDOWS)
Esempio n. 7
0
def test_get_platform(ret_val, expected_result):
    with mock.patch("platform.system", mock.Mock(return_value=ret_val)):
        assert get_platform() == expected_result