@@ -172,38 +172,41 @@ setup_worker(Node) ->
172172 % % Ensure application is started
173173 ok = rpc :call (Node , application , ensure_all_started , [erlang_python ]),
174174
175- % % Setup virtual environment with dependencies
175+ % % Setup virtual environment with requirements file
176176 {ok , VenvPath } = rpc :call (Node , py , ensure_venv , [
177177 <<" /opt/app/venv" >>,
178- [ <<" numpy " >>, << " pandas " >>, << " scikit-learn " >>]
178+ <<" /opt/app/requirements.txt " >>
179179 ]),
180180
181181 % % Verify setup
182- {ok , true } = rpc :call (Node , py , eval , [<<" 'numpy' in dir( )" >>]),
182+ {ok , _ } = rpc :call (Node , py , eval , [<<" __import__( 'numpy')" >>]),
183183 ok .
184184```
185185
186186### Reproducible Environments
187187
188- Create identical environments across all nodes:
188+ Create identical environments across all nodes using a shared requirements file :
189189
190190``` erlang
191- % % Define environment specification
192- -define (PYTHON_DEPS , [
193- <<" numpy==1.26.0" >>,
194- <<" pandas==2.1.0" >>,
195- <<" scikit-learn==1.3.0" >>,
196- <<" torch==2.1.0" >>
197- ]).
198-
199- % % Setup all worker nodes
200- setup_cluster (Nodes ) ->
191+ % % Setup all worker nodes with same requirements.txt
192+ setup_cluster (Nodes , RequirementsFile ) ->
201193 lists :foreach (fun (Node ) ->
202194 {ok , _ } = rpc :call (Node , py , ensure_venv , [
203195 <<" /opt/app/venv" >>,
204- ? PYTHON_DEPS
196+ RequirementsFile
205197 ])
206198 end , Nodes ).
199+
200+ % % Usage:
201+ % % setup_cluster(Nodes, <<"/shared/requirements.txt">>).
202+ ```
203+
204+ Where ` requirements.txt ` contains:
205+ ```
206+ numpy==1.26.0
207+ pandas==2.1.0
208+ scikit-learn==1.3.0
209+ torch==2.1.0
207210```
208211
209212## Parallel Execution Patterns
0 commit comments