@@ -1315,6 +1315,7 @@ def process(
1315
1315
except :
1316
1316
self .logger .warning ('Unable to load mpi4py, running serially' )
1317
1317
num_proc = 1
1318
+ self .logger .debug (f'Number of processors: { num_proc } ' )
1318
1319
1319
1320
# Create the sub-pipeline configuration for each processor
1320
1321
# FIX: catered to EDD with one spec scan
@@ -1343,7 +1344,7 @@ def process(
1343
1344
num = scans_per_proc
1344
1345
if n_proc < num_scan - scans_per_proc * num_proc :
1345
1346
num += 1
1346
- config = map_config .model_dump_json ()
1347
+ config = map_config .model_dump ()
1347
1348
config ['spec_scans' ][0 ]['scan_numbers' ] = \
1348
1349
scan_numbers [n_scan :n_scan + num ]
1349
1350
pipeline_config .append (
@@ -1427,12 +1428,10 @@ def process(
1427
1428
os .remove (tmp_name )
1428
1429
1429
1430
# Construct the NeXus NXroot object
1430
- nxroot = self ._get_nxroot (
1431
+ return self ._get_nxroot (
1431
1432
map_config , detector_config , data , independent_dimensions ,
1432
1433
all_scalar_data , placeholder_data )
1433
1434
1434
- return nxroot
1435
-
1436
1435
def _get_nxroot (
1437
1436
self , map_config , detector_config , data , independent_dimensions ,
1438
1437
all_scalar_data , placeholder_data ):
@@ -1913,20 +1912,32 @@ def process(self, data, comm, root_as_worker=True):
1913
1912
data = [comm .recv (source = n_worker )]
1914
1913
else :
1915
1914
data .append (comm .recv (source = n_worker ))
1915
+ #FIX RV TODO Merge the list of data items in some generic fashion
1916
1916
return data
1917
1917
1918
1918
1919
1919
class MPIMapProcessor (Processor ):
1920
1920
"""A Processor that applies a parallel generic sub-pipeline to
1921
1921
a map configuration.
1922
1922
"""
1923
- def process (self , data , sub_pipeline = None ):
1923
+ def process (self , data , sub_pipeline = None , inputdir = '.' , outputdir = '.' ,
1924
+ interactive = False , log_level = 'INFO' ):
1924
1925
"""Run a parallel generic sub-pipeline.
1925
1926
1926
1927
:param data: Input data.
1927
1928
:type data: list[PipelineData]
1928
1929
:param sub_pipeline: The sub-pipeline.
1929
1930
:type sub_pipeline: Pipeline, optional
1931
+ :param inputdir: Input directory, used only if files in the
1932
+ input configuration are not absolute paths,
1933
+ defaults to `'.'`.
1934
+ :type inputdir: str, optional
1935
+ :param outputdir: Directory to which any output figures will
1936
+ be saved, defaults to `'.'`.
1937
+ :type outputdir: str, optional
1938
+ :param interactive: Allows for user interactions, defaults to
1939
+ `False`.
1940
+ :type interactive: bool, optional
1930
1941
:return: The `data` field of the first item in the returned
1931
1942
list of sub-pipeline items.
1932
1943
"""
@@ -1946,7 +1957,7 @@ def process(self, data, sub_pipeline=None):
1946
1957
1947
1958
# Get the map configuration from data
1948
1959
map_config = self .get_config (
1949
- data , 'common.models.map.MapConfig' )
1960
+ data , 'common.models.map.MapConfig' , inputdir = inputdir )
1950
1961
1951
1962
# Create the spec reader configuration for each processor
1952
1963
spec_scans = map_config .spec_scans [0 ]
@@ -1970,7 +1981,10 @@ def process(self, data, sub_pipeline=None):
1970
1981
# Get the run configuration to use for the sub-pipeline
1971
1982
if sub_pipeline is None :
1972
1983
sub_pipeline = {}
1973
- run_config = RunConfig (sub_pipeline .get ('config' ), comm )
1984
+ run_config = {'inputdir' : inputdir , 'outputdir' : outputdir ,
1985
+ 'interactive' : interactive , 'log_level' : log_level }
1986
+ run_config .update (sub_pipeline .get ('config' ))
1987
+ run_config = RunConfig (run_config , comm )
1974
1988
pipeline_config = []
1975
1989
for item in sub_pipeline ['pipeline' ]:
1976
1990
if isinstance (item , dict ):
@@ -1987,8 +2001,8 @@ def process(self, data, sub_pipeline=None):
1987
2001
# Run the sub-pipeline on each processor
1988
2002
return run (
1989
2003
pipeline_config , inputdir = run_config .inputdir ,
1990
- outputdir = run_config .outputdir ,
1991
- interactive = run_config . interactive , comm = comm )
2004
+ outputdir = run_config .outputdir , interactive = run_config . interactive ,
2005
+ logger = self . logger , comm = comm )
1992
2006
1993
2007
1994
2008
class MPISpawnMapProcessor (Processor ):
@@ -1997,7 +2011,8 @@ class MPISpawnMapProcessor(Processor):
1997
2011
"""
1998
2012
def process (
1999
2013
self , data , num_proc = 1 , root_as_worker = True , collect_on_root = True ,
2000
- sub_pipeline = None ):
2014
+ sub_pipeline = None , inputdir = '.' , outputdir = '.' , interactive = False ,
2015
+ log_level = 'INFO' ):
2001
2016
"""Spawn workers running a parallel generic sub-pipeline.
2002
2017
2003
2018
:param data: Input data.
@@ -2012,6 +2027,16 @@ def process(
2012
2027
:type collect_on_root: bool, optional
2013
2028
:param sub_pipeline: The sub-pipeline.
2014
2029
:type sub_pipeline: Pipeline, optional
2030
+ :param inputdir: Input directory, used only if files in the
2031
+ input configuration are not absolute paths,
2032
+ defaults to `'.'`.
2033
+ :type inputdir: str, optional
2034
+ :param outputdir: Directory to which any output figures will
2035
+ be saved, defaults to `'.'`.
2036
+ :type outputdir: str, optional
2037
+ :param interactive: Allows for user interactions, defaults to
2038
+ `False`.
2039
+ :type interactive: bool, optional
2015
2040
:return: The `data` field of the first item in the returned
2016
2041
list of sub-pipeline items.
2017
2042
"""
@@ -2034,12 +2059,15 @@ def process(
2034
2059
2035
2060
# Get the map configuration from data
2036
2061
map_config = self .get_config (
2037
- data , 'common.models.map.MapConfig' )
2062
+ data , 'common.models.map.MapConfig' , inputdir = inputdir )
2038
2063
2039
2064
# Get the run configuration to use for the sub-pipeline
2040
2065
if sub_pipeline is None :
2041
2066
sub_pipeline = {}
2042
- run_config = RunConfig (config = sub_pipeline .get ('config' ))
2067
+ run_config = {'inputdir' : inputdir , 'outputdir' : outputdir ,
2068
+ 'interactive' : interactive , 'log_level' : log_level }
2069
+ run_config .update (sub_pipeline .get ('config' ))
2070
+ run_config = RunConfig (run_config )
2043
2071
2044
2072
# Create the sub-pipeline configuration for each processor
2045
2073
spec_scans = map_config .spec_scans [0 ]
@@ -3355,28 +3383,28 @@ def process(self, data):
3355
3383
return self .unwrap_pipelinedata (data )[- 1 ].data
3356
3384
3357
3385
3358
- class SumProcessor (Processor ):
3359
- """A Processor to sum the data in a NeXus NXobject, given a set of
3360
- nxpaths.
3361
- """
3362
- def process (self , data ):
3363
- """Return the summed data array
3364
-
3365
- :param data:
3366
- :type data:
3367
- :return: The summed data.
3368
- :rtype: numpy.ndarray
3369
- """
3370
- nxentry , nxpaths = self .unwrap_pipelinedata (data )[- 1 ]
3371
- if len (nxpaths ) == 1 :
3372
- return nxentry [nxpaths [0 ]]
3373
- sum_data = deepcopy (nxentry [nxpaths [0 ]])
3374
- for nxpath in nxpaths [1 :]:
3375
- nxdata = nxentry [nxpath ]
3376
- for entry in nxdata .entries :
3377
- sum_data [entry ] += nxdata [entry ]
3378
-
3379
- return sum_data
3386
+ # class SumProcessor(Processor):
3387
+ # """A Processor to sum the data in a NeXus NXobject, given a set of
3388
+ # nxpaths.
3389
+ # """
3390
+ # def process(self, data):
3391
+ # """Return the summed data array
3392
+ #
3393
+ # :param data:
3394
+ # :type data:
3395
+ # :return: The summed data.
3396
+ # :rtype: numpy.ndarray
3397
+ # """
3398
+ # nxentry, nxpaths = self.unwrap_pipelinedata(data)[-1]
3399
+ # if len(nxpaths) == 1:
3400
+ # return nxentry[nxpaths[0]]
3401
+ # sum_data = deepcopy(nxentry[nxpaths[0]])
3402
+ # for nxpath in nxpaths[1:]:
3403
+ # nxdata = nxentry[nxpath]
3404
+ # for entry in nxdata.entries:
3405
+ # sum_data[entry] += nxdata[entry]
3406
+ #
3407
+ # return sum_data
3380
3408
3381
3409
3382
3410
if __name__ == '__main__' :
0 commit comments