Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apapt pipeline to accept config file as optional input #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 10 additions & 11 deletions src/parenttext_pipeline/cli.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import runpy

import argparse
from parenttext_pipeline.pipelines import Config, run


class ConfigError(Exception):
pass

def init(config_path='config.py'):
run(load_config(config_path))

def init():
run(load_config())


def load_config():
create_config = runpy.run_path('config.py').get("create_config")
def load_config(config_path):
create_config = runpy.run_path(config_path).get("create_config")

if create_config and callable(create_config):
return Config(**create_config())
else:
raise ConfigError("Could not find 'create_config' function in 'config.py'")

raise ConfigError("Could not find 'create_config' function in the specified config file")

if __name__ == '__main__':
init()
parser = argparse.ArgumentParser(description='Run the parenttext pipeline with a specified config file.')
parser.add_argument('config_path', help='Path to the config.py file')
args = parser.parse_args()
init(args.config_path)