mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-03 10:27:42 +00:00
fix: fix json load error (#386)
* fix json load error * fix os.symlink error * reformat with black * fix os.symlink error * reformat with isort
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import uuid
|
||||
from abc import ABC, abstractmethod
|
||||
@@ -122,7 +123,10 @@ class FBWorkspace(Workspace):
|
||||
workspace_data_file_path = workspace_path / data_file_path.name
|
||||
if workspace_data_file_path.exists():
|
||||
workspace_data_file_path.unlink()
|
||||
os.symlink(data_file_path, workspace_data_file_path)
|
||||
if platform.system() == "Linux":
|
||||
os.symlink(data_file_path, workspace_data_file_path)
|
||||
if platform.system() == "Windows":
|
||||
os.link(data_file_path, workspace_data_file_path)
|
||||
|
||||
def inject_code(self, **files: str) -> None:
|
||||
"""
|
||||
|
||||
@@ -208,12 +208,15 @@ class DockerEnv(Env[DockerConf]):
|
||||
with Progress(SpinnerColumn(), TextColumn("{task.description}")) as p:
|
||||
task = p.add_task("[cyan]Building image...")
|
||||
for part in resp_stream:
|
||||
status_dict = json.loads(part)
|
||||
if "error" in status_dict:
|
||||
p.update(task, description=f"[red]error: {status_dict['error']}")
|
||||
raise docker.errors.BuildError(status_dict["error"], "")
|
||||
if "stream" in status_dict:
|
||||
p.update(task, description=status_dict["stream"])
|
||||
lines = part.decode("utf-8").split("\r\n")
|
||||
for line in lines:
|
||||
if line.strip():
|
||||
status_dict = json.loads(line)
|
||||
if "error" in status_dict:
|
||||
p.update(task, description=f"[red]error: {status_dict['error']}")
|
||||
raise docker.errors.BuildError(status_dict["error"], "")
|
||||
if "stream" in status_dict:
|
||||
p.update(task, description=status_dict["stream"])
|
||||
logger.info(f"Finished building the image from dockerfile: {self.conf.dockerfile_folder_path}")
|
||||
try:
|
||||
client.images.get(self.conf.image)
|
||||
|
||||
Reference in New Issue
Block a user