Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class IgnoredFiles(RenkuException):
"""Raise when trying to work with ignored files."""
def __init__(self, ignored):
"""Build a custom message."""
super(IgnoredFiles, self).__init__(
'The following paths are ignored by one of your .gitignore files:'
'\n\n' + '\n'.
join('\t' + click.style(path, fg='yellow')
for path in ignored) + '\n'
'Please use the "--force" option if you really want to add them.'
)
class MigrationRequired(RenkuException):
"""Raise when migration is required."""
def __init__(self, resource_type):
"""Build a custom message."""
super(MigrationRequired, self).__init__(
'Broken resource of type `{0}` found.\n'
'Migration is required.\n'
'Please check `renku migrate --help` '
'command to fix the issue.\n'
'Hint: `renku migrate datasets`'.format(resource_type)
)
class NothingToCommit(RenkuException):
"""Raise when there is nothing to commit."""
class DirtyRepository(RenkuException):
"""Raise when trying to work with dirty repository."""
def __init__(self, repo):
"""Build a custom message."""
super(DirtyRepository, self).__init__(
'The repository is dirty. '
'Please use the "git" command to clean it.'
'\n\n' + str(repo.git.status()) + '\n\n'
'Once you have added the untracked files, '
'commit them with "git commit".'
)
class DirtyRenkuDirectory(RenkuException):
"""Raise when a directory in the renku repository is dirty."""
def __init__(self, repo):
"""Build a custom message."""
super(DirtyRenkuDirectory, self).__init__((
'The renku directory {0} contains uncommitted changes.\n'
'Please use "git" command to resolve.\n'
'Files within {0} directory '
'need to be manually committed or removed.'
).format(RENKU_HOME) + '\n\n' + str(repo.git.status()) + '\n\n')
class IgnoredFiles(RenkuException):
"""Raise when trying to work with ignored files."""
def __init__(self, ignored):
super(InvalidAccessToken, self).__init__(msg)
class GitError(RenkuException):
"""Raised when a remote Git repo cannot be accessed."""
class UrlSchemeNotSupported(RenkuException):
"""Raised when adding data from unsupported URL schemes."""
class OperationError(RenkuException):
"""Raised when an operation at runtime raises an error."""
class SHACLValidationError(RenkuException):
"""Raises when SHACL validation of the graph fails."""
'\nYou can use --output flag to specify outputs explicitly.'
)
else:
msg += (
'\n\nIf you want to track the command anyway use '
'--no-output option.'
)
super(OutputsNotFound, self).__init__(msg)
class InvalidInputPath(RenkuException):
"""Raise when input path does not exist or is not in the repository."""
class InvalidSuccessCode(RenkuException):
"""Raise when the exit-code is not 0 or redefined."""
def __init__(self, returncode, success_codes=None):
"""Build a custom message."""
if not success_codes:
msg = 'Command returned non-zero exit status {0}.'.format(
returncode
)
else:
msg = (
'Command returned {0} exit status, but it expects {1}'.format(
returncode,
', '.join((str(code) for code in success_codes))
)
)
super(InvalidSuccessCode, self).__init__(msg)
def __init__(self, message=None):
"""Build a custom message."""
message = message or (
'The email address is not configured. '
'Please use the "git config" command to configure it.\n\n'
'\tgit config --set user.email "john.doe@example.com"\n'
)
super().__init__(message)
class AuthenticationError(RenkuException):
"""Raise when there is a problem with authentication."""
class DirtyRepository(RenkuException):
"""Raise when trying to work with dirty repository."""
def __init__(self, repo):
"""Build a custom message."""
super(DirtyRepository, self).__init__(
'The repository is dirty. '
'Please use the "git" command to clean it.'
'\n\n' + str(repo.git.status()) + '\n\n'
'Once you have added the untracked files, '
'commit them with "git commit".'
)
class DirtyRenkuDirectory(RenkuException):
"""Raise when a directory in the renku repository is dirty."""
'\t' + click.style(path, fg='yellow') for path in paths
) + '\n\n'
'Once you have removed files that should be used as outputs,\n'
'you can safely rerun the previous command.'
'\nYou can use --output flag to specify outputs explicitly.'
)
else:
msg += (
'\n\nIf you want to track the command anyway use '
'--no-output option.'
)
super(OutputsNotFound, self).__init__(msg)
class InvalidInputPath(RenkuException):
"""Raise when input path does not exist or is not in the repository."""
class InvalidSuccessCode(RenkuException):
"""Raise when the exit-code is not 0 or redefined."""
def __init__(self, returncode, success_codes=None):
"""Build a custom message."""
if not success_codes:
msg = 'Command returned non-zero exit status {0}.'.format(
returncode
)
else:
msg = (
'Command returned {0} exit status, but it expects {1}'.format(
returncode,
def check_siblings(graph, outputs):
"""Check that all outputs have their siblings listed."""
siblings = set()
for node in outputs:
siblings |= graph.siblings(node)
siblings = {node.path for node in siblings}
missing = siblings - {node.path for node in outputs}
if missing:
msg = (
'Include the files above in the command '
'or use the --with-siblings option.'
)
raise RenkuException(
'There are missing output siblings:\n\n'
'\t{0}\n\n{1}'.format(
'\n\t'.join(click.style(path, fg='red') for path in missing),
msg,
),
)
return outputs
super(UnmodifiedOutputs, self).__init__(
'There are no detected new outputs or changes.\n'
'\nIf any of the following files should be considered as outputs,'
'\nthey need to be removed first in order to be detected '
'correctly.'
'\n (use "git rm ..." to remove them first)'
'\n\n' + '\n'.
join('\t' + click.style(path, fg='green')
for path in unmodified) + '\n'
'\nOnce you have removed the files that should be used as outputs,'
'\nyou can safely rerun the previous command.'
'\nYou can use --output flag to specify outputs explicitly.'
)
class InvalidOutputPath(RenkuException):
"""Raise when trying to work with an invalid output path."""
class OutputsNotFound(RenkuException):
"""Raise when there are not any detected outputs in the repository."""
def __init__(self, repo, inputs):
"""Build a custom message."""
msg = 'There are not any detected outputs in the repository.'
from renku.core.models.cwl.types import File
paths = [
os.path.relpath(str(input_.default.path)) # relative to cur path
for input_ in inputs # only choose files
if isinstance(input_.default, File)
]
)
else:
message = 'Invalid parameter value: {}'.format(message)
super().__init__(message)
class InvalidFileOperation(RenkuException):
"""Raise when trying to perfrom invalid file operation."""
class UsageError(RenkuException):
"""Raise in case of unintended usage of certain function calls."""
class ConfigurationError(RenkuException):
"""Raise in case of misconfiguration."""
class MissingUsername(ConfigurationError):
"""Raise when the username is not configured."""
def __init__(self, message=None):
"""Build a custom message."""
message = message or (
'The user name is not configured. '
'Please use the "git config" command to configure it.\n\n'
'\tgit config --set user.name "John Doe"\n'
)
super(MissingUsername, self).__init__(message)
class InvalidAccessToken(RenkuException):
"""Raise when access token is incorrect."""
def __init__(self):
"""Build a custom message."""
msg = ('Invalid access token.\n' 'Please, update access token.')
super(InvalidAccessToken, self).__init__(msg)
class GitError(RenkuException):
"""Raised when a remote Git repo cannot be accessed."""
class UrlSchemeNotSupported(RenkuException):
"""Raised when adding data from unsupported URL schemes."""
class OperationError(RenkuException):
"""Raised when an operation at runtime raises an error."""
class SHACLValidationError(RenkuException):
"""Raises when SHACL validation of the graph fails."""