コード例 #1
0
ファイル: deploy.py プロジェクト: zhaohb/polyaxon
 def install_on_docker_compose(self):
     path = ComposeConfigManager.get_config_filepath()
     path = "/".join(path.split("/")[:-1])
     # Fetch docker-compose
     Transport().download(
         url=
         "https://github.com/polyaxon/polyaxon-compose/archive/master.tar.gz",
         filename=path + "/file",
         untar=True,
         delete_tar=True,
         extract_path=path,
     )
     # Move necessary info
     shutil.copy(
         path + "/polyaxon-compose-master/docker-compose.yml",
         path + "/docker-compose.yml",
     )
     shutil.copy(path + "/polyaxon-compose-master/components.env",
                 path + "/components.env")
     shutil.copy(path + "/polyaxon-compose-master/base.env",
                 path + "/base.env")
     shutil.rmtree(path + "/polyaxon-compose-master/")
     # Generate env from config
     ComposeConfigManager.set_config(self.compose.generate_env(self.config))
     Printer.print_success("Docker Compose deployment is initialised.")
     if self.dry_run:
         Printer.print_success("Polyaxon generated deployment env.")
         return
     self.docker.execute(["volume", "create", "--name=polyaxon-postgres"])
     Printer.print_success("Docker volume created.")
     self.compose.execute(["-f", path + "/docker-compose.yml", "up", "-d"])
     Printer.print_success("Deployment is running in the background.")
     Printer.print_success("You can configure your CLI by running: "
                           "polyaxon config set --host=localhost.")
コード例 #2
0
class TestTransport(BaseTestCaseTransport):
    # pylint:disable=protected-access
    def setUp(self):
        super().setUp()
        self.transport = Transport()

    def test_get_headers(self):
        assert self.transport._get_headers() == {}
        assert self.transport._get_headers({"foo": "bar"}) == {"foo": "bar"}

        self.transport.config = ClientConfig(token="token", host="host")

        assert self.transport._get_headers() == {
            "Authorization": "{} {}".format(AuthenticationTypes.TOKEN, "token")
        }
        assert self.transport._get_headers({"foo": "bar"}) == {
            "foo": "bar",
            "Authorization": "{} {}".format(AuthenticationTypes.TOKEN,
                                            "token"),
        }

        self.transport.config.authentication_type = AuthenticationTypes.INTERNAL_TOKEN
        assert self.transport._get_headers() == {
            "Authorization":
            "{} {}".format(AuthenticationTypes.INTERNAL_TOKEN, "token")
        }
        assert self.transport._get_headers({"foo": "bar"}) == {
            "foo":
            "bar",
            "Authorization":
            "{} {}".format(AuthenticationTypes.INTERNAL_TOKEN, "token"),
        }
コード例 #3
0
class TestHttpTransport(BaseTestCaseTransport):
    # pylint:disable=protected-access
    def setUp(self):
        super(TestHttpTransport, self).setUp()
        self.transport = Transport()

    def test_create_progress_callback(self):
        encoder = mock.MagicMock()
        encoder.configure_mock(len=10)
        _, progress_bar = self.transport.create_progress_callback(encoder)
        assert isinstance(progress_bar, Bar)

    def test_format_sizeof(self):
        assert self.transport.format_sizeof(10) == "10.0B"
        assert self.transport.format_sizeof(10000) == "9.8KiB"
        assert self.transport.format_sizeof(100000) == "97.7KiB"
        assert self.transport.format_sizeof(10000000) == "9.5MiB"
        assert self.transport.format_sizeof(10000000000) == "9.3GiB"

    def test_session(self):
        assert hasattr(self.transport, "_session") is False
        assert isinstance(self.transport.session, requests.Session)
        assert isinstance(self.transport._session, requests.Session)
コード例 #4
0
ファイル: client.py プロジェクト: zhaohb/polyaxon
 def transport(self):
     if not self._transport:
         self._transport = Transport(config=self.config)
     return self._transport
コード例 #5
0
 def setUp(self):
     super().setUp()
     self.transport = Transport()
コード例 #6
0
ファイル: test_transport.py プロジェクト: x10-utils/polyaxon
 def setUp(self):
     super(TestTransport, self).setUp()
     self.transport = Transport()