How to use the tabpy.tabpy_tools.rest.RESTProperty function in tabpy

To help you get started, we’ve selected a few tabpy 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 tableau / TabPy / tests / unit / tools_tests / test_rest_object.py View on Github external
def test_new_class(self):
        class FooObject(RESTObject):
            f = RESTProperty(float)
            i = RESTProperty(int)
            s = RESTProperty(str)
            e = RESTProperty(enum("a", "b"))

        f = FooObject(f="6.0", i="3", s="hello!")
        self.assertEqual(f.f, 6.0)
        self.assertEqual(f.i, 3)
        self.assertEqual(f.s, "hello!")

        with self.assertRaises(AttributeError):
            f.e

        self.assertEqual(f["f"], 6.0)
        self.assertEqual(f["i"], 3)
        self.assertEqual(f["s"], "hello!")

        with self.assertRaises(KeyError):
github tableau / TabPy / tests / unit / tools_tests / test_rest_object.py View on Github external
def test_new_class(self):
        class FooObject(RESTObject):
            f = RESTProperty(float)
            i = RESTProperty(int)
            s = RESTProperty(str)
            e = RESTProperty(enum("a", "b"))

        f = FooObject(f="6.0", i="3", s="hello!")
        self.assertEqual(f.f, 6.0)
        self.assertEqual(f.i, 3)
        self.assertEqual(f.s, "hello!")

        with self.assertRaises(AttributeError):
            f.e

        self.assertEqual(f["f"], 6.0)
        self.assertEqual(f["i"], 3)
        self.assertEqual(f["s"], "hello!")
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
required_files : str

        The local file path to the directory containing the
        required files.

    required_packages : str

        The local file path to the directory containing the
        required packages.

    """

    src_path = RESTProperty(str)
    required_files = RESTProperty(list)
    required_packages = RESTProperty(list)
    required_packages_dst_path = RESTProperty(str)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.type = "model"

    def __eq__(self, other):
        return (
            super().__eq__(other)
            and self.required_files == other.required_files
            and self.required_packages == other.required_packages
        )


class AliasEndpoint(Endpoint):
    """Represents an alias Endpoint.
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
required_files : str

        The local file path to the directory containing the
        required files.

    required_packages : str

        The local file path to the directory containing the
        required packages.

    """

    src_path = RESTProperty(str)
    required_files = RESTProperty(list)
    required_packages = RESTProperty(list)
    required_packages_dst_path = RESTProperty(str)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.type = "model"

    def __eq__(self, other):
        return (
            super().__eq__(other)
            and self.required_files == other.required_files
            and self.required_packages == other.required_packages
        )


class AliasEndpoint(Endpoint):
    """Represents an alias Endpoint.
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
dependencies: list
        A list of endpoints that this endpoint depends on.
    methods : list
        ???
    """

    name = RESTProperty(str)
    type = RESTProperty(str)
    version = RESTProperty(int)
    description = RESTProperty(str)
    dependencies = RESTProperty(list)
    methods = RESTProperty(list)
    creation_time = RESTProperty(datetime, from_epoch, to_epoch)
    last_modified_time = RESTProperty(datetime, from_epoch, to_epoch)
    evaluator = RESTProperty(str)
    schema_version = RESTProperty(int)
    schema = RESTProperty(str)

    def __new__(cls, **kwargs):
        """Dispatch to the appropriate class."""
        cls = {"alias": AliasEndpoint, "model": ModelEndpoint,}[kwargs["type"]]

        """return object.__new__(cls, **kwargs)"""
        """ modified for Python 3"""
        return object.__new__(cls)

    def __eq__(self, other):
        return (
            self.name == other.name
            and self.type == other.type
            and self.version == other.version
            and self.description == other.description
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
type : str
        The type of endpoint. The types include "alias", "model".
    version : int
        The version of this endpoint. Initial versions have version on 1. New
        versions increment this by 1.
    description : str
        A human-readable description of the endpoint.
    dependencies: list
        A list of endpoints that this endpoint depends on.
    methods : list
        ???
    """

    name = RESTProperty(str)
    type = RESTProperty(str)
    version = RESTProperty(int)
    description = RESTProperty(str)
    dependencies = RESTProperty(list)
    methods = RESTProperty(list)
    creation_time = RESTProperty(datetime, from_epoch, to_epoch)
    last_modified_time = RESTProperty(datetime, from_epoch, to_epoch)
    evaluator = RESTProperty(str)
    schema_version = RESTProperty(int)
    schema = RESTProperty(str)

    def __new__(cls, **kwargs):
        """Dispatch to the appropriate class."""
        cls = {"alias": AliasEndpoint, "model": ModelEndpoint,}[kwargs["type"]]

        """return object.__new__(cls, **kwargs)"""
        """ modified for Python 3"""
        return object.__new__(cls)
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
The local file path to the source of this object.

    required_files : str

        The local file path to the directory containing the
        required files.

    required_packages : str

        The local file path to the directory containing the
        required packages.

    """

    src_path = RESTProperty(str)
    required_files = RESTProperty(list)
    required_packages = RESTProperty(list)
    required_packages_dst_path = RESTProperty(str)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.type = "model"

    def __eq__(self, other):
        return (
            super().__eq__(other)
            and self.required_files == other.required_files
            and self.required_packages == other.required_packages
        )

github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
The type of endpoint. The types include "alias", "model".
    version : int
        The version of this endpoint. Initial versions have version on 1. New
        versions increment this by 1.
    description : str
        A human-readable description of the endpoint.
    dependencies: list
        A list of endpoints that this endpoint depends on.
    methods : list
        ???
    """

    name = RESTProperty(str)
    type = RESTProperty(str)
    version = RESTProperty(int)
    description = RESTProperty(str)
    dependencies = RESTProperty(list)
    methods = RESTProperty(list)
    creation_time = RESTProperty(datetime, from_epoch, to_epoch)
    last_modified_time = RESTProperty(datetime, from_epoch, to_epoch)
    evaluator = RESTProperty(str)
    schema_version = RESTProperty(int)
    schema = RESTProperty(str)

    def __new__(cls, **kwargs):
        """Dispatch to the appropriate class."""
        cls = {"alias": AliasEndpoint, "model": ModelEndpoint,}[kwargs["type"]]

        """return object.__new__(cls, **kwargs)"""
        """ modified for Python 3"""
        return object.__new__(cls)
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
version : int
        The version of this endpoint. Initial versions have version on 1. New
        versions increment this by 1.
    description : str
        A human-readable description of the endpoint.
    dependencies: list
        A list of endpoints that this endpoint depends on.
    methods : list
        ???
    """

    name = RESTProperty(str)
    type = RESTProperty(str)
    version = RESTProperty(int)
    description = RESTProperty(str)
    dependencies = RESTProperty(list)
    methods = RESTProperty(list)
    creation_time = RESTProperty(datetime, from_epoch, to_epoch)
    last_modified_time = RESTProperty(datetime, from_epoch, to_epoch)
    evaluator = RESTProperty(str)
    schema_version = RESTProperty(int)
    schema = RESTProperty(str)

    def __new__(cls, **kwargs):
        """Dispatch to the appropriate class."""
        cls = {"alias": AliasEndpoint, "model": ModelEndpoint,}[kwargs["type"]]

        """return object.__new__(cls, **kwargs)"""
        """ modified for Python 3"""
        return object.__new__(cls)

    def __eq__(self, other):
github tableau / TabPy / tabpy / tabpy_tools / rest_client.py View on Github external
A list of endpoints that this endpoint depends on.
    methods : list
        ???
    """

    name = RESTProperty(str)
    type = RESTProperty(str)
    version = RESTProperty(int)
    description = RESTProperty(str)
    dependencies = RESTProperty(list)
    methods = RESTProperty(list)
    creation_time = RESTProperty(datetime, from_epoch, to_epoch)
    last_modified_time = RESTProperty(datetime, from_epoch, to_epoch)
    evaluator = RESTProperty(str)
    schema_version = RESTProperty(int)
    schema = RESTProperty(str)

    def __new__(cls, **kwargs):
        """Dispatch to the appropriate class."""
        cls = {"alias": AliasEndpoint, "model": ModelEndpoint,}[kwargs["type"]]

        """return object.__new__(cls, **kwargs)"""
        """ modified for Python 3"""
        return object.__new__(cls)

    def __eq__(self, other):
        return (
            self.name == other.name
            and self.type == other.type
            and self.version == other.version
            and self.description == other.description
            and self.dependencies == other.dependencies