-
Notifications
You must be signed in to change notification settings - Fork 22
/
App_Python.tex
4210 lines (3017 loc) · 120 KB
/
App_Python.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Appendix: Python bindings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Python Bindings}
\label{app:python}
While the \ac{PMIx} Standard is defined in terms of C-based \acp{API}, there is no intent to limit the use of \ac{PMIx} to that specific language. Support for other languages is captured in the Standard by describing their equivalent syntax for the \ac{PMIx} \acp{API} and native forms for the \ac{PMIx} datatypes. This Appendix specifically deals with Python interfaces, beginning with a review of the \ac{PMIx} datatypes. Support is restricted to Python 3 and above - i.e., the Python bindings do not support Python 2.
Note: the \ac{PMIx} \acp{API} have been loosely collected into three Python classes based on their \ac{PMIx} “class” (i.e., client, server, and tool). All processes have access to a basic set of the \acp{API}, and therefore those have been included in the “client” class. Servers can utilize any of those functions plus a set focused on operations not commonly executed by an application process. Finally, tools can also act as servers but have their own initialization function.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Design Considerations}
\label{app:python:design}
Several issues arose during design of the Python bindings:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Error Codes vs Python Exceptions}
\label{app:python:exceptions}
The C programming language reports errors through the return of the corresponding integer status codes. \ac{PMIx} has defined a range of negative values for this purpose. However, Python has the option of raising \emph{exceptions} that effectively operate as interrupts that can be trapped if the program appropriately tests for them. The \ac{PMIx} Python bindings opted to follow the C-based standard and return \ac{PMIx} status codes in lieu of raising exceptions as this method was considered more consistent for those working in both domains.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Representation of Structured Data}
\label{app:python:rep}
\ac{PMIx} utilizes a number of C-language structures to efficiently bundle related information. For example, the \ac{PMIx} process identifier is represented as a struct containing a character array for the namespace and a 32-bit unsigned integer for the process rank. There are several options for translating such objects to Python – e.g., the \ac{PMIx} process identifier could be represented as a two-element tuple (nspace, rank) or as a dictionary {‘nspace’: name, ‘rank’: 0}. Exploration found no discernible benefit to either representation, nor was any clearly identifiable rationale developed that would lead a user to expect one versus the other for a given \ac{PMIx} data type. Consistency in the translation (i.e., exclusively using tuple or dictionary) appeared to be the most important criterion. Hence, the decision was made to express all complex datatypes as Python dictionaries.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Datatype Definitions}
\label{app:python:types}
\ac{PMIx} defines a number of datatypes comprised of fixed-size character arrays, restricted range integers (e.g., uint32_t), and structures. Each datatype is represented by a named unsigned 16-bit integer (\code{uint16_t}) constant. Users are advised to use the named \ac{PMIx} constants for indicating datatypes instead of integer values to ensure compatibility with future PMIx versions.
With only a few exceptions, the C-based \ac{PMIx} datatypes defined in \chapterref{chap:struct} directly translate to Python. However, Python lacks the size-specific value definitions of C (e.g., \code{uint8_t}) and thus some care must be taken to protect against overflow/underflow situations when moving between the languages. Python bindings that accept values including \ac{PMIx} datatypes shall therefore have the datatype and associated value checked for compatibility with their \ac{PMIx}-defined equivalents, returning an error if:
\begin{itemize}
\item datatypes not defined by \ac{PMIx} are encountered
\item provided values fall outside the range of the C-equivalent definition - e.g., if a value identified as \refconst{PMIX_UINT8} lies outside the \code{uint8_t}range
\end{itemize}
Note that explicit labeling of \ac{PMIx} data type, even when Python itself doesn’t care, is often required for the Python bindings to know how to properly interpret and label the provided value when passing it to the \ac{PMIx} library.
Table~\ref{app:python:ctopy} lists the correspondence between data types in the two languages.
\begin{landscape}
\begin{small}
\begin{longtable}{ | p{4.5cm} | p{4cm} | p{3cm} | p{5.5cm} |}
\caption{C-to-Python Datatype Correspondence} \label{app:python:ctopy} \\
\hline
C-Definition & PMIx Name & Python Definition & Notes \\ \hline
\endhead
\code{bool} & \refconst{PMIX_BOOL} & boolean & \\ \hline
\code{byte} & \refconst{PMIX_BYTE} & A single element byte array (i.e., a byte array of length one) & \\ \hline
\code{char*} & \refconst{PMIX_STRING} & string & \\ \hline
\code{size_t} & \refconst{PMIX_SIZE} & integer & \\ \hline
\code{pid_t} & \refconst{PMIX_PID} & integer & value shall be limited to the \code{uint32_t} range \\ \hline
\code{int, int8_t, int16_t, int32_t, int64_t} & \refconst{PMIX_INT}, \refconst{PMIX_INT8}, \refconst{PMIX_INT16}, \refconst{PMIX_INT32}, \refconst{PMIX_INT64} & integer & value shall be limited to its corresponding range \\ \hline
\code{uint, uint8_t, uint16_t, uint32_t, uint64_t} & \refconst{PMIX_UINT}, \refconst{PMIX_UINT8}, \refconst{PMIX_UINT16}, \refconst{PMIX_UINT32}, \refconst{PMIX_UINT64} & integer & value shall be limited to its corresponding range \\ \hline
\code{float, double} & \refconst{PMIX_FLOAT}, \refconst{PMIX_DOUBLE} & float & value shall be limited to its corresponding range \\ \hline
\code{struct timeval} & \refconst{PMIX_TIMEVAL} & \{'sec': sec, 'usec': microsec\} & each field is an integer value \\ \hline
\code{time_t} & \refconst{PMIX_TIME} & integer & limited to positive values \\ \hline
\refstruct{pmix_data_type_t} & \refconst{PMIX_DATA_TYPE} & integer & value shall be limited to the \code{uint16_t} range \\ \hline
\refstruct{pmix_status_t} & \refconst{PMIX_STATUS} & integer & \\ \hline
\refstruct{pmix_key_t} & N/A & \pylabel{key}string & The string's length shall be limited to one less than the size of the \refstruct{pmix_key_t} array (to reserve space for the terminating \code{NULL}) \\ \hline
\refstruct{pmix_nspace_t} & N/A & \pylabel{nspace}string & The string's length shall be limited to one less than the size of the \refstruct{pmix_nspace_t} array (to reserve space for the terminating \code{NULL}) \\ \hline
\refstruct{pmix_rank_t} & \refconst{PMIX_PROC_RANK} & \pylabel{rank}integer & value shall be limited to the \code{uint32_t} range excepting the reserved values near \code{UINT32_MAX} \\ \hline
\refstruct{pmix_proc_t} & \refconst{PMIX_PROC} & \pylabel{proc}\{'nspace': nspace, 'rank': rank\} & \refarg{nspace} is a Python string and \refarg{rank} is an integer value. The \refarg{nspace} string's length shall be limited to one less than the size of the \refstruct{pmix_nspace_t} array (to reserve space for the terminating \code{NULL}), and the \refarg{rank} value shall conform to the constraints associated with \refstruct{pmix_rank_t} \\ \hline
\refstruct{pmix_byte_object_t} & \refconst{PMIX_BYTE_OBJECT} & \pylabel{byteobject}\{'bytes': bytes, 'size': size\} & \refarg{bytes} is a Python byte array and \refarg{size} is the integer number of bytes in that array. \\ \hline
\refstruct{pmix_persistence_t} & \refattr{PMIX_PERSISTENCE} & integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_scope_t} & \refconst{PMIX_SCOPE} & integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_data_range_t} & \refattr{PMIX_RANGE} & \pylabel{range}integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_proc_state_t} & \refconst{PMIX_PROC_STATE} & integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_proc_info_t} & \refconst{PMIX_PROC_INFO} & \{'proc': \{'nspace': nspace, 'rank': rank\}, 'hostname': hostname, 'executable': executable, 'pid': pid, 'exitcode': exitcode, 'state': state\} & \refarg{proc} is a Python \refpy{proc} dictionary; \refarg{hostname} and \refarg{executable} are Python strings; and \refarg{pid}, \refarg{exitcode}, and \refarg{state} are Python integers \\ \hline
\refstruct{pmix_data_array_t} & \refconst{PMIX_DATA_ARRAY} & \pylabel{array}\{'type': type, 'array': array\} & \refarg{type} is the \ac{PMIx} type of object in the array and \refarg{array} is a Python \emph{list} containing the individual array elements. Note that \refarg{array} can consist of \emph{any} \ac{PMIx} types, including (for example) a Python \refpy{info} object that itself contains an \refpy{array} value \\ \hline
\refstruct{pmix_info_directives_t} & \refconst{PMIX_INFO_DIRECTIVES} & \pylabel{info directives}list & list of integer values (defined in Section \ref{api:struct:infodirs}) \\ \hline
\refstruct{pmix_alloc_directive_t} & \refconst{PMIX_ALLOC_DIRECTIVE} & \pylabel{allocdir}integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_iof_channel_t} & \refconst{PMIX_IOF_CHANNEL} & \pylabel{channel}list & list of integer values (defined in Section \ref{api:tool:iofchannels}) \\ \hline
\refstruct{pmix_envar_t} & \refconst{PMIX_ENVAR} & \{'envar': envar, 'value': value, 'separator': separator\} & \refarg{envar} and \refarg{value} are Python strings, and \refarg{separator} a single-character Python string \\ \hline
\refstruct{pmix_value_t} & \refconst{PMIX_VALUE} & \pylabel{value}\{'value': value, 'val_type': type\} & \refarg{type} is the \ac{PMIx} datatype of \refarg{value}, and \refarg{value} is the associated value expressed in the appropriate Python form for the specified datatype \\ \hline
\refstruct{pmix_info_t} & \refconst{PMIX_INFO} & \pylabel{info}\{'key': key, 'flags': flags, value': value, 'val_type': type\} & \refarg{key} is a Python string \refpy{key}, \refarg{flags} is an \refpy{info directives} value, \refarg{type} is the \ac{PMIx} datatype of \refarg{value}, and \refarg{value} is the associated value expressed in the appropriate Python form for the specified datatype \\ \hline
\refstruct{pmix_pdata_t} & \refconst{PMIX_PDATA} & \pylabel{pdata}\{'proc': \{'nspace': nspace, 'rank': rank\}, 'key': key, 'value': value, 'val_type': type\} & \refarg{proc} is a Python \refpy{proc} dictionary; \refarg{key} is a Python string \refpy{key}; \refarg{type} is the \ac{PMIx} datatype of \refarg{value}; and \refarg{value} is the associated value expressed in the appropriate Python form for the specified datatype \\ \hline
\refstruct{pmix_app_t} & \refconst{PMIX_APP} & \pylabel{app}\{'cmd': cmd, 'argv': [argv], 'env': [env], 'maxprocs': maxprocs, 'info': [info]\} & \refarg{cmd} is a Python string; \refarg{argv} and \refarg{env} are Python \emph{lists} containing Python strings; \refarg{maxprocs} is an integer; and \refarg{info} is a Python \emph{list} of \refpy{info} values \\ \hline
\refstruct{pmix_query_t} & \refconst{PMIX_QUERY} & \pylabel{query}\{'keys': [keys], 'qualifiers': [info]\} & \refarg{keys} is a Python \emph{list} of Python strings, and \refarg{qualifiers} is a Python \emph{list} of \refpy{info} values \\ \hline
\refstruct{pmix_regattr_t} & \refconst{PMIX_REGATTR} & \pylabel{regattr}\{'name': name, 'key': key, 'type': type, 'info': [info], 'description': [desc]\} & \refarg{name} and \refarg{string} are Python strings; \refarg{type} is the \ac{PMIx} datatype for the attribute's value; \refarg{info} is a Python \emph{list} of \refpy{info} values; and \refarg{description} is a list of Python strings describing the attribute \\ \hline
\refstruct{pmix_job_state_t} & \refconst{PMIX_JOB_STATE} & integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_link_state_t} & \refconst{PMIX_LINK_STATE} & integer & value shall be limited to the \code{uint8_t} range \\ \hline
\refstruct{pmix_cpuset_t} & \refconst{PMIX_PROC_CPUSET} & \pylabel{cpuset}\{'source': source, 'cpus': bitmap\} & \refarg{source} is a string name of the library that created the cpuset; and \refarg{cpus} is a list of string ranges identifying the \acp{PU} to which the process is bound (e.g., [1, 3-5, 7]) \\ \hline
\refstruct{pmix_locality_t} & \refconst{PMIX_LOCTYPE} & \pylabel{locality}list & list of integer values (defined in Section \ref{api:proc:locality}) describing the relative locality of the specified local process \\ \hline
\refstruct{pmix_fabric_t} & N/A & \pylabel{fabric}\{'name': name, 'index': idx, 'info': [info]\} & \refarg{name} is the string name assigned to the fabric; \refarg{index} is the integer ID assigned to the fabric; \refarg{info} is a list of \refpy{info} describing the fabric \\ \hline
\refstruct{pmix_endpoint_t} & \refconst{PMIX_ENDPOINT} & \pylabel{endpoint}\{'uuid': uuid, 'osname': osname, endpt': endpt\} & \refarg{uuid} is the string system-unique identifier assigned to the device; \refarg{osname} is the operating system name assigned to the device; \refarg{endpt} is a \refpy{byteobject} containing the endpoint information \\ \hline
\refstruct{pmix_device_distance_t} & \refconst{PMIX_DEVICE_DIST} & \pylabel{devdist}\{'uuid': uuid, 'osname': osname, mindist': mindist, 'maxdist': maxdist\} & \refarg{uuid} is the string system-unique identifier assigned to the device; \refarg{osname} is the operating system name assigned to the device; and \refarg{mindist} and \refarg{maxdist} are Python integers \\ \hline
\refstruct{pmix_coord_t} & \refconst{PMIX_COORD} & \pylabel{coord}\{'view': view, 'coord': [coords]\} & \refarg{view} is the \refstruct{pmix_coord_view_t} of the coordinate; and \refarg{coord} is a list of integer coordinates, one for each dimension of the fabric \\ \hline
\refstruct{pmix_geometry_t} & \refconst{PMIX_GEOMETRY} & \pylabel{geometry}\{'fabric': idx, 'uuid': uuid, 'osname': osname, coordinates': [coords]\} & \refarg{fabric} is the Python integer index of the fabric; \refarg{uuid} is the string system-unique identifier assigned to the device; \refarg{osname} is the operating system name assigned to the device; and \refarg{coordinates} is a list of \refpy{coord} containing the coordinates for the device across all views \\ \hline
\refstruct{pmix_device_type_t} & \refconst{PMIX_DEVTYPE} & \pylabel{devtype}list & list of integer values (defined in Section \ref{api:proc:devtype}) \\ \hline
\refstruct{pmix_bind_envelope_t} & N/A & \pylabel{bindenv}integer & one of the values defined in Section \ref{api:proc:bindenv} \\ \hline
\end{longtable}
\end{small}
\end{landscape}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Example}
Converting a C-based program to its Python equivalent requires translation of the relevant datatypes as well as use of the appropriate \ac{API} form. An example small program may help illustrate the changes. Consider the following C-based program snippet:
\cspecificstart
\begin{codepar}
#include <pmix.h>
...
pmix_info_t info[2];
PMIx_Info_load(&info[0], PMIX_PROGRAMMING_MODEL, "TEST", PMIX_STRING)
PMIx_Info_load(&info[1], PMIX_MODEL_LIBRARY_NAME, "PMIX", PMIX_STRING)
rc = PMIx_Init(&myproc, info, 2);
PMIX_INFO_DESTRUCT(&info[0]); // free the copied string
PMIX_INFO_DESTRUCT(&info[1]); // free the copied string
\end{codepar}
\cspecificend
Moving to the Python version requires that the \refstruct{pmix_info_t} be translated to the Python \refpy{info} equivalent, and that the returned information be captured in the return parameters as opposed to a pointer parameter in the function call, as shown below:
\pyspecificstart
\begin{codepar}
import pmix
...
myclient = PMIxClient()
info = [\{'key':PMIX_PROGRAMMING_MODEL,
'value':'TEST', 'val_type':PMIX_STRING\},
\{'key':PMIX_MODEL_LIBRARY_NAME,
'value':'PMIX', 'val_type':PMIX_STRING\}]
(rc,myproc) = myclient.init(info)
\end{codepar}
\pyspecificend
Note the use of the \refconst{PMIX_STRING} identifier to ensure the Python bindings interpret the provided string value as a \ac{PMIx} "string" and not an array of bytes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Callback Function Definitions}
\label{app:python:fns}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{IOF Delivery Function}
\pylabel{iofcbfunc}
\declareapibinding{iofcbfunc}{pmix_iof_cbfunc_t}{Python}
%%%%
\summary
Callback function for delivering forwarded \ac{IO} to a process
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def iofcbfunc(iofhdlr:integer, channel:bitarray,
source:dict, payload:dict, info:list)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{iofhdlr}{Registration number of the handler being invoked (integer)}
\argin{channel}{Python \refpy{channel} 16-bit bitarray identifying the channel the data arrived on (bitarray)}
\argin{source}{Python \refpy{proc} identifying the namespace/rank of the process that generated the data (dict)}
\argin{payload}{Python \refpy{byteobject} containing the data (dict)}
\argin{info}{List of Python \refpy{info} provided by the source containing metadata about the payload. This could include \refattr{PMIX_IOF_COMPLETE} (list)}
\end{arglist}
Returns: nothing
See \refapi{pmix_iof_cbfunc_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Event Handler}
\pylabel{evhandler}
\declareapibinding{evhandler}{pmix_notification_fn_t}{Python}
%%%%
\summary
Callback function for event handlers
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def evhandler(evhdlr:integer, status:integer,
source:dict, info:list, results:list)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{iofhdlr}{Registration number of the handler being invoked (integer)}
\argin{status}{Status associated with the operation (integer)}
\argin{source}{Python \refpy{proc} identifying the namespace/rank of the process that generated the event (dict)}
\argin{info}{List of Python \refpy{info} provided by the source containing metadata about the event (list)}
\argin{results}{List of Python \refpy{info} containing the aggregated results of all prior evhandlers (list)}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - Status returned by the event handler's operation (integer)
\item \refarg{results} - List of Python \refpy{info} containing results from this event handler's operation on the event (list)
\end{itemize}
See \refapi{pmix_notification_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Server Module Functions}
\pylabel{server module}
The following definitions represent functions that may be provided to the \ac{PMIx} server library at time of initialization for servicing of client requests. Module functions that are not provided default to returning "not supported" to the caller.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Client Connected}
\declareapibinding{clientconnected2}{pmix_server_client_connected2_fn_t}{Python}
%%%%
\summary
Notify the host server that a client connected to this server.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def clientconnected2(proc:dict is not None, info:list)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{proc}{Python \refpy{proc} identifying the namespace/rank of the process that connected (dict)}
\argin{info}{list of Python \refpy{info} containing information about the process (list)}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the connection should be rejected (integer)
\end{itemize}
See \refapi{pmix_server_client_connected2_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Client Finalized}
\declareapibinding{clientfinalized}{pmix_server_client_finalized_fn_t}{Python}
%%%%
\summary
Notify the host environment that a client called \refapi{PMIx_Finalize}.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def clientfinalized(proc:dict is not None):
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{proc}{Python \refpy{proc} identifying the namespace/rank of the process that finalized (dict)}
\end{arglist}
Returns: nothing
See \refapi{pmix_server_client_finalized_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Client Aborted}
\declareapibinding{clientaborted}{pmix_server_abort_fn_t}{Python}
%%%%
\summary
Notify the host environment that a local client called \refapi{PMIx_Abort}.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def clientaborted(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'caller': Python \refpy{proc} identifying the namespace/rank of the process calling abort (dict)
\item 'status': PMIx status to be returned on exit (integer)
\item 'msg': Optional string message to be printed (string)
\item 'targets': Optional list of Python \refpy{proc} identifying the namespace/rank of the processes to be aborted (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_abort_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Fence}
\declareapibinding{fence}{pmix_server_fencenb_fn_t}{Python}
%%%%
\summary
At least one client called either \refapi{PMIx_Fence} or \refapi{PMIx_Fence_nb}
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def fence(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'procs': List of Python \refpy{proc} identifying the namespace/rank of the participating processes (list)
\item 'directives': Optional list of Python \refpy{info} containing directives controlling the operation (list)
\item 'data': Optional Python bytearray of data to be circulated during fence operation (bytearray)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{data} - Python bytearray containing the aggregated data from all participants (bytearray)
\end{itemize}
See \refapi{pmix_server_fencenb_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Direct Modex}
\declareapibinding{dmodex}{pmix_server_dmodex_req_fn_t}{Python}
%%%%
\summary
Used by the PMIx server to request its local host contact the \ac{PMIx} server on the remote node that hosts the specified proc to obtain and return a direct modex blob for that proc.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def dmodex(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'proc': Python \refpy{proc} of process whose data is being requested (dict)
\item 'directives': Optional list of Python \refpy{info} containing directives controlling the operation (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{data} - Python bytearray containing the data for the specified process (bytearray)
\end{itemize}
See \refapi{pmix_server_dmodex_req_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Publish}
\declareapibinding{publish}{pmix_server_publish_fn_t}{Python}
%%%%
\summary
Publish data per the PMIx API specification.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def publish(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'proc': Python \refpy{proc} dictionary of process publishing the data (dict)
\item 'directives': List of Python \refpy{info} containing data and directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_publish_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Lookup}
\declareapibinding{lookup}{pmix_server_lookup_fn_t}{Python}
%%%%
\summary
Lookup published data.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def lookup(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'proc': Python \refpy{proc} of process seeking the data (dict)
\item 'keys': List of Python strings (list)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{pdata} - List of \refpy{pdata} containing the returned results (list)
\end{itemize}
See \refapi{pmix_server_lookup_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Unpublish}
\declareapibinding{unpublish}{pmix_server_unpublish_fn_t}{Python}
%%%%
\summary
Delete data from the data store.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def unpublish(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'proc': Python \refpy{proc} of process unpublishing data (dict)
\item 'keys': List of Python strings (list)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_unpublish_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Spawn}
\declareapibinding{spawn}{pmix_server_spawn_fn_t}{Python}
%%%%
\summary
Spawn a set of applications/processes as per the \refapi{PMIx_Spawn} API.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def spawn(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'proc': Python \refpy{proc} of process making the request (dict)
\item 'jobinfo': Optional list of Python \refpy{info} job-level directives and information (list)
\item 'apps': List of Python \refpy{app} describing applications to be spawned (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{nspace} - Python string containing namespace of the spawned job (str)
\end{itemize}
See \refapi{pmix_server_spawn_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Connect}
\declareapibinding{connect}{pmix_server_connect_fn_t}{Python}
%%%%
\summary
Record the specified processes as \textit{connected}.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def connect(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'procs': List of Python \refpy{proc} identifying the namespace/rank of the participating processes (list)
\item 'directives': Optional list of Python \refpy{info} containing directives controlling the operation (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_connect_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Disconnect}
\declareapibinding{disconnect}{pmix_server_disconnect_fn_t}{Python}
%%%%
\summary
Disconnect a previously connected set of processes.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def disconnect(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'procs': List of Python \refpy{proc} identifying the namespace/rank of the participating processes (list)
\item 'directives': Optional list of Python \refpy{info} containing directives controlling the operation (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_disconnect_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Register Events}
\declareapibinding{register_events}{pmix_server_register_events_fn_t}{Python}
%%%%
\summary
Register to receive notifications for the specified events.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def register_events(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'codes': List of Python integers (list)
\item 'directives': Optional list of Python \refpy{info} containing directives controlling the operation (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_register_events_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Deregister Events}
\declareapibinding{deregister_events}{pmix_server_deregister_events_fn_t}{Python}
%%%%
\summary
Deregister to receive notifications for the specified events.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def deregister_events(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'codes': List of Python integers (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_deregister_events_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Notify Event}
\declareapibinding{notify_event}{pmix_server_notify_event_fn_t}{Python}
%%%%
\summary
Notify the specified range of processes of an event.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def notify_event(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'code': Python integer \refstruct{pmix_status_t} (integer)
\item 'source': Python \refpy{proc} of process that generated the event (dict)
\item 'range': Python \refpy{range} in which the event is to be reported (integer)
\item 'directives': Optional list of Python \refpy{info} directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_notify_event_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Query}
\declareapibinding{query}{pmix_server_query_fn_t}{Python}
%%%%
\summary
Query information from the resource manager.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def query(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'queries': List of Python \refpy{query} directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{info} - List of Python \refpy{info} containing the returned results (list)
\end{itemize}
See \refapi{pmix_server_query_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Tool Connected}
\declareapibinding{tool_connected}{pmix_server_tool_connection_fn_t}{Python}
%%%%
\summary
Register that a tool has connected to the server.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def tool_connected(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'directives': Optional list of Python \refpy{info} info on the connecting tool (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{proc} - Python \refpy{proc} containing the assigned namespace:rank for the tool (dict)
\end{itemize}
See \refapi{pmix_server_tool_connection_fn_t} for details
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Log}
\declareapibinding{log}{pmix_server_log_fn_t}{Python}
%%%%
\summary
Log data on behalf of a client.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def log(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'data': Optional list of Python \refpy{info} containing data to be logged (list)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_log_fn_t} for details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Allocate Resources}
\declareapibinding{allocate}{pmix_server_alloc_fn_t}{Python}
%%%%
\summary
Request allocation operations on behalf of a client.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def allocate(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'action': Python \refpy{allocdir} specifying requested action (integer)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item refarg{info} - List of Python \refpy{info} containing results of requested operation (list)
\end{itemize}
See \refapi{pmix_server_alloc_fn_t} for details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Job Control}
\declareapibinding{job_control}{pmix_server_job_control_fn_t}{Python}
%%%%
\summary
Execute a job control action on behalf of a client.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def job_control(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'targets': List of Python \refpy{proc} specifying target processes (list)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_job_control_fn_t} for details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Monitor}
\declareapibinding{monitor}{pmix_server_monitor_fn_t}{Python}
%%%%
\summary
Request that a client be monitored for activity.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def monitor(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'monitor': Python \refpy{info} attribute indicating the type of monitor being requested (dict)
\item 'error': Status code to be used when generating an event notification (integer) alerting that the monitor has been triggered.
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\end{itemize}
See \refapi{pmix_server_monitor_fn_t} for details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Get Credential}
\declareapibinding{get_credential}{pmix_server_get_cred_fn_t}{Python}
%%%%
\summary
Request a credential from the host environment.
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def get_credential(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns:
\begin{itemize}
\item \refarg{rc} - \refconst{PMIX_SUCCESS} or a \ac{PMIx} error code indicating the operation failed (integer)
\item \refarg{cred} - Python \refpy{byteobject} containing returned credential (dict)
\item \refarg{info} - List of Python \refpy{info} containing any additional info about the credential (list)
\end{itemize}
See \refapi{pmix_server_get_cred_fn_t} for details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Validate Credential}
\declareapibinding{validate_credential}{pmix_server_validate_cred_fn_t}{Python}
%%%%
\summary
Request validation of a credential
%%%%
\format
\versionMarker{4.0}
\pyspecificstart
\begin{codepar}
def validate_credential(args:dict is not None)
\end{codepar}
\pyspecificend
\begin{arglist}
\argin{args}{Python dictionary containing:
\begin{itemize}
\item 'source': Python \refpy{proc} of requesting process (dict)
\item 'credential': Python \refpy{byteobject} containing credential (dict)
\item 'directives': Optional list of Python \refpy{info} containing directives (list)
\end{itemize}}
\end{arglist}
Returns: