コード例 #1
0
def exec_init():
    from jovian.utils.api import get_api_key
    from jovian.utils.credentials import get_guest_key
    # webbrowser.open('https://jvn.io/')
    get_guest_key()
    get_api_key()
    print('Initialization finished')
コード例 #2
0
def configure():
    """Configure Jovian for first time usage"""
    # Check if already exists
    if creds_exist():
        log('It looks like Jovian is already configured ( check ~/.jovian/credentials.json ).')
        msg = 'Do you want to overwrite the existing configuration?'
        confirm = click.confirm(msg)

        if confirm:
            log('Removing existing configuration..')
        else:
            log('Skipping..')
            return

    # Remove existing credentials
    purge_creds()

    # Capture and save organization ID
    ensure_org(check_pro=False)

    # Ask for API Key
    get_guest_key()
    get_api_key()

    log('Configuration complete!')
コード例 #3
0
ファイル: api.py プロジェクト: vaishnavipatil29/jovian-py
def _h():
    """Create authorization header with API key"""
    return {"Authorization": "Bearer " + get_api_key(),
            "x-jovian-source": "library",
            "x-jovian-library-version": __version__,
            "x-jovian-guest": get_guest_key(),
            "x-jovian-org": read_org_id()}
コード例 #4
0
ファイル: slack.py プロジェクト: vaishnavipatil29/jovian-py
def _h():
    """Create a header to provide library metadata"""
    return {"Authorization": "Bearer " + get_api_key(),
            "x-jovian-source": "library",
            "x-jovian-library-version": __version__,
            "x-jovian-command": "add-slack",
            "x-jovian-guest": get_guest_key(),
            "x-jovian-org": read_org_id()}
コード例 #5
0
def test_get_guest_key_generate_key(mock_uuid4):
    with fake_creds():
        creds = {
            "WEBAPP_URL": "https://staging.jovian.ai/",
            "ORG_ID": "staging",
            "API_URL": "https://api-staging.jovian.ai"
        }
        write_creds(creds)

        assert get_guest_key() == "b66406dc02c3471bac27d923fb4c6b1e"
コード例 #6
0
ファイル: clone.py プロジェクト: afcarl/jovian-py
def _h(fresh):
    """Create a header to provide library metadata"""
    api_key, _ = read_api_key_opt()

    headers = {"x-jovian-source": "library",
               "x-jovian-library-version": __version__,
               "x-jovian-command": "clone" if fresh else "pull",
               "x-jovian-guest": get_guest_key()}

    if api_key is not None:
        headers["Authorization"] = "Bearer " + api_key

    return headers
コード例 #7
0
def test_get_guest_key():
    with fake_creds():
        assert get_guest_key() == "b6538d4dfde04fcf993463a828a9cec6"
コード例 #8
0
def test_get_guest_key():
    with fake_creds('.jovian', 'credentials.json'):
        assert get_guest_key() == "b6538d4dfde04fcf993463a828a9cec6"