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.")
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"), }
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)
def transport(self): if not self._transport: self._transport = Transport(config=self.config) return self._transport
def setUp(self): super().setUp() self.transport = Transport()
def setUp(self): super(TestTransport, self).setUp() self.transport = Transport()