Skip to content

Commit

Permalink
Add argparser to local example for autopiloting
Browse files Browse the repository at this point in the history
  • Loading branch information
lnauta committed Jan 2, 2025
1 parent ad5dae0 commit ff81da6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion examples/local_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Attach the logs to the token
'''

import argparse
import logging
import os
import time
Expand Down Expand Up @@ -78,14 +79,28 @@ def process_task(self, token):
pass


def arg_parser():
"""
Arguments parser for optional values of the example
returns: argparse object
"""
parser = argparse.ArgumentParser(description="Arguments used in the different classes in the example.")
parser.add_argument("-d", "--design_doc", default="Monitor", type=str, help="Select the designdoc used by the actor class")
parser.add_argument("-V", "--view", default="todo", type=str, help="Select the view used by the actor class")
parser.add_argument("-v", "--verbose", action="store_true", type=bool, help="Set verbose") # add v for optional verbosity in the future
return parser.parse_args()


def main():
# parse user arguments
args = arg_parser()
# setup connection to db
client = CouchDB(url=picasconfig.PICAS_HOST_URL, db=picasconfig.PICAS_DATABASE, username=picasconfig.PICAS_USERNAME, password=picasconfig.PICAS_PASSWORD)
print("Connected to the database %s sucessfully. Now starting work..." %(picasconfig.PICAS_DATABASE))
# Create token modifier
modifier = BasicTokenModifier()
# Create actor
actor = ExampleActor(client, modifier)
actor = ExampleActor(client, modifier, view=args.view, design_doc=args.design_doc)
# Start work!
actor.run(max_token_time=1800, max_total_time=3600, max_tasks=10, max_scrub=2)

Expand Down
5 changes: 5 additions & 0 deletions examples/multi-core-job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

#SBATCH -c 4

python local_example.py -d MonitorMultiCore
5 changes: 5 additions & 0 deletions examples/single-core-job.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

#SBATCH -c 1

python local_example.py -d MonitorSingleCore

0 comments on commit ff81da6

Please sign in to comment.