How to use the jovian.utils.api function in jovian

To help you get started, we’ve selected a few jovian examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JovianML / jovian-py / jovian / utils / commit.py View on Github external
project,
                              new_project)
        return

    # Ensure that the file exists
    if not os.path.exists(filename):
        log('The detected/provided file "' + filename +
            '" does not exist. Please provide the correct notebook filename ' +
            'as the "filename" argument to "jovian.commit".', error=True)
        return

    # Retrieve Gist ID & title
    project_title, project_id = _parse_project(project, filename, new_project)

    # Create or update gist (with title and )
    res = api.create_gist_simple(filename, project_id, privacy, project_title, message)
    slug, owner, version, title = res['slug'], res['owner'], res['version'], res['title']
    username = owner['username']

    # Cache slug for further commits
    set_notebook_slug(filename, slug)

    # Attach environment, files and outputs
    _capture_environment(environment, slug, version)
    _attach_files(files, slug, version, exclude_files=filename)
    _attach_files(outputs, slug, version, output=True)

    if not git_message or git_message == 'auto':
        git_message = message or 'jovian commit ' + username + '/' + title + ' v' + str(version)
    _perform_git_commit(filename, git_commit, git_message)
    _attach_records(slug, version)
github JovianML / jovian-py / jovian / utils / commit.py View on Github external
def _attach_records(gist_slug, version):
    """Attached records to the current commit"""
    tracking_slugs = get_records(slug_only=True)
    if len(tracking_slugs) > 0:
        log('Attaching records (metrics, hyperparameters, dataset etc.)')
        api.post_records(gist_slug, tracking_slugs, version)
github JovianML / jovian-py / jovian / utils / commit.py View on Github external
project_title = project
        username = api.get_current_user()['username']
        metadata = api.get_gist(username + '/' + project)

    # Skip if metadata could not be found
    if not metadata:
        log('Creating a new project "' + username + '/' + project_title + '"')
        return project_title, None

    # Extract information from metadata
    username = metadata['owner']['username']
    project_title = metadata['title']
    project_id = metadata['slug']

    # Check if the current user can commit to this project
    permissions = api.get_gist_access(project_id)
    if not permissions['write']:
        return project_title, None

    # Log whether this is an update or creation
    if project_id is None:
        log('Creating a new notebook on ' + read_webapp_url())
    else:
        log('Updating notebook "' + username + "/" + project_title + '" on ' + read_webapp_url())

    return project_title, project_id