@@ -160,7 +160,7 @@ def ensure_ecs_security_group(region):
160160 :param region: The region, or `None` to pull the region from the environment.
161161 :return: The GroupId of the SecurityGroup.
162162 """
163- sg_name = "axon-autogenerated-sg- ecs"
163+ sg_name = "axon-autogenerated-ecs-sg "
164164 client = make_client ("ec2" , region )
165165 sg_id = get_single_security_group (client , sg_name , "Axon autogenerated for ECS." )
166166 ensure_ecs_gress (sg_id , region )
@@ -173,7 +173,7 @@ def ensure_ec2_security_group(region):
173173 :param region: The region, or `None` to pull the region from the environment.
174174 :return: The GroupId of the SecurityGroup.
175175 """
176- sg_name = "axon-autogenerated-sg- ec2"
176+ sg_name = "axon-autogenerated-ec2-sg "
177177 client = make_client ("ec2" , region )
178178 sg_id = get_single_security_group (client , sg_name , "Axon autogenerated for EC2." )
179179 ensure_ec2_gress (sg_id , region )
@@ -631,46 +631,47 @@ def impl_download_trained_model_file(model_path, bucket_name, region):
631631 print ("Downloaded from: {}\n " .format (key ))
632632
633633
634- def impl_download_training_script (script_name , bucket_name , region ):
634+ def impl_download_training_script (script_path , bucket_name , region ):
635635 """
636636 Downloads a training script from S3.
637637
638- :param script_name : The filename of the script to download (must be in the current directory) .
638+ :param script_path : The file path to download to, ending with the name of the script .
639639 :param bucket_name: The S3 bucket name.
640640 :param region: The region, or `None` to pull the region from the environment.
641641 """
642642 client = make_client ("s3" , region )
643- remote_path = "axon-training-scripts/" + os .path .basename (script_name )
644- client .download_file (bucket_name , remote_path , script_name )
645- print ("Downloaded from: {}\n " .format (remote_path ))
643+ key = "axon-training-scripts/" + os .path .basename (script_path )
644+ client .download_file (bucket_name , key , script_path )
645+ print ("Downloaded from: {}\n " .format (key ))
646646
647647
648- def impl_upload_dataset (dataset_name , bucket_name , region ):
648+ def impl_upload_dataset (dataset_path , bucket_name , region ):
649649 """
650650 Uploads a dataset to S3.
651651
652- :param dataset_name: The filename of the dataset to upload (must be in the current directory).
652+ :param dataset_path: The file path to the dataset to upload, ending with the name of the
653+ dataset.
653654 :param bucket_name: The S3 bucket name.
654655 :param region: The region, or `None` to pull the region from the environment.
655656 """
656657 client = make_client ("s3" , region )
657- remote_path = "axon-datasets/" + os .path .basename (dataset_name )
658- client .upload_file (dataset_name , bucket_name , remote_path )
659- print ("Uploaded to: {}\n " .format (remote_path ))
658+ key = "axon-datasets/" + os .path .basename (dataset_path )
659+ client .upload_file (dataset_path , bucket_name , key )
660+ print ("Uploaded to: {}\n " .format (key ))
660661
661662
662- def impl_download_dataset (dataset_name , bucket_name , region ):
663+ def impl_download_dataset (dataset_path , bucket_name , region ):
663664 """
664665 Downloads a dataset from S3.
665666
666- :param dataset_name : The filename of the dataset to download (must be in the current directory) .
667+ :param dataset_path : The file path to download to, ending with the name of the dataset .
667668 :param bucket_name: The S3 bucket name.
668669 :param region: The region, or `None` to pull the region from the environment.
669670 """
670671 client = make_client ("s3" , region )
671- remote_path = "axon-datasets/" + os .path .basename (dataset_name )
672- client .download_file (bucket_name , remote_path , dataset_name )
673- print ("Downloaded from: {}\n " .format (remote_path ))
672+ key = "axon-datasets/" + os .path .basename (dataset_path )
673+ client .download_file (bucket_name , key , dataset_path )
674+ print ("Downloaded from: {}\n " .format (key ))
674675
675676
676677def impl_update_training_progress (model_name , dataset_name , progress_text , bucket_name , region ):
@@ -701,15 +702,24 @@ def cli():
701702 return
702703
703704
704- # TODO: Don't set a default value for region in any of these
705+ region_choices = ['us-east-1' , 'us-east-2' , 'us-west-1' , 'us-west-2' , 'ca-central-1' ,
706+ 'eu-central-1' , 'eu-west-1' , 'eu-west-2' , 'eu-west-3' ,
707+ 'eu-north-1' , 'ap-east-1' , 'ap-south-1' , 'ap-northeast-1' ,
708+ 'ap-northeast-2' , 'ap-northeast-3' , 'ap-southeast-1' ,
709+ 'ap-southeast-2' , 'me-south-1' , 'sa-east-1' ]
710+
705711
706712@cli .command (name = "start-axon" )
707- @click .argument ( "cluster-name" )
708- @ click .argument ( "task-family" )
713+ @click .option ( "--region" , help = "The region to connect to." ,
714+ type = click .Choice ( region_choices ) )
709715@click .option ("--revision" , default = None ,
710716 help = "The revision of the task. Set to None to use the latest revision." )
711- @click .option ("--region" , help = "The region to connect to." )
712- def start_axon (cluster_name , task_family , revision , region ):
717+ def start_axon (revision , region ):
718+ """
719+ Starts Axon and opens the ECS server in the default web browser.
720+ """
721+ cluster_name = "axon-autogenerated-cluster"
722+ task_family = "axon-autogenerated-task-family"
713723 impl_ensure_configuration (cluster_name , task_family , region )
714724 task_arn = impl_start_task (cluster_name , task_family , revision , region )
715725 print ("Started task: {}" .format (task_arn ))
@@ -722,22 +732,29 @@ def start_axon(cluster_name, task_family, revision, region):
722732
723733
724734@cli .command (name = "ensure-configuration" )
725- @click .argument ("cluster-name" )
726- @click .argument ("task-family" )
727- @click .option ("--region" , help = "The region to connect to." )
728- def ensure_configuration (cluster_name , task_family , region ):
729- impl_ensure_configuration (cluster_name , task_family , region )
735+ @click .option ("--region" , help = "The region to connect to." ,
736+ type = click .Choice (region_choices ))
737+ def ensure_configuration (region ):
738+ """
739+ Ensures that AWS is configured for Axon.
740+ """
741+ impl_ensure_configuration ("axon-autogenerated-cluster" , "axon-autogenerated-task-family" ,
742+ region )
730743
731744
732745@cli .command (name = "start-task" )
733- @click .argument ( "cluster-name" )
734- @ click .argument ( "task-family" )
746+ @click .option ( "--region" , help = "The region to connect to." ,
747+ type = click .Choice ( region_choices ) )
735748@click .option ("--revision" , default = None ,
736749 help = "The revision of the task. Set to None to use the latest revision." )
737- @click .option ("--region" , help = "The region to connect to." )
738750@click .option ("--stop-after/--no-stop-after" , default = False ,
739751 help = "Whether to stop the task immediately after creating it." )
740- def start_task (cluster_name , task_family , revision , region , stop_after ):
752+ def start_task (revision , region , stop_after ):
753+ """
754+ Starts a task.
755+ """
756+ cluster_name = "axon-autogenerated-cluster"
757+ task_family = "axon-autogenerated-task-family"
741758 impl_ensure_configuration (cluster_name , task_family , region )
742759 task_arn = impl_start_task (cluster_name , task_family , revision , region )
743760 print ("Started task: {}" .format (task_arn ))
@@ -750,82 +767,138 @@ def start_task(cluster_name, task_family, revision, region, stop_after):
750767
751768
752769@cli .command (name = "stop-task" )
753- @click .argument ("cluster-name" )
754- @click .argument ("task" )
755- @click .option ("--region" , help = "The region to connect to." )
756- def stop_task (cluster_name , task , region ):
757- impl_stop_task (cluster_name , task , region )
770+ @click .argument ("task-arn" )
771+ @click .option ("--region" , help = "The region to connect to." ,
772+ type = click .Choice (region_choices ))
773+ def stop_task (task_arn , region ):
774+ """
775+ Stops a task.
776+
777+ TASK_ARN The ARN of the task to stop. Given to you from `start_task` or `start_axon`.
778+ """
779+ impl_stop_task ("axon-autogenerated-cluster" , task_arn , region )
758780
759781
760782@cli .command (name = "get-container-ip" )
761- @click .argument ("cluster-name" )
762- @click .argument ("task" )
763- @click .option ("--region" , help = "The region to connect to." )
764- def get_container_ip (cluster_name , task , region ):
765- print (impl_get_task_ip (cluster_name , task , region ))
783+ @click .argument ("task-arn" )
784+ @click .option ("--region" , help = "The region to connect to." ,
785+ type = click .Choice (region_choices ))
786+ def get_container_ip (task_arn , region ):
787+ """
788+ Gets the IP of the container the task is running on.
789+
790+ TASK_ARN The ARN of the task.
791+ """
792+ print (impl_get_task_ip ("axon-autogenerated-cluster" , task_arn , region ))
766793
767794
768795@cli .command (name = "upload-untrained-model-file" )
769- @click .argument ("model-name" )
770- @click .argument ("bucket-name" )
771- @click .option ("--region" , help = "The region to connect to." )
772- def upload_untrained_model_file (model_name , bucket_name , region ):
773- impl_upload_untrained_model_file (model_name , bucket_name , region )
796+ @click .argument ("model-path" )
797+ @click .option ("--region" , help = "The region to connect to." ,
798+ type = click .Choice (region_choices ))
799+ def upload_untrained_model_file (model_path , region ):
800+ """
801+ Uploads an untrained model from a local file.
802+
803+ MODEL_PATH The path to the model to upload, ending with the name of the model.
804+ """
805+ impl_upload_untrained_model_file (model_path , ensure_s3_bucket (region ), region )
774806
775807
776808@cli .command (name = "download-untrained-model-file" )
777- @click .argument ("model-name" )
778- @click .argument ("bucket-name" )
779- @click .option ("--region" , help = "The region to connect to." )
780- def download_untrained_model_file (model_name , bucket_name , region ):
781- impl_download_untrained_model_file (model_name , bucket_name , region )
809+ @click .argument ("model-path" )
810+ @click .option ("--region" , help = "The region to connect to." ,
811+ type = click .Choice (region_choices ))
812+ def download_untrained_model_file (model_path , region ):
813+ """
814+ Downloads an untrained model to a local file.
815+
816+ MODEL_PATH The path to download the model to, ending with the name of the model.
817+ """
818+ impl_download_untrained_model_file (model_path , ensure_s3_bucket (region ), region )
782819
783820
784821@cli .command (name = "upload-trained-model-file" )
785- @click .argument ("model-name" )
786- @click .argument ("bucket-name" )
787- @click .option ("--region" , help = "The region to connect to." )
788- def upload_trained_model_file (model_name , bucket_name , region ):
789- impl_upload_trained_model_file (model_name , bucket_name , region )
822+ @click .argument ("model-path" )
823+ @click .option ("--region" , help = "The region to connect to." ,
824+ type = click .Choice (region_choices ))
825+ def upload_trained_model_file (model_path , region ):
826+ """
827+ Uploads a trained model from a local file.
828+
829+ MODEL_PATH The path to the model to upload, ending with the name of the model.
830+ """
831+ impl_upload_trained_model_file (model_path , ensure_s3_bucket (region ), region )
790832
791833
792834@cli .command (name = "download-trained-model-file" )
793- @click .argument ("model-name" )
794- @click .argument ("bucket-name" )
795- @click .option ("--region" , help = "The region to connect to." )
796- def download_trained_model_file (model_name , bucket_name , region ):
797- impl_download_trained_model_file (model_name , bucket_name , region )
835+ @click .argument ("model-path" )
836+ @click .option ("--region" , help = "The region to connect to." ,
837+ type = click .Choice (region_choices ))
838+ def download_trained_model_file (model_path , region ):
839+ """
840+ Downloads a trained model to a local file.
798841
842+ MODEL_PATH The path to download the model to, ending with the name of the model.
843+ """
844+ impl_download_trained_model_file (model_path , ensure_s3_bucket (region ), region )
799845
800- @cli .command (name = "download-training-script" )
801- @click .argument ("script-name" )
802- @click .argument ("bucket-name" )
803- @click .option ("--region" , help = "The region to connect to." )
804- def download_training_script (script_name , bucket_name , region ):
805- impl_download_training_script (script_name , bucket_name , region )
806846
847+ @cli .command (name = "download-training-script" )
848+ @click .argument ("script-path" )
849+ @click .option ("--region" , help = "The region to connect to." ,
850+ type = click .Choice (region_choices ))
851+ def download_training_script (script_path , region ):
852+ """
853+ Downloads a training script.
807854
808- @cli .command (name = "download-dataset" )
809- @click .argument ("dataset-name" )
810- @click .argument ("bucket-name" )
811- @click .option ("--region" , help = "The region to connect to." )
812- def download_dataset (dataset_name , bucket_name , region ):
813- impl_download_dataset (dataset_name , bucket_name , region )
855+ SCRIPT_PATH The path to download the script to, ending with the name of the script.
856+ """
857+ impl_download_training_script (script_path , ensure_s3_bucket (region ), region )
814858
815859
816860@cli .command (name = "upload-dataset" )
817- @click .argument ("dataset-name" )
818- @click .argument ("bucket-name" )
819- @click .option ("--region" , help = "The region to connect to." )
820- def upload_dataset (dataset_name , bucket_name , region ):
821- impl_upload_dataset (dataset_name , bucket_name , region )
861+ @click .argument ("dataset-path" )
862+ @click .option ("--region" , help = "The region to connect to." ,
863+ type = click .Choice (region_choices ))
864+ def upload_dataset (dataset_path , region ):
865+ """
866+ Uploads a dataset.
867+
868+ DATASET_PATH The path to the dataset to upload, ending with the name of the dataset.
869+ """
870+ impl_upload_dataset (dataset_path , ensure_s3_bucket (region ), region )
871+
872+
873+ @cli .command (name = "download-dataset" )
874+ @click .argument ("dataset-path" )
875+ @click .option ("--region" , help = "The region to connect to." ,
876+ type = click .Choice (region_choices ))
877+ def download_dataset (dataset_path , region ):
878+ """
879+ Downloads a dataset.
880+
881+ DATASET_PATH The path to download the dataset to, ending with the name of the dataset.
882+ """
883+ impl_download_dataset (dataset_path , ensure_s3_bucket (region ), region )
822884
823885
824886@cli .command (name = "update-training-progress" )
825887@click .argument ("model-name" )
826888@click .argument ("dataset-name" )
827889@click .argument ("progress-text" )
828- @click .argument ("bucket-name" )
829- @click .option ("--region" , help = "The region to connect to." )
830- def update_training_progress (model_name , dataset_name , progress_text , bucket_name , region ):
831- impl_update_training_progress (model_name , dataset_name , progress_text , bucket_name , region )
890+ @click .option ("--region" , help = "The region to connect to." ,
891+ type = click .Choice (region_choices ))
892+ def update_training_progress (model_name , dataset_name , progress_text , region ):
893+ """
894+ Updates the training progress. Meant to be used while a training script is running to provide
895+ progress updates to Axon.
896+
897+ MODEL_NAME The filename of the model currently being trained.
898+
899+ DATASET_NAME The name of the dataset currently being trained on.
900+
901+ PROGRESS_TEXT The text to write to the progress file.
902+ """
903+ impl_update_training_progress (model_name , dataset_name , progress_text , ensure_s3_bucket (region ),
904+ region )
0 commit comments