def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the ls command parser_ls = subparsers.add_parser( 'ls', help='Runs the ls command inside your container to check the location \ of files within the container.', parents=[common.container_parser()]) parser_ls.set_defaults(func=command_ls) parser_ls.add_argument( '-l', action='store_true', help='Output additional file information including file size.') parser_ls.add_argument( '--human', action='store_true', help='Output file sizes in human-readable denominations (requires -l \ flag)') parser_ls.add_argument( '-a', action='store_true', help='Include "hidden" files in the listing.') parser_ls.add_argument( 'dir', help='The directory to list. (e.g. /grader)') return parser_ls
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the upload command. parser_upload = subparsers.add_parser( 'upload', help='Upload a container to Coursera.', parents=[common.container_parser()]) parser_upload.set_defaults(func=command_upload) setup_registration_parser(parser_upload) parser_upload.add_argument( '--temp-dir', default='/tmp', help='Temporary directory to use when exporting the container.') parser_upload.add_argument( '--file-name', help='File name to use when saving the docker container image. ' 'Defaults to the name of the container image.') parser_upload.add_argument( '--upload-to-requestbin', help='Pass the ID of a request bin to debug uploads!') parser_upload.add_argument('--transloadit-template', default='7531c0b023f611e5aa2ecf267b4b90ee', help='The transloadit template to upload to.') parser_upload.add_argument('--transloadit-account-id', default='05912e90e83346abb96c261bf458b615', help='The Coursera transloadit account id.') return parser_upload
def parser(subparsers): "Build an argparse argument parser to parse the command line." module_doc_string = sys.modules[__name__].__doc__ # create the parser for the grade command parser_grade = subparsers.add_parser( 'grade', description=module_doc_string + EXTRA_DOC, help=module_doc_string) common_flags = argparse.ArgumentParser(add_help=False) common_flags.add_argument( '--timeout', type=int, default=300, help='The time out the grader after TIMEOUT seconds') grade_subparsers = parser_grade.add_subparsers() # Local subsubcommand of the grade subcommand parser_grade_local = grade_subparsers.add_parser( 'local', help=command_grade_local.__doc__, parents=[common_flags, common.container_parser()]) parser_grade_local.set_defaults(func=command_grade_local) parser_grade_local.add_argument( 'dir', help='Directory containing the submission.', type=common.arg_fq_dir) return parser_grade
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the inspect command parser_inspect = subparsers.add_parser( 'inspect', help='Starts a shell in the foreground inside your container to poke ' 'around the container.', parents=[common.container_parser()]) parser_inspect.set_defaults(func=command_inspect) parser_inspect.add_argument( '-s', '--shell', help='Shell to use.', default='/bin/bash') parser_inspect.add_argument( '-d', '--submission', help='Submission directory to mount into the container.', type=common.arg_fq_dir) parser_inspect.add_argument( '--allow-network', action='store_true', help='Enable network access within the container. (Default off.)') parser_inspect.add_argument( '--unlimited-memory', action='store_true', help='Remove memory limits. (Default: limited memory.)') parser_inspect.add_argument( '--super-user', action='store_true', help='Inspect as super-user. (Default: userid 1000.)') return parser_inspect
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the inspect command parser_inspect = subparsers.add_parser( 'inspect', help='Starts a shell in the foreground inside your container to poke ' 'around the container.', parents=[common.container_parser()]) parser_inspect.set_defaults(func=command_inspect) parser_inspect.add_argument('-s', '--shell', help='Shell to use.', default='/bin/bash') parser_inspect.add_argument( '-d', '--submission', help='Submission directory to mount into the container.', type=common.arg_fq_dir) parser_inspect.add_argument( '--allow-network', action='store_true', help='Enable network access within the container. (Default off.)') parser_inspect.add_argument( '--unlimited-memory', action='store_true', help='Remove memory limits. (Default: limited memory.)') parser_inspect.add_argument( '--super-user', action='store_true', help='Inspect as super-user. (Default: userid 1000.)') return parser_inspect
def parser(subparsers): "Build an argparse argument parser to parse the command line." module_doc_string = sys.modules[__name__].__doc__ # create the parser for the grade command parser_grade = subparsers.add_parser('grade', description=module_doc_string + EXTRA_DOC, help=module_doc_string) common_flags = argparse.ArgumentParser(add_help=False) common_flags.add_argument( '--timeout', type=int, default=300, help='The time out the grader after TIMEOUT seconds') grade_subparsers = parser_grade.add_subparsers() # Local subsubcommand of the grade subcommand parser_grade_local = grade_subparsers.add_parser( 'local', help=command_grade_local.__doc__, parents=[common_flags, common.container_parser()]) parser_grade_local.set_defaults(func=command_grade_local) parser_grade_local.add_argument( 'dir', help='Directory containing the submission.', type=common.arg_fq_dir) parser_grade_local.add_argument('args', nargs=argparse.REMAINDER, help='Arguments to the docker executable') return parser_grade
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the ls command parser_ls = subparsers.add_parser( 'ls', help='Runs the ls command inside your container to check the location \ of files within the container.', parents=[common.container_parser()]) parser_ls.set_defaults(func=command_ls) parser_ls.add_argument( '-l', action='store_true', help='Output additional file information including file size.') parser_ls.add_argument( '--human', action='store_true', help='Output file sizes in human-readable denominations (requires -l \ flag)') parser_ls.add_argument( '-a', action='store_true', help='Include "hidden" files in the listing.') parser_ls.add_argument( 'dir', help='The directory to list. (e.g. /grader)') parser_ls.add_argument( '--no-rm', action='store_true', help="Don't remove the container after running the ls command.") return parser_ls
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the cat command parser_cat = subparsers.add_parser( 'cat', help='Output files within the container to the console for debugging', parents=[common.container_parser()]) parser_cat.set_defaults(func=command_cat) parser_cat.add_argument('file', help='File(s) to output.', nargs='+') return parser_cat
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the cat command parser_cat = subparsers.add_parser( 'cat', help='Output files within the container to the console for debugging', parents=[common.container_parser()]) parser_cat.set_defaults(func=command_cat) parser_cat.add_argument('file', help='File(s) to output.', nargs='+') return parser_cat
def parser(subparsers): "Build an argparse argument parser to parse the command line." module_doc_string = sys.modules[__name__].__doc__ # create the parser for the grade command parser_grade = subparsers.add_parser( 'grade', description=module_doc_string + EXTRA_DOC, help=module_doc_string) common_flags = argparse.ArgumentParser(add_help=False) common_flags.add_argument( '--timeout', type=int, default=300, help='The time out the grader after TIMEOUT seconds') common_flags.add_argument( '--mem-limit', type=int, default=1024, help='The amount of memory allocated to the grader') grade_subparsers = parser_grade.add_subparsers() # Local subsubcommand of the grade subcommand parser_grade_local = grade_subparsers.add_parser( 'local', help=command_grade_local.__doc__, parents=[common_flags, common.container_parser()]) parser_grade_local.set_defaults(func=command_grade_local) parser_grade_local.add_argument( '--no-rm', action='store_true', help='Do not clean up the container after grading completes.') parser_grade_local.add_argument( 'dir', help='Directory containing the submission.', type=common.arg_fq_dir) parser_grade_local.add_argument( 'args', nargs=argparse.REMAINDER, help='Arguments to the docker executable') return parser_grade
def parser(subparsers): "Build an argparse argument parser to parse the command line." # constants for timeout ranges TIMEOUT_LOWER = 300 TIMEOUT_UPPER = 1800 # create the parser for the upload command. parser_upload = subparsers.add_parser( 'upload', help='Upload a container to Coursera.', parents=[common.container_parser()]) parser_upload.set_defaults(func=command_upload) parser_upload.add_argument( 'course', help='The course id to associate the grader. The course id is a ' 'gibberish string UUID. Given a course slug such as `developer-iot`, ' 'you can retrieve the course id by querying the catalog API. e.g.: ' 'https://api.coursera.org/api/courses.v1?q=slug&slug=developer-iot') parser_upload.add_argument( 'item', help='The id of the item to associate the grader. The easiest way ' 'to find the item id is by looking at the URL in the authoring web ' 'interface. It is the last part of the URL, and is a short UUID.') parser_upload.add_argument( 'part', help='The id of the part to associate the grader.') parser_upload.add_argument( '--additional_item_and_part', nargs=2, action='append', help='The next two args specify an item ID and part ID which will ' 'also be associated with the grader.') parser_upload.add_argument( '--grader-cpu', type=int, choices=[1, 2], help='Amount of CPU your grader is allocated when grading ' 'submissions. You may choose from 1 or 2 full CPU cores. The ' 'default number is 1.') parser_upload.add_argument( '--grader-memory-limit', type=int, choices=[1024, 2048], help='Amount of memory your grader is allocated when grading ' 'submissions. You may choose from 1024 MB or 2048 MB. The ' 'default amount is 1024 MB.') parser_upload.add_argument( '--grading-timeout', type=lambda v: utils.check_int_range(v, TIMEOUT_LOWER, TIMEOUT_UPPER), help='Amount of time allowed before your grader times out, in ' 'seconds. You may choose any value between 300 seconds and 1800 ' 'seconds. The default time is 1200 seconds (20 minutes).') parser_upload.add_argument( '--temp-dir', default='/tmp', help='Temporary directory to use when exporting the container.') parser_upload.add_argument( '--file-name', help='File name to use when saving the docker container image. ' 'Defaults to the name of the container image.') parser_upload.add_argument( '--upload-to-requestbin', help='Pass the ID of a request bin to debug uploads!') parser_upload.add_argument('--transloadit-template', default='7531c0b023f611e5aa2ecf267b4b90ee', help='The transloadit template to upload to.') parser_upload.add_argument('--transloadit-account-id', default='05912e90e83346abb96c261bf458b615', help='The Coursera transloadit account id.') parser_upload.add_argument( '--register-endpoint', default='https://api.coursera.org/api/gridExecutorCreationAttempts.v1', help='Override the endpoint used to register the graders after upload') parser_upload.add_argument( '--update-part-endpoint', default='https://api.coursera.org/api/' 'authoringProgrammingAssignments.v1', help='Override the endpoint used to update the assignment (draft)') parser_upload.add_argument( '--update-part-action', default='setGridExecutorId', help='The name of the Naptime action called to update the assignment') return parser_upload
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the upload command. parser_upload = subparsers.add_parser( 'upload', help='Upload a container to Coursera.', parents=[common.container_parser()]) parser_upload.set_defaults(func=command_upload) parser_upload.add_argument( 'course', help='The course id to associate the grader.') parser_upload.add_argument( 'item', help='The id of the item to associate the grader.') parser_upload.add_argument( 'part', help='The id of the part to associate the grader.') parser_upload.add_argument( '--temp-dir', default='/tmp', help='Temporary directory to use when exporting the container.') parser_upload.add_argument( '--file-name', help='File name to use when saving the docker container image. ' 'Defaults to the name of the container image.') parser_upload.add_argument( '--upload-to-requestbin', help='Pass the ID of a request bin to debug uploads!') parser_upload.add_argument( '--transloadit-template', default='7531c0b023f611e5aa2ecf267b4b90ee', help='The transloadit template to upload to.') parser_upload.add_argument( '--transloadit-account-id', default='05912e90e83346abb96c261bf458b615', help='The Coursera transloadit account id.') parser_upload.add_argument( '--register-endpoint', default='https://api.coursera.org/api/gridExecutorCreationAttempts.v1', help='Override the endpoint used to register the graders after upload') parser_upload.add_argument( '--update-part-endpoint', default='https://api.coursera.org/api/' 'authoringProgrammingAssignments.v1', help='Override the endpoint used to update the assignment (draft)') parser_upload.add_argument( '--update-part-action', default='setGridExecutorId', help='The name of the Naptime action called to update the assignment') return parser_upload
def parser(subparsers): "Build an argparse argument parser to parse the command line." # create the parser for the upload command. parser_upload = subparsers.add_parser( 'upload', help='Upload a container to Coursera.', parents=[common.container_parser()]) parser_upload.set_defaults(func=command_upload) parser_upload.add_argument('course', help='The course id to associate the grader.') parser_upload.add_argument( 'item', help='The id of the item to associate the grader.') parser_upload.add_argument( 'part', help='The id of the part to associate the grader.') parser_upload.add_argument( '--additional_item_and_part', nargs=2, action='append', help='The next two args specify an item ID and part ID which will ' 'also be associated with the grader.') parser_upload.add_argument( '--temp-dir', default='/tmp', help='Temporary directory to use when exporting the container.') parser_upload.add_argument( '--file-name', help='File name to use when saving the docker container image. ' 'Defaults to the name of the container image.') parser_upload.add_argument( '--upload-to-requestbin', help='Pass the ID of a request bin to debug uploads!') parser_upload.add_argument('--transloadit-template', default='7531c0b023f611e5aa2ecf267b4b90ee', help='The transloadit template to upload to.') parser_upload.add_argument('--transloadit-account-id', default='05912e90e83346abb96c261bf458b615', help='The Coursera transloadit account id.') parser_upload.add_argument( '--register-endpoint', default='https://api.coursera.org/api/gridExecutorCreationAttempts.v1', help='Override the endpoint used to register the graders after upload') parser_upload.add_argument( '--update-part-endpoint', default='https://api.coursera.org/api/' 'authoringProgrammingAssignments.v1', help='Override the endpoint used to update the assignment (draft)') parser_upload.add_argument( '--update-part-action', default='setGridExecutorId', help='The name of the Naptime action called to update the assignment') return parser_upload
def parser(subparsers): "Build an argparse argument parser to parse the command line." # constants for timeout ranges TIMEOUT_LOWER = 300 TIMEOUT_UPPER = 1800 # create the parser for the upload command. parser_upload = subparsers.add_parser( "upload", help="Upload a container to Coursera.", parents=[common.container_parser()] ) parser_upload.set_defaults(func=command_upload) parser_upload.add_argument("course", help="The course id to associate the grader.") parser_upload.add_argument("item", help="The id of the item to associate the grader.") parser_upload.add_argument("part", help="The id of the part to associate the grader.") parser_upload.add_argument( "--additional_item_and_part", nargs=2, action="append", help="The next two args specify an item ID and part ID which will " "also be associated with the grader.", ) parser_upload.add_argument( "--grader-cpu", type=int, choices=[1, 2], help="Amount of CPU your grader is allocated when grading " "submissions. You may choose from 1 or 2 full CPU cores. The " "default number is 1.", ) parser_upload.add_argument( "--grader-memory-limit", type=int, choices=[1024, 2048], help="Amount of memory your grader is allocated when grading " "submissions. You may choose from 1024 MB or 2048 MB. The " "default amount is 1024 MB.", ) parser_upload.add_argument( "--grading-timeout", type=lambda v: utils.check_int_range(v, TIMEOUT_LOWER, TIMEOUT_UPPER), help="Amount of time allowed before your grader times out, in " "seconds. You may choose any value between 300 seconds and 1800 " "seconds. The default time is 1200 seconds (20 minutes).", ) parser_upload.add_argument( "--temp-dir", default="/tmp", help="Temporary directory to use when exporting the container." ) parser_upload.add_argument( "--file-name", help="File name to use when saving the docker container image. " "Defaults to the name of the container image.", ) parser_upload.add_argument("--upload-to-requestbin", help="Pass the ID of a request bin to debug uploads!") parser_upload.add_argument( "--transloadit-template", default="7531c0b023f611e5aa2ecf267b4b90ee", help="The transloadit template to upload to.", ) parser_upload.add_argument( "--transloadit-account-id", default="05912e90e83346abb96c261bf458b615", help="The Coursera transloadit account id.", ) parser_upload.add_argument( "--register-endpoint", default="https://api.coursera.org/api/gridExecutorCreationAttempts.v1", help="Override the endpoint used to register the graders after upload", ) parser_upload.add_argument( "--update-part-endpoint", default="https://api.coursera.org/api/" "authoringProgrammingAssignments.v1", help="Override the endpoint used to update the assignment (draft)", ) parser_upload.add_argument( "--update-part-action", default="setGridExecutorId", help="The name of the Naptime action called to update the assignment", ) return parser_upload
def parser(subparsers): "Build an argparse argument parser to parse the command line." # constants for timeout ranges TIMEOUT_LOWER = 300 TIMEOUT_UPPER = 1800 # create the parser for the upload command. parser_upload = subparsers.add_parser( 'upload', help='Upload a container to Coursera.', parents=[common.container_parser()]) parser_upload.set_defaults(func=command_upload) parser_upload.add_argument( 'course', help='The course id to associate the grader. The course id is a ' 'gibberish string UUID. Given a course slug such as `developer-iot`, ' 'you can retrieve the course id by querying the catalog API. e.g.: ' 'https://api.coursera.org/api/courses.v1?q=slug&slug=developer-iot') parser_upload.add_argument( 'item', help='The id of the item to associate the grader. The easiest way ' 'to find the item id is by looking at the URL in the authoring web ' 'interface. It is the last part of the URL, and is a short UUID.') parser_upload.add_argument( 'part', help='The id of the part to associate the grader.') parser_upload.add_argument( '--additional_item_and_part', nargs=2, action='append', help='The next two args specify an item ID and part ID which will ' 'also be associated with the grader.') parser_upload.add_argument( '--grader-cpu', type=int, choices=[1, 2], help='Amount of CPU your grader is allocated when grading ' 'submissions. You may choose from 1 or 2 full CPU cores. The ' 'default number is 1.') parser_upload.add_argument( '--grader-memory-limit', type=int, choices=[1024, 2048], help='Amount of memory your grader is allocated when grading ' 'submissions. You may choose from 1024 MB or 2048 MB. The ' 'default amount is 1024 MB.') parser_upload.add_argument( '--grading-timeout', type=lambda v: utils.check_int_range(v, TIMEOUT_LOWER, TIMEOUT_UPPER), help='Amount of time allowed before your grader times out, in ' 'seconds. You may choose any value between 300 seconds and 1800 ' 'seconds. The default time is 1200 seconds (20 minutes).') parser_upload.add_argument( '--temp-dir', default='/tmp', help='Temporary directory to use when exporting the container.') parser_upload.add_argument( '--file-name', help='File name to use when saving the docker container image. ' 'Defaults to the name of the container image.') parser_upload.add_argument( '--upload-to-requestbin', help='Pass the ID of a request bin to debug uploads!') parser_upload.add_argument( '--transloadit-template', default='7531c0b023f611e5aa2ecf267b4b90ee', help='The transloadit template to upload to.') parser_upload.add_argument( '--transloadit-account-id', default='05912e90e83346abb96c261bf458b615', help='The Coursera transloadit account id.') parser_upload.add_argument( '--register-endpoint', default='https://api.coursera.org/api/gridExecutorCreationAttempts.v1', help='Override the endpoint used to register the graders after upload') parser_upload.add_argument( '--update-part-endpoint', default='https://api.coursera.org/api/' 'authoringProgrammingAssignments.v1', help='Override the endpoint used to update the assignment (draft)') parser_upload.add_argument( '--update-part-action', default='setGridExecutorId', help='The name of the Naptime action called to update the assignment') return parser_upload