-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from entangled/feature-loom
Feature loom
- Loading branch information
Showing
29 changed files
with
1,160 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ coverage.* | |
dist | ||
poetry.lock | ||
site | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
import argh # type: ignore | ||
import asyncio | ||
|
||
from ..config import config | ||
from ..loom import resolve_tasks, Target | ||
from ..logging import logger | ||
|
||
log = logger() | ||
|
||
async def main(target_strs: list[str], force_run: bool, throttle: Optional[int]): | ||
db = await resolve_tasks(config.loom) | ||
for t in db.tasks: | ||
log.debug(str(t)) | ||
if throttle: | ||
db.throttle = asyncio.Semaphore(throttle) | ||
db.force_run = force_run | ||
jobs = [db.run(Target.from_str(t)) for t in target_strs] | ||
await asyncio.gather(*jobs) | ||
|
||
|
||
@argh.arg("targets", nargs="+", help="name of target to run") | ||
@argh.arg("-B", "--force-run", help="rebuild all dependencies") | ||
@argh.arg("-j", "--throttle", help="limit number of concurrent jobs") | ||
def loom(targets: list[str], force_run: bool = False, throttle: Optional[int] = None): | ||
"""Build one of the configured targets.""" | ||
asyncio.run(main(targets, force_run, throttle)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import logging | ||
from rich.logging import RichHandler | ||
from rich.highlighter import RegexHighlighter | ||
|
||
from .version import __version__ | ||
|
||
LOGGING_SETUP = False | ||
|
||
|
||
class BackTickHighlighter(RegexHighlighter): | ||
highlights = [r"`(?P<bold>[^`]*)`"] | ||
|
||
|
||
def logger(): | ||
return logging.getLogger("entangled") | ||
|
||
|
||
def configure(debug=False): | ||
global LOGGING_SETUP | ||
if LOGGING_SETUP: | ||
return | ||
|
||
if debug: | ||
level = logging.DEBUG | ||
else: | ||
level = logging.INFO | ||
|
||
FORMAT = "%(message)s" | ||
logging.basicConfig( | ||
level=level, | ||
format=FORMAT, | ||
datefmt="[%X]", | ||
handlers= | ||
[RichHandler(show_path=debug, highlighter=BackTickHighlighter())], | ||
) | ||
log = logging.getLogger("entangled") | ||
log.setLevel(level) | ||
# log.addHandler(RichHandler(show_path=debug, highlighter=BackTickHighlighter())) | ||
# log.propagate = False | ||
log.info(f"Entangled {__version__} (https://entangled.github.io/)") | ||
|
||
LOGGING_SETUP = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .program import Program, resolve_tasks | ||
from .task import Task, TaskDB, Target | ||
|
||
__all__ = ["Program", "resolve_tasks", "Task", "TaskDB", "Target"] |
Oops, something went wrong.