Skip to content
Merged
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "olcf-velocity"
version = "0.4.dev"
version = "0.4.0dev"
description = "A container build manager"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
6 changes: 3 additions & 3 deletions src/velocity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from velocity._config import config # noqa: E402
from velocity._graph import ImageRepo # noqa: E402
from velocity._build import ImageBuilder # noqa: E402
from velocity._print import TextBlock, header_print, indent_print # noqa: E402
from velocity._print import TextBlock, bare_print, header_print, indent_print # noqa: E402


# config functions
Expand Down Expand Up @@ -85,7 +85,7 @@ def set_distro(distro: str) -> None:

def build(
targets: str,
name: str = None,
name: str | None = None,
dry_run: bool = False,
leave_tags: bool = False,
verbose: bool = False,
Expand Down Expand Up @@ -120,7 +120,7 @@ def build(
header_print([TextBlock("Build Order:")])
for r in recipe:
indent_print([TextBlock(f"{r.name}@{r.version}-{r.id}", fore=Fore.MAGENTA, style=Style.BRIGHT)])
print() # newline
bare_print([]) # newline

# prep builder
builder = ImageBuilder(
Expand Down
14 changes: 7 additions & 7 deletions src/velocity/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from colorama import Fore, Style
from importlib.metadata import version
from loguru import logger
from networkx import neighbors as nx_neighbors
from re import fullmatch as re_fullmatch
import sys

Expand Down Expand Up @@ -159,7 +160,7 @@
recipe = imageRepo.create_build_recipe(args.targets)[0]

# print build specs
header_print([TextBlock("Build Order:")])
header_print([TextBlock("Build recipe:")])
for r in recipe:
indent_print([TextBlock(f"{r.name}@{r.version}-{r.id}", fore=Fore.MAGENTA, style=Style.BRIGHT)])
print() # newline
Expand Down Expand Up @@ -197,7 +198,7 @@
deps.sort()
for t in deps:
indent_print([TextBlock(t.version, fore=Fore.YELLOW, style=Style.BRIGHT)])
print() # add newline
bare_print([]) # add newline

elif args.subcommand == "spec":
# get recipe
Expand All @@ -207,14 +208,14 @@
flat_dep_tree = dict()
for r in recipe:
flat_dep_tree[r.name] = set()
deps = set(graph.get_dependencies(r))
deps = set(nx_neighbors(graph, r))
for o in deps.intersection(set(recipe)):
flat_dep_tree[r.name].add(o.name)
# get top level entries
top_level_entries = set()
deps = set()
for r in recipe:
deps.update(graph.get_dependencies(r))
deps.update(set(nx_neighbors(graph, r)))
for r in recipe:
if r not in deps:
top_level_entries.add(r)
Expand Down Expand Up @@ -249,14 +250,13 @@ def spec_print(seed: str, indent: int, fdt: dict, rs: tuple[Image]):
# print specs
for tl in top_level_entries:
spec_print(tl.name, 0, flat_dep_tree, recipe)
print() # add newline
bare_print([]) # add newline
else:
parser.print_help()
print() # add newline
bare_print([]) # add newline

except KeyboardInterrupt:
bare_print([
TextBlock("\b\b==> ", fore=Fore.YELLOW, style=Style.BRIGHT),
TextBlock("Keyboard Interrupt", fore=Fore.MAGENTA, style=Style.BRIGHT)
])

6 changes: 4 additions & 2 deletions src/velocity/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from timeit import default_timer as timer
from queue import SimpleQueue
from subprocess import PIPE, Popen
from time import sleep

from colorama import Fore, Style
from loguru import logger
Expand All @@ -32,7 +33,7 @@ def read_pipe(pipe: PIPE, topic: SimpleQueue, prefix: str, log: SimpleQueue) ->
topic.put(ln.strip("\n"))
log.put("{} {}".format(prefix, ln.strip("\n")))
except UnicodeDecodeError as e:
# some ubuntu container builds were printing out wierd characters
# some ubuntu container builds were printing out weird characters
logger.error(e)


Expand Down Expand Up @@ -62,6 +63,7 @@ def run(cmd: str, log_file: Path = None, verbose: bool = False, critical: bool =
if file and not log.empty():
file.write(log.get() + "\n")
file.flush() # TODO is this needed?
sleep(0.01) # Sleep 10ms to reduce CPU usage

out.join()
err.join()
Expand Down Expand Up @@ -94,7 +96,7 @@ class ImageBuilder(metaclass=OurMeta):
def __init__(
self,
bt: tuple[Image],
build_name: str = None,
build_name: str | None = None,
dry_run: bool = False,
remove_tags: bool = True,
clean_build_dir: bool = False,
Expand Down
10 changes: 8 additions & 2 deletions src/velocity/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def __init__(self, *args) -> None:
class EdgeViolatesDAG(Exception):
"""Edge breaks the DAG requirement of a graph."""

def __init__(self, u_of_edge, v_of_edge, cycle) -> None:
super().__init__(f"Addition of edge {u_of_edge} -> {v_of_edge} violates graph DAG requirement!")
def __init__(self, cycle) -> None:
super().__init__("Addition of edge(s) violates graph DAG requirement!")
for c in cycle:
print(f"{c[0]} -> {c[1]}", file=stderr)

Expand Down Expand Up @@ -83,3 +83,9 @@ class InvalidCLIArgumentFormat(Exception):

def __init__(self, *args) -> None:
super().__init__(*args)

class SpecSyntaxError(Exception):
"""Invalid spec syntax."""

def __init__(self, *args) -> None:
super().__init__(*args)
Loading