@@ -638,7 +638,39 @@ def _parse_commitments(commitments: dict, round_number: int, schedule: Schedule,
638638 help = "HuggingFace token to pass as HF_TOKEN environment variable" ,
639639)
640640@click .option ("--name" , "container_name" , default = None , help = "Custom container name (default: generator)" )
641- def start_generator_cmd (image_url : str , targon_api_key : str , hf_token : str | None , container_name : str | None ) -> None :
641+ @click .option (
642+ "--container-concurrency" ,
643+ "container_concurrency" ,
644+ type = int ,
645+ default = 1 ,
646+ show_default = True ,
647+ help = "Maximum concurrent requests per generator replica." ,
648+ )
649+ @click .option (
650+ "--min-replicas" ,
651+ "min_replicas" ,
652+ type = int ,
653+ default = 1 ,
654+ show_default = True ,
655+ help = "Minimum number of generator replicas." ,
656+ )
657+ @click .option (
658+ "--max-replicas" ,
659+ "max_replicas" ,
660+ type = int ,
661+ default = 2 ,
662+ show_default = True ,
663+ help = "Maximum number of generator replicas." ,
664+ )
665+ def start_generator_cmd (
666+ image_url : str ,
667+ targon_api_key : str ,
668+ hf_token : str | None ,
669+ container_name : str | None ,
670+ container_concurrency : int ,
671+ min_replicas : int ,
672+ max_replicas : int ,
673+ ) -> None :
642674 """Start the generator container."""
643675 click .echo (f"Starting generator: { image_url } " , err = True )
644676
@@ -663,6 +695,9 @@ def start_generator_cmd(image_url: str, targon_api_key: str, hf_token: str | Non
663695 health_check_path = _GENERATOR_HEALTH_CHECK_PATH ,
664696 echo = lambda msg : click .echo (msg , err = True ),
665697 env = env ,
698+ container_concurrency = container_concurrency ,
699+ min_replicas = min_replicas ,
700+ max_replicas = max_replicas ,
666701 )
667702 )
668703 click .echo (json .dumps ({"success" : True , "container_url" : container_url }))
@@ -678,7 +713,36 @@ def start_generator_cmd(image_url: str, targon_api_key: str, hf_token: str | Non
678713
679714@cli .command ("start-renderer" )
680715@click .option ("--targon-api-key" , required = True , help = "Targon API key" )
681- def start_renderer_cmd (targon_api_key : str ) -> None :
716+ @click .option (
717+ "--container-concurrency" ,
718+ "container_concurrency" ,
719+ type = int ,
720+ default = 1 ,
721+ show_default = True ,
722+ help = "Maximum concurrent requests per renderer replica." ,
723+ )
724+ @click .option (
725+ "--min-replicas" ,
726+ "min_replicas" ,
727+ type = int ,
728+ default = 1 ,
729+ show_default = True ,
730+ help = "Minimum number of renderer replicas." ,
731+ )
732+ @click .option (
733+ "--max-replicas" ,
734+ "max_replicas" ,
735+ type = int ,
736+ default = 2 ,
737+ show_default = True ,
738+ help = "Maximum number of renderer replicas." ,
739+ )
740+ def start_renderer_cmd (
741+ targon_api_key : str ,
742+ container_concurrency : int ,
743+ min_replicas : int ,
744+ max_replicas : int ,
745+ ) -> None :
682746 """Start the renderer container."""
683747 click .echo (f"Starting renderer: { _RENDER_IMAGE_URL } " , err = True )
684748
@@ -692,6 +756,9 @@ def start_renderer_cmd(targon_api_key: str) -> None:
692756 port = _RENDER_PORT ,
693757 health_check_path = _RENDER_HEALTH_CHECK_PATH ,
694758 echo = lambda msg : click .echo (msg , err = True ),
759+ container_concurrency = container_concurrency ,
760+ min_replicas = min_replicas ,
761+ max_replicas = max_replicas ,
695762 )
696763 )
697764 click .echo (json .dumps ({"success" : True , "container_url" : container_url }))
@@ -709,14 +776,22 @@ def start_renderer_cmd(targon_api_key: str) -> None:
709776@click .option ("--data-dir" , required = True , help = "Path to the directory containing the .ply files to render" )
710777@click .option ("--endpoint" , required = True , help = "Renderer endpoint URL." )
711778@click .option ("--output-dir" , default = "results" , help = "Path to the directory where the rendered images will be saved." )
712- def render_cmd (data_dir : str , endpoint : str , output_dir : str ) -> None :
779+ @click .option (
780+ "--concurrency" ,
781+ type = int ,
782+ default = 1 ,
783+ show_default = True ,
784+ help = "Maximum number of files rendered concurrently." ,
785+ )
786+ def render_cmd (data_dir : str , endpoint : str , output_dir : str , concurrency : int ) -> None :
713787 """Render the .ply files using the renderer endpoint."""
714788 click .echo (f"Rendering { data_dir } with endpoint { endpoint } " , err = True )
715789 try :
716790 renderer = Renderer (
717791 data_dir = data_dir ,
718792 endpoint = endpoint ,
719793 output_dir = output_dir ,
794+ concurrency = concurrency ,
720795 )
721796 asyncio .run (renderer .render ())
722797 click .echo (json .dumps ({"success" : True , "output_dir" : output_dir }))
@@ -833,11 +908,19 @@ async def _stop() -> None:
833908@click .option ("--endpoint" , required = True , help = "Generator endpoint URL." )
834909@click .option ("--seed" , required = True , help = "Seed for generation." )
835910@click .option ("--output-folder" , default = "results" , help = "Folder path where generated .ply files will be saved." )
911+ @click .option (
912+ "--concurrency" ,
913+ type = int ,
914+ default = 8 ,
915+ show_default = True ,
916+ help = "Maximum number of prompts / HTTP requests processed concurrently." ,
917+ )
836918def generate_cmd (
837919 prompts_file : str ,
838920 endpoint : str ,
839921 seed : str ,
840922 output_folder : str ,
923+ concurrency : int ,
841924) -> None :
842925 """Generate models using the generator endpoint."""
843926 # Read prompts from prompt file
@@ -864,6 +947,7 @@ def generate_cmd(
864947 seed = int (seed ),
865948 output_folder = Path (output_folder ),
866949 echo = lambda msg : click .echo (msg , err = True ),
950+ concurrency = concurrency ,
867951 )
868952
869953 try :
@@ -888,6 +972,9 @@ async def _create_container(
888972 echo : Callable [[str ], None ],
889973 args : list [str ] | None = None ,
890974 env : dict [str , str ] | None = None ,
975+ container_concurrency : int = 1 ,
976+ min_replicas : int = 1 ,
977+ max_replicas : int = 2 ,
891978) -> str :
892979 """
893980 Create and deploy a container on Targon.
@@ -914,7 +1001,9 @@ async def _create_container(
9141001 image = image_url ,
9151002 resource_name = resource_name ,
9161003 port = port ,
917- container_concurrency = 1 ,
1004+ container_concurrency = container_concurrency ,
1005+ min_replicas = min_replicas ,
1006+ max_replicas = max_replicas ,
9181007 args = args ,
9191008 env = env ,
9201009 )
0 commit comments