def _download_jdk(self, version: str): context = create_context(f"{self._JDK_STACK_BASE}/{version}", self._PROFILE, self.config) jdk_attachment = pull_data(context, os=self.get_os()) jdk_path = self._jdk_path(check_path_exist=False) if jdk_path.exists(): self._delete(jdk_path) temp = Path(gettempdir()) / str(uuid4()) archive_path = temp / jdk_attachment.settings["filename"] extract_dir = temp / "output" self._download_data(jdk_attachment, archive_path) shutil.unpack_archive(str(archive_path), extract_dir=str(extract_dir)) self._add_permissions(extract_dir) list_files = list(extract_dir.iterdir()) assert len(list_files) == 1 self._move(list_files[0], jdk_path) self._delete(temp)
def test_with_schema(self): md = Markdown("Test *markdown*") ds.push("test/md", md) frame_data = ds.pull_data(ds.create_context("test/md")) self.assertEqual("text/markdown", frame_data.content_type) self.assertEqual("markdown", frame_data.application) self.assertEqual(md.text, frame_data.data.value().decode("utf-8"))
def _update(self, download: bool) -> bool: context = create_context(self._STACK, self._PROFILE, self.config) server_attachment = pull_data(context, meta={"base_version": parse_version(dstack_version).base_version}) server_version = server_attachment.params["version"] jdk_version = server_attachment.params["jdk_version"] jdk_compatible_versions = server_attachment.params["jdk_compatible_versions"].split(",") jar_file = self.jar_path() is_newer_version = self._is_newer_version(server_version) or not jar_file or not jar_file.exists() if is_newer_version and download: self._save_server(server_attachment) is_jdk_version_compatible = self._is_jdk_version_compatible(jdk_compatible_versions) if not is_jdk_version_compatible and download: self._download_jdk(jdk_version) return is_newer_version or not is_jdk_version_compatible