@@ -100,7 +100,17 @@ def pipeline():
100100 is_flag = True ,
101101 help = 'Skip creating config-lock.yaml file.' ,
102102)
103- def upload (path , no_lockfile ):
103+ @click .option (
104+ '--user_id' ,
105+ default = None ,
106+ help = 'Override the user_id from the Clarifai context.' ,
107+ )
108+ @click .option (
109+ '--app_id' ,
110+ default = None ,
111+ help = 'Override the app_id from the Clarifai context.' ,
112+ )
113+ def upload (path , no_lockfile , user_id , app_id ):
104114 """Upload a pipeline with associated pipeline steps to Clarifai.
105115
106116 PATH: Path to the pipeline configuration file or directory containing config.yaml. If not specified, the current directory is used by default.
@@ -110,6 +120,10 @@ def upload(path, no_lockfile):
110120
111121 if os .path .isfile (path ) and path .endswith ('.py' ):
112122 pipeline_obj = load_pipeline_from_file (path )
123+ if user_id :
124+ pipeline_obj .user_id = user_id
125+ if app_id :
126+ pipeline_obj .app_id = app_id
113127 output_dir = os .path .join (
114128 os .path .dirname (os .path .abspath (path )), f'generated-{ pipeline_obj .id } '
115129 )
@@ -128,16 +142,42 @@ def upload(path, no_lockfile):
128142 required = True ,
129143 help = 'Directory to write the compiled pipeline config and step folders.' ,
130144)
131- def compile (path , output_dir ):
132- """Compile YAML/config-based pipeline assets from a Python pipeline definition."""
145+ @click .option ('--user_id' , default = None , help = 'Override the user_id from the Clarifai context.' )
146+ @click .option ('--app_id' , default = None , help = 'Override the app_id from the Clarifai context.' )
147+ def compile (path , output_dir , user_id , app_id ):
148+ """Compile YAML/config-based pipeline assets from a Python pipeline definition.
149+
150+ Generates config.yaml, step directories (with requirements.txt and
151+ pipeline_step.py), and a Dockerfile for each locally managed step.
152+ """
153+ from clarifai .runners .pipeline_steps .pipeline_step_builder import PipelineStepBuilder
133154 from clarifai .runners .pipelines import load_pipeline_from_file
134155
135156 if not os .path .isfile (path ) or not path .endswith ('.py' ):
136157 raise click .UsageError ('clarifai pipeline compile expects a Python file path.' )
137158
138159 pipeline_obj = load_pipeline_from_file (path )
160+ if user_id :
161+ pipeline_obj .user_id = user_id
162+ if app_id :
163+ pipeline_obj .app_id = app_id
139164 config_path = pipeline_obj .generate (output_dir )
140- logger .info (f"Generated pipeline assets at { config_path } " )
165+
166+ # Generate Dockerfiles for all locally managed step directories.
167+ seen : set = set ()
168+ step_ids = []
169+ for node in pipeline_obj .nodes :
170+ sid = node .step_definition .id
171+ if node .step_definition .is_managed and sid not in seen :
172+ seen .add (sid )
173+ step_ids .append (sid )
174+ for step_id in step_ids :
175+ step_dir = os .path .join (output_dir , step_id )
176+ if os .path .isdir (step_dir ):
177+ PipelineStepBuilder (step_dir ).create_dockerfile ()
178+ logger .info (f"Generated Dockerfile for step '{ step_id } '" )
179+
180+ logger .info (f'Generated pipeline assets at { config_path } ' )
141181
142182
143183@pipeline .command ()
@@ -1049,7 +1089,7 @@ def validate_lock(lockfile_path):
10491089 raise click .Abort ()
10501090
10511091
1052- @pipeline .command (['ls' ])
1092+ @pipeline .command (name = 'list' , aliases = ['ls' ])
10531093@click .option ('--page_no' , required = False , help = 'Page number to list.' , default = 1 )
10541094@click .option ('--per_page' , required = False , help = 'Number of items per page.' , default = 16 )
10551095@click .option (
@@ -1063,7 +1103,7 @@ def validate_lock(lockfile_path):
10631103 help = 'User ID to list pipelines from. If not provided, uses current user.' ,
10641104)
10651105@click .pass_context
1066- def list (ctx , page_no , per_page , app_id , user_id ):
1106+ def list_pipelines (ctx , page_no , per_page , app_id , user_id ):
10671107 """List all pipelines for the user."""
10681108 validate_context (ctx )
10691109
0 commit comments