mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 23:47:46 +00:00
fix: rich.print error when some control char in output (#684)
* fix rich.print error when some control char in output * change conda env info printing * fix import
This commit is contained in:
+20
-20
@@ -29,7 +29,6 @@ from pydantic import BaseModel, model_validator
|
||||
from pydantic_settings import SettingsConfigDict
|
||||
from rich import print
|
||||
from rich.console import Console
|
||||
from rich.pretty import Pretty
|
||||
from rich.progress import Progress, SpinnerColumn, TextColumn
|
||||
from rich.rule import Rule
|
||||
from rich.table import Table
|
||||
@@ -307,15 +306,15 @@ class LocalEnv(Env[ASpecificLocalConf]):
|
||||
**kwargs: dict,
|
||||
) -> tuple[str, int]:
|
||||
|
||||
# mocking the volumns
|
||||
volumns = {}
|
||||
# mocking the volumes
|
||||
volumes = {}
|
||||
if self.conf.extra_volumes is not None:
|
||||
for lp, rp in self.conf.extra_volumes.items():
|
||||
volumns[lp] = rp
|
||||
volumes[lp] = rp
|
||||
for lp, rp in running_extra_volume.items():
|
||||
volumns[lp] = rp
|
||||
volumes[lp] = rp
|
||||
|
||||
for rp, lp in volumns.items():
|
||||
for rp, lp in volumes.items():
|
||||
link_path = Path(lp)
|
||||
real_path = Path(rp)
|
||||
if not link_path.parent.exists():
|
||||
@@ -333,14 +332,15 @@ class LocalEnv(Env[ASpecificLocalConf]):
|
||||
if entry is None:
|
||||
entry = self.conf.default_entry
|
||||
|
||||
summary = {
|
||||
"entry": entry,
|
||||
"local_path": local_path,
|
||||
"env": env,
|
||||
"volumes": volumns,
|
||||
}
|
||||
print(Rule("[bold green]LocalEnv Logs Begin[/bold green]", style="dark_orange"))
|
||||
print(Pretty(summary))
|
||||
table = Table(title="Run Info", show_header=False)
|
||||
table.add_column("Key", style="bold cyan")
|
||||
table.add_column("Value", style="bold magenta")
|
||||
table.add_row("Entry", entry)
|
||||
table.add_row("Local Path", local_path)
|
||||
table.add_row("Env", "\n".join(f"{k}:{v}" for k, v in env.items()))
|
||||
table.add_row("Volumes", "\n".join(f"{k}:{v}" for k, v in volumes.items()))
|
||||
print(table)
|
||||
|
||||
cwd = None
|
||||
if local_path:
|
||||
@@ -348,7 +348,7 @@ class LocalEnv(Env[ASpecificLocalConf]):
|
||||
|
||||
result = subprocess.run(entry, cwd=cwd, env={**os.environ, **env}, capture_output=True, text=True, shell=True)
|
||||
combined_output = result.stderr + result.stdout # Combine stdout and stderr
|
||||
print(combined_output) # Display the combined output in the console
|
||||
Console().print(combined_output, markup=False)
|
||||
print(Rule("[bold green]LocalEnv Logs End[/bold green]", style="dark_orange"))
|
||||
|
||||
return combined_output, result.returncode
|
||||
@@ -601,15 +601,15 @@ class DockerEnv(Env[DockerConf]):
|
||||
env["PYTHONUNBUFFERED"] = "1"
|
||||
client = docker.from_env()
|
||||
|
||||
volumns = {}
|
||||
volumes = {}
|
||||
if local_path is not None:
|
||||
local_path = os.path.abspath(local_path)
|
||||
volumns[local_path] = {"bind": self.conf.mount_path, "mode": "rw"}
|
||||
volumes[local_path] = {"bind": self.conf.mount_path, "mode": "rw"}
|
||||
if self.conf.extra_volumes is not None:
|
||||
for lp, rp in self.conf.extra_volumes.items():
|
||||
volumns[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
||||
volumes[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
||||
for lp, rp in running_extra_volume.items():
|
||||
volumns[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
||||
volumes[lp] = {"bind": rp, "mode": self.conf.extra_volume_mode}
|
||||
|
||||
log_output = ""
|
||||
|
||||
@@ -617,7 +617,7 @@ class DockerEnv(Env[DockerConf]):
|
||||
container: docker.models.containers.Container = client.containers.run( # type: ignore[no-any-unimported]
|
||||
image=self.conf.image,
|
||||
command=entry,
|
||||
volumes=volumns,
|
||||
volumes=volumes,
|
||||
environment=env,
|
||||
detach=True,
|
||||
working_dir=self.conf.mount_path,
|
||||
@@ -637,7 +637,7 @@ class DockerEnv(Env[DockerConf]):
|
||||
table.add_row("Container Name", container.name)
|
||||
table.add_row("Entry", entry)
|
||||
table.add_row("Env", "\n".join(f"{k}:{v}" for k, v in env.items()))
|
||||
table.add_row("Volumns", "\n".join(f"{k}:{v}" for k, v in volumns.items()))
|
||||
table.add_row("Volumes", "\n".join(f"{k}:{v}" for k, v in volumes.items()))
|
||||
print(table)
|
||||
for log in logs:
|
||||
decoded_log = log.strip().decode()
|
||||
|
||||
Reference in New Issue
Block a user