Created
October 19, 2016 20:54
-
-
Save mpkocher/8c7e5b7e73801b7730d96cdbedb42147 to your computer and use it in GitHub Desktop.
Pipeline to RST
This file contains hidden or 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
"""Example of Convert to RST""" | |
import sys | |
from collections import namedtuple | |
from pbcommand.cli import get_default_argparser_with_base_opts | |
from pbcommand.validators import validate_dir | |
from pbsmrtpipe.models import Pipeline | |
__version__ = "0.1.0" | |
# container for the pipeline id and the pipeline converted to a String | |
ConvertedPipeline = namedtuple("ConvertedPipeline", "pipeline_id s") | |
def load_pipelines_from_dir(path): | |
""" | |
:arg path: Path to pipeline template dir | |
:type path: basestring | |
:rtype path: list[Pipeline] | |
""" | |
return [] | |
def convert_pipeline_to_rst(pipeline): | |
""":type pipeline: ConvertedPipeline""" | |
return ConvertedPipeline("test.pipeline_id", "My Pipeline Id\nTask-Options:\n") | |
def apply_pipeline_template_view_rules(pipeline, pipeline_view_rules): | |
"""Returns a copy of the pipeline with the new rules applied (e.g,, change the pipeline name)""" | |
return pipeline | |
def write_converted_pipelines(converted_pipelines, output_dir): | |
""" | |
writes a index rst file to the output dir with each pipeline named | |
pipeline_id.rst | |
Maybe each individual pipeline.rst should be nested within a subdir called "pipelines" | |
index.rst | |
pipelines/ | |
- my_pipeline.rst | |
:type converted_pipelines: list[ConvertedPipeline] | |
:type output_dir: basestring | |
""" | |
return 0 | |
def convert_pipeline_json_files(pipeline_dir, output_dir): | |
pipelines = load_pipelines_from_dir(pipeline_dir) | |
converted_pipelines = [convert_pipeline_to_rst(p) for p in pipelines] | |
write_converted_pipelines(converted_pipelines, output_dir) | |
return 0 | |
def get_parser(): | |
desc = "Description" | |
p = get_default_argparser_with_base_opts(__version__, desc) | |
p.add_argument("path_to_pipeline_dir", type=validate_dir, help="Path to Pipeline Template JSON Dir") | |
p.add_argument("--output-dir", "pipeline-outputs") | |
p.add_argument("--pipeline-view-rules", ) | |
return p | |
def main(args): | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main(args=sys.argv[1:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment