Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sc/branching/commands/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _show_project(self, proj: ProjectElementInterface):
proj_dir = self.top_dir / proj.path
logger.info(f"Project: {proj_dir}")
logger.info(
f"Lock Status: [bold yellow]\[{proj.lock_status or 'NORMAL'}][/]",
rf"Lock Status: [bold yellow]\[{proj.lock_status or 'NORMAL'}][/]",
extra={"markup": True}
)

Expand Down
6 changes: 3 additions & 3 deletions src/sc/branching/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def _show_project(self, proj: ProjectElementInterface):
proj_dir = self.top_dir / proj.path
logger.info(f"Project: {proj_dir}")
logger.info(
f"Lock Status: \[[bold yellow]{proj.lock_status or 'NORMAL'}[/]]",
rf"Lock Status: \[[bold yellow]{proj.lock_status or 'NORMAL'}[/]]",
extra={"markup": True}
)

if proj.groups:
groups = proj.groups.split(",")
group_str = " ".join([f"\[[bold yellow]{g}[/]]" for g in groups])
group_str = " ".join([rf"\[[bold yellow]{g}[/]]" for g in groups])
else:
group_str = "\[[red bold]No Groups[/]]"
group_str = "\\[[red bold]No Groups[/]]"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be completely honest when I did it with a raw string only and not an rf" string my vscode syntax turns the whole string red which looked horrible so I did it this way.


logger.info(f"Groups: {group_str}", extra={"markup": True})

Expand Down
13 changes: 13 additions & 0 deletions src/sc/docker/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ def _generate_docker_run_command(
else:
self._warn_x11_not_forwarded(display, xauth_line)

if max_cpu := self._get_cpu_limit():
docker_args += [f"--cpuset-cpus=0-{max_cpu}"]
Comment on lines +586 to +587

coverity_dir = Path('/opt/coverity').resolve()
if Path('/opt/coverity').is_symlink() and Path(coverity_dir).exists():
docker_args += ["-v", f"{coverity_dir}:{coverity_dir}"]
Expand Down Expand Up @@ -678,3 +681,13 @@ def _warn_x11_not_forwarded(self, display: str | None, xauth_line: str | None):
click.secho(
"WARNING: Failed to get line from xauthority.", fg="yellow")
click.secho("WARNING: X11 not forwarded into docker.", fg="yellow")

def _get_cpu_limit(self) -> int | None:
"""Get the highest CPU ID to leave at least 4 cores free."""
cpu_count = os.cpu_count() or 1

if cpu_count >= 20:
# We leave 4 cores free, but CPU IDs start from zero so minus 5
return cpu_count - 5
else:
return None
Comment on lines +687 to +693