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

NO-REF: Adding ability to run scripts via main.py #527

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
29 changes: 28 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
)



def main(args):
logger = create_log(__name__)

environment = args.environment

if args.script is not None:
logger.info(f'Running script {args.script} in {environment}')

run_script(args.script)

return

process = args.process
process_type = args.ingestType
custom_file = args.inputFile
Expand Down Expand Up @@ -57,10 +66,28 @@ def register_processes():
return dict(process_classes)


def register_scripts() -> dict:
import scripts

script_functions = inspect.getmembers(scripts, inspect.isfunction)

return dict(script_functions)


def run_script(script: str):
scripts = register_scripts()

script = scripts.get(script)

if script is not None:
script()


def create_arg_parser():
parser = argparse.ArgumentParser(description='Run DCDW Data Ingest Jobs')

parser.add_argument('-p', '--process', required=True, help='The name of the process job to be run')
parser.add_argument('-p', '--process', help='The name of the process job to be run')
parser.add_argument('-sc', '--script', help='The name of the script to run')
parser.add_argument('-e', '--environment', required=True, help='Environment for deployment, sets env file to load')
parser.add_argument('-i', '--ingestType', help='The interval to run the ingest over. Generally daily/complete/custom')
parser.add_argument('-f', '--inputFile', help='Name of file to ingest. Ignored if -i custom is not set')
Expand Down
54 changes: 0 additions & 54 deletions scriptRunner.py

This file was deleted.

1 change: 1 addition & 0 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
from .nyplLoginFlags import main as nyplFlags
from .deleteUMPManifestLinks import main as deleteUMPManifests
from .deleteProblemWorks import main as deleteWorks
from .cleanup_duplicate_works import main as cleanup_duplicate_works
Loading