Commit f685a0bb authored by Lucas Bourneuf's avatar Lucas Bourneuf

new API to compile multiple contexts

parent c16ee61b
__version__ = '0.0.16.dev0'
from .script import Script
from .core import run, single_image_from_filenames, multiple_images_from_filenames, gif_from_filenames, compile_to_single_image, compile_to_images, compile_context_to_dots, compile_context_to_dot
from .core import run, single_image_from_filenames, multiple_images_from_filenames, gif_from_filenames, compile_to_single_image, compile_to_images, compile_context_to_dots, compile_context_to_dot, compile_contexts_to_dots, compile_contexts_to_dot
from .module_loader import build_scripts_from_file, build_scripts_from_dir, sort_scripts_per_dependancies
from .export import standalone_export_pipeline
......@@ -8,6 +8,7 @@ import io
import time
import json
import tempfile
import itertools
from PIL import Image
from collections import OrderedDict
from . import utils
......@@ -165,9 +166,27 @@ def compile_context_to_dots(context:str, nb_model:int=0) -> [str]:
yield from dot_writer.multiple_graphs_from_configs(configs)
def compile_contexts_to_dots(contexts:[str], nb_model:int=0) -> [str]:
"Yield a dot string for each found model"
configs = itertools.chain.from_iterable(
asp_to_dot.visual_config_from_asp(solve_context(context, nb_model=nb_model))
for context in contexts
)
yield from dot_writer.multiple_graphs_from_configs(configs)
def compile_context_to_dot(context:str, nb_model:int=0) -> str:
"Return a dot string for all found model"
configs = asp_to_dot.visual_config_from_asp(
solve_context(context, nb_model=nb_model)
)
return ''.join(dot_writer.one_graph_from_configs(configs))
def compile_contexts_to_dot(contexts:[str], nb_model:int=0) -> str:
"Return a dot string for all given model/contexts"
configs = itertools.chain.from_iterable(
asp_to_dot.visual_config_from_asp(solve_context(context, nb_model=nb_model))
for context in contexts
)
return ''.join(dot_writer.one_graph_from_configs(configs))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment