How to use the runway.exceptions.InvalidArgumentError function in runway

To help you get started, we’ve selected a few runway 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 runwayml / model-sdk / runway / data_types.py View on Github external
def validate(self, value):
        if len(value) != 2:
            raise InvalidArgumentError(self.name, 'Value must be of length 2')
github runwayml / model-sdk / runway / data_types.py View on Github external
def validate(self, value):
        if len(value) == 4:
            left, top, right, bottom = value
            if left >= right:
                message = '%s[0] must be less than %s[2]' % (self.name, self.name)
                raise InvalidArgumentError(self.name, message)
            if top >= bottom:
                message = '%s[1] must be less than %s[3]' % (self.name, self.name)
                raise InvalidArgumentError(self.name, message)
        else:
            raise InvalidArgumentError(self.name, 'Value must be of length 4')
github runwayml / model-sdk / runway / data_types.py View on Github external
def validate(self, landmarks):
        if len(landmarks) != self.length:
            msg = 'Expected array of length {}, instead got array of length {}'.format(self.length, len(landmarks))
            raise InvalidArgumentError(self.name, msg)
        for index, point in enumerate(landmarks):
            if len(point) != 2:
                msg = 'Expected point at index {} to have 2 elements, instead got {} elements'.format(index, len(point))
                raise InvalidArgumentError(self.name, msg)
github runwayml / model-sdk / runway / data_types.py View on Github external
def validate(self, value):
        if len(value) == 4:
            left, top, right, bottom = value
            if left >= right:
                message = '%s[0] must be less than %s[2]' % (self.name, self.name)
                raise InvalidArgumentError(self.name, message)
            if top >= bottom:
                message = '%s[1] must be less than %s[3]' % (self.name, self.name)
                raise InvalidArgumentError(self.name, message)
        else:
            raise InvalidArgumentError(self.name, 'Value must be of length 4')
github runwayml / model-sdk / runway / data_types.py View on Github external
def deserialize(self, path_or_url):
        if is_url(path_or_url):
            downloaded_path = download_file(path_or_url)
            if tarfile.is_tarfile(downloaded_path):
                return extract_tarball(downloaded_path)
            else:
                return downloaded_path
        else:
            if not os.path.exists(path_or_url):
                raise InvalidArgumentError(self.name, 'file path provided does not exist')
            if self.extension and not path_or_url.endswith(self.extension):
                raise InvalidArgumentError(self.name, 'file path does not have expected extension')
            return path_or_url
github runwayml / model-sdk / runway / data_types.py View on Github external
def __init__(
        self,
        description=None,
        channels=3,
        min_width=None,
        min_height=None,
        max_width=None,
        max_height=None,
        width=None,
        height=None,
        default_output_format=None
    ):
        super(image, self).__init__('image', description=description)
        self.channels = channels
        if channels not in [1, 3, 4]:
            raise InvalidArgumentError(self.name or self.type, 'channels value needs to be 1, 3, or 4')
        if default_output_format and default_output_format not in ['JPEG', 'PNG']:
            msg = 'default_output_format needs to be JPEG or PNG'
            raise InvalidArgumentError(self.name, msg)
        if default_output_format:
            self.default_output_format = default_output_format
        elif self.channels == 3:
            self.default_output_format = 'JPEG'
        else:
            self.default_output_format = 'PNG'
        self.min_width = min_width
        self.min_height = min_height
        self.max_width = max_width
        self.max_height = max_height
        self.width = width
        self.height = height
github runwayml / model-sdk / runway / data_types.py View on Github external
def __init__(self, length, description=None, labels=None, connections=None):
        super(image_landmarks, self).__init__('image_landmarks', description=description)
        if length <= 0:
            msg = 'landmarks length must be greater than 0'
            raise InvalidArgumentError(self.name, msg)
        if labels and len(labels) != length:
            msg = 'length of labels list does not match provided length'
            raise InvalidArgumentError(self.name, msg)
        if labels is None and connections is not None:
            msg = 'connections cannot be defined if labels is undefined'
            raise InvalidArgumentError(self.name, msg)
        if connections is not None:
            for index, connection in enumerate(connections):
                if len(connection) != 2:
                    msg = 'Expected connection at index {} to have 2 elements, instead got {} elements'.format(index, len(connection))
                    raise InvalidArgumentError(self.name, msg)
                if connection[0] not in labels:
                    msg = '{} is not a valid landmark label'.format(connection[0])
                    raise InvalidArgumentError(self.name, msg)
                if connection[1] not in labels:
                    msg = '{} is not a valid landmark label'.format(connection[1])
                    raise InvalidArgumentError(self.name, msg)
        self.length = length
        self.connections = connections
        self.labels = labels