1414/// + support for constructor specialization will help avoid duplication here.
1515/// TODO: Potentially too many clones of slice objects, might need to refactor to avoid that.
1616use std:: collections:: HashMap ;
17- use std:: fs:: File ;
18- use std:: io:: BufReader ;
1917use std:: ops:: DerefMut ;
20- use std:: os:: fd:: FromRawFd ;
21- use std:: os:: fd:: OwnedFd ;
2218
2319use anyhow:: Result ;
24- use clap:: Parser ;
2520use hyperactor:: data:: Serialized ;
2621use hyperactor:: reference:: ActorId ;
2722use monarch_hyperactor:: ndslice:: PySlice ;
@@ -30,10 +25,6 @@ use monarch_hyperactor::runtime::get_tokio_runtime;
3025use monarch_messages:: wire_value:: WireValue ;
3126use monarch_messages:: wire_value:: func_call_args_to_wire_values;
3227use monarch_messages:: worker:: * ;
33- use monarch_tensor_worker:: bootstrap:: BinaryArgs ;
34- use monarch_tensor_worker:: bootstrap:: bootstrap_pipe;
35- use monarch_tensor_worker:: bootstrap:: bootstrap_worker_proc;
36- use monarch_tensor_worker:: bootstrap:: worker_server;
3728use monarch_types:: TryIntoPyObjectUnsafe ;
3829use pyo3:: IntoPyObjectExt ;
3930use pyo3:: exceptions:: PyRuntimeError ;
@@ -1377,33 +1368,6 @@ pub(crate) fn worker_message_to_py(py: Python<'_>, message: &WorkerMessage) -> P
13771368 }
13781369}
13791370
1380- /// The Python main entry point of the monarch worker from Python. It allows to bundle Python dependencies
1381- /// during packaging.
1382- #[ pyfunction]
1383- fn worker_main ( py : Python < ' _ > ) -> PyResult < ( ) > {
1384- let argv: Vec < String > = py. import ( "sys" ) ?. getattr ( "argv" ) ?. extract ( ) ?;
1385- Python :: allow_threads ( py, move || {
1386- let args = BinaryArgs :: parse_from ( argv) ;
1387-
1388- match args {
1389- BinaryArgs :: Pipe => bootstrap_pipe ( ) ,
1390- BinaryArgs :: WorkerServer { rd, wr } => {
1391- worker_server (
1392- // SAFETY: Raw FD passed in from parent.
1393- BufReader :: new ( File :: from ( unsafe { OwnedFd :: from_raw_fd ( rd) } ) ) ,
1394- // SAFETY: Raw FD passed in from parent.
1395- File :: from ( unsafe { OwnedFd :: from_raw_fd ( wr) } ) ,
1396- )
1397- }
1398- BinaryArgs :: Worker ( args) => get_tokio_runtime ( ) . block_on ( async move {
1399- let _ = bootstrap_worker_proc ( args) . await ?. await ;
1400- Ok ( ( ) )
1401- } ) ,
1402- }
1403- . map_err ( |err : anyhow:: Error | PyRuntimeError :: new_err ( err. to_string ( ) ) )
1404- } )
1405- }
1406-
14071371pub ( crate ) fn register_python_bindings ( worker_mod : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
14081372 worker_mod. add_class :: < PyWorkerMessage > ( ) ?;
14091373 worker_mod. add_class :: < BackendNetworkInit > ( ) ?;
@@ -1438,12 +1402,6 @@ pub(crate) fn register_python_bindings(worker_mod: &Bound<'_, PyModule>) -> PyRe
14381402 worker_mod. add_class :: < RecordingFormal > ( ) ?;
14391403 worker_mod. add_class :: < RecordingResult > ( ) ?;
14401404 worker_mod. add_class :: < CallRecording > ( ) ?;
1441- let f = wrap_pyfunction ! ( worker_main, worker_mod) ?;
1442- f. setattr (
1443- "__module__" ,
1444- "monarch._rust_bindings.monarch_extension.tensor_worker" ,
1445- ) ?;
1446- worker_mod. add_function ( f) ?;
14471405
14481406 Ok ( ( ) )
14491407}
0 commit comments