Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
project = current_slug
# From .jovianrc file
else:
project = get_notebook_slug(filename)
# Skip if project is not provided & can't be read
if project is None:
return None, None
# Get project metadata for UUID & username/title
if is_uuid(project):
project_title = None
metadata = api.get_gist(project)
elif '/' in project:
project_title = project.split('/')[1]
username = api.get_current_user()['username']
metadata = api.get_gist(project)
# Attach username to the title
else:
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']
# Skip if project is not provided & can't be read
if project is None:
return None, None
# Get project metadata for UUID & username/title
if is_uuid(project):
project_title = None
metadata = api.get_gist(project)
elif '/' in project:
project_title = project.split('/')[1]
username = api.get_current_user()['username']
metadata = api.get_gist(project)
# Attach username to the title
else:
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
def perform_kaggle_commit(message,
files,
outputs,
environment,
privacy,
project,
new_project):
""" Retreive all cells and writes it to a file called project-name.ipynb, then returns the filename"""
# Get user profile
user = get_current_user()['username']
# Construct and print URL
url = read_cred(WEBAPP_URL_KEY, DEFAULT_WEBAPP_URL) + user + "/" + project
log("Uploading notebook to " + url)
# Construct filename
filename = "{}.ipynb".format(project.split('/')[1] if '/' in project else project)
# Handle str, None accordingly
message = "'{}'".format(message) if isinstance(message, str) else None
environment = "'{}'".format(environment) if isinstance(environment, str) else None
# Construct jovian.commit w/ parameters
jovian_commit = """jovian.commit(message={}, files={}, outputs={}, environment={}, privacy='{}', filename='{}', project='{}', new_project={})""".format(
message, files, outputs, environment, privacy, filename, project, new_project)