Created
January 18, 2020 12:30
-
-
Save podhmo/a14c9c828e959aab288332e77a27c8db to your computer and use it in GitHub Desktop.
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
from handofcats import as_subcommand | |
@as_subcommand | |
def foo(target: str): | |
import heavy_module | |
heavy_module.hello(target) | |
@as_subcommand | |
def bar(target: str): | |
import heavy_module | |
heavy_module.hello(target) | |
as_subcommand.run() |
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
import typing as t | |
from handofcats import as_subcommand | |
@as_subcommand | |
def foo(targets: t.List[str]): | |
import heavy_module | |
for target in targets: | |
heavy_module.hello(target) | |
@as_subcommand | |
def bar(targets: t.List[str]): | |
import heavy_module | |
for target in targets: | |
heavy_module.hello(target) | |
as_subcommand.run() |
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
from handofcats import as_subcommand | |
@as_subcommand | |
def foo(target: str): | |
import heavy_module | |
print("foo") | |
heavy_module.hello(target) | |
@as_subcommand | |
def bar(target: str): | |
import heavy_module | |
print("bar") | |
heavy_module.hello(target) | |
if __name__ == "__main__": | |
import sys | |
import itertools | |
sep = "-" | |
itr = iter(sys.argv[1:]) | |
while True: | |
argv = list(itertools.takewhile(lambda x: x != sep, itr)) | |
if len(argv) == 0: | |
break | |
as_subcommand.run(argv=argv) |
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
import time | |
print("loading") | |
time.sleep(0.5) | |
print("loaded") | |
def hello(target: str): | |
print(f"hello {target}") |
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
gen: targets | |
for i in `seq 10`; do echo $$i > targets/`printf "%02dtarget.txt" $$i`; done | |
targets: | |
mkdir -p $@ | |
00: | |
ls targets/*.txt | xargs -n 1 python $(shell echo $@*.py) foo | |
01: | |
python $(shell echo $@*.py) foo targets/*.txt | |
02: | |
python $(shell echo $@*.py) \ | |
foo targets/target01.txt - bar targets/target02.txt - \ | |
foo targets/target03.txt - bar targets/target04.txt - \ | |
foo targets/target05.txt - bar targets/target06.txt - \ | |
foo targets/target07.txt - bar targets/target08.txt - \ | |
foo targets/target09.txt - bar targets/target10.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment