Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 9153fb7

Browse files
Introduce config options which enables parallel/inline for overloads (#457)
* Introduce config options which enables parallel/inline for overloads * Implement strtobool via distutils.util.strtobool
1 parent 32a72dc commit 9153fb7

File tree

4 files changed

+115
-7
lines changed

4 files changed

+115
-7
lines changed

sdc/config.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@
4747
_has_opencv = True
4848
import sdc.cv_ext
4949

50-
config_transport_mpi_default = distutils_util.strtobool(os.getenv('SDC_CONFIG_MPI', 'True'))
50+
51+
def strtobool(val):
52+
'''Convert string to True or False'''
53+
return bool(distutils_util.strtobool(val))
54+
55+
56+
config_transport_mpi_default = strtobool(os.getenv('SDC_CONFIG_MPI', 'True'))
5157
'''
5258
Default value for transport used if no function decorator controls the transport
5359
'''
@@ -58,11 +64,21 @@
5864
because decorator called later then modules have been initialized
5965
'''
6066

61-
config_pipeline_hpat_default = distutils_util.strtobool(os.getenv('SDC_CONFIG_PIPELINE_SDC', 'False'))
67+
config_pipeline_hpat_default = strtobool(os.getenv('SDC_CONFIG_PIPELINE_SDC', 'False'))
6268
'''
6369
Default value used to select compiler pipeline in a function decorator
6470
'''
6571

72+
config_use_parallel_overloads = strtobool(os.getenv('SDC_AUTO_PARALLEL', 'False'))
73+
'''
74+
Default value used to select whether auto parallel would be applied to sdc functions
75+
'''
76+
77+
config_inline_overloads = strtobool(os.getenv('SDC_AUTO_INLINE', 'False'))
78+
'''
79+
Default value used to select whether sdc functions would inline
80+
'''
81+
6682
if not config_pipeline_hpat_default:
6783
# avoid using MPI transport if no SDC compiler pipeline used
6884
config_transport_mpi_default = False
@@ -73,7 +89,7 @@
7389
Default value for a pointer intended to use as Numba.DefaultPassBuilder.define_nopython_pipeline() in overloaded function
7490
'''
7591

76-
test_expected_failure = distutils_util.strtobool(os.getenv('SDC_TEST_EXPECTED_FAILURE', 'False'))
92+
test_expected_failure = strtobool(os.getenv('SDC_TEST_EXPECTED_FAILURE', 'False'))
7793
'''
7894
If True then replaces skip decorators to expectedFailure decorator.
7995
'''

sdc/tests/test_series.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from sdc.tests.test_base import TestCase
3838
from sdc.tests.test_utils import (
3939
count_array_REPs, count_parfor_REPs, count_array_OneDs, get_start_end,
40-
skip_numba_jit, skip_sdc_jit, sdc_limitation)
40+
skip_numba_jit, skip_sdc_jit, sdc_limitation, skip_parallel, skip_inline)
4141
from sdc.tests.gen_test_data import ParquetGenerator
4242
from numba import types
4343
from numba.config import IS_32BITS
@@ -612,6 +612,7 @@ def test_impl(A, deep):
612612
self.assertEqual(actual.index is S.index, expected.index is S.index)
613613
self.assertEqual(actual.index is S.index, not deep)
614614

615+
@skip_parallel
615616
@skip_sdc_jit('Series.corr() parameter "min_periods" unsupported')
616617
def test_series_corr(self):
617618
def test_series_corr_impl(S1, S2, min_periods=None):
@@ -679,6 +680,8 @@ def test_series_corr_impl(S1, S2, min_periods=None):
679680
msg = 'Method corr(). The object min_periods'
680681
self.assertIn(msg, str(raises.exception))
681682

683+
@skip_parallel
684+
@skip_inline
682685
def test_series_astype_int_to_str1(self):
683686
'''Verifies Series.astype implementation with function 'str' as argument
684687
converts integer series to series of strings
@@ -691,6 +694,8 @@ def test_impl(S):
691694
S = pd.Series(np.arange(n))
692695
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
693696

697+
@skip_parallel
698+
@skip_inline
694699
def test_series_astype_int_to_str2(self):
695700
'''Verifies Series.astype implementation with a string literal dtype argument
696701
converts integer series to series of strings
@@ -703,6 +708,8 @@ def test_impl(S):
703708
S = pd.Series(np.arange(n))
704709
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
705710

711+
@skip_parallel
712+
@skip_inline
706713
def test_series_astype_str_to_str1(self):
707714
'''Verifies Series.astype implementation with function 'str' as argument
708715
handles string series not changing it
@@ -714,6 +721,8 @@ def test_impl(S):
714721
S = pd.Series(['aa', 'bb', 'cc'])
715722
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
716723

724+
@skip_parallel
725+
@skip_inline
717726
def test_series_astype_str_to_str2(self):
718727
'''Verifies Series.astype implementation with a string literal dtype argument
719728
handles string series not changing it
@@ -725,6 +734,8 @@ def test_impl(S):
725734
S = pd.Series(['aa', 'bb', 'cc'])
726735
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
727736

737+
@skip_parallel
738+
@skip_inline
728739
def test_series_astype_str_to_str_index_str(self):
729740
'''Verifies Series.astype implementation with function 'str' as argument
730741
handles string series not changing it
@@ -738,6 +749,8 @@ def test_impl(S):
738749
S = pd.Series(['aa', 'bb', 'cc'], index=['d', 'e', 'f'])
739750
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
740751

752+
@skip_parallel
753+
@skip_inline
741754
def test_series_astype_str_to_str_index_int(self):
742755
'''Verifies Series.astype implementation with function 'str' as argument
743756
handles string series not changing it
@@ -857,6 +870,8 @@ def test_impl(A):
857870
S = pd.Series(['3.24', '1E+05', '-1', '-1.3E-01', 'nan', 'inf'])
858871
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
859872

873+
@skip_parallel
874+
@skip_inline
860875
def test_series_astype_str_index_str(self):
861876
'''Verifies Series.astype implementation with function 'str' as argument
862877
handles string series not changing it
@@ -869,6 +884,8 @@ def test_impl(S):
869884
S = pd.Series(['aa', 'bb', 'cc'], index=['a', 'b', 'c'])
870885
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
871886

887+
@skip_parallel
888+
@skip_inline
872889
def test_series_astype_str_index_int(self):
873890
'''Verifies Series.astype implementation with function 'str' as argument
874891
handles string series not changing it
@@ -1462,6 +1479,7 @@ def test_impl(A):
14621479
df = pd.DataFrame({'A': np.arange(n)})
14631480
self.assertTrue(isinstance(hpat_func(df.A), np.ndarray))
14641481

1482+
@skip_parallel
14651483
@skip_sdc_jit('No support of axis argument in old-style Series.fillna() impl')
14661484
def test_series_fillna_axis1(self):
14671485
'''Verifies Series.fillna() implementation handles 'index' as axis argument'''
@@ -1472,6 +1490,7 @@ def test_impl(S):
14721490
S = pd.Series([1.0, 2.0, np.nan, 1.0, np.inf])
14731491
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
14741492

1493+
@skip_parallel
14751494
@skip_sdc_jit('No support of axis argument in old-style Series.fillna() impl')
14761495
def test_series_fillna_axis2(self):
14771496
'''Verifies Series.fillna() implementation handles 0 as axis argument'''
@@ -1482,6 +1501,7 @@ def test_impl(S):
14821501
S = pd.Series([1.0, 2.0, np.nan, 1.0, np.inf])
14831502
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
14841503

1504+
@skip_parallel
14851505
@skip_sdc_jit('No support of axis argument in old-style Series.fillna() impl')
14861506
def test_series_fillna_axis3(self):
14871507
'''Verifies Series.fillna() implementation handles correct non-literal axis argument'''
@@ -1493,6 +1513,7 @@ def test_impl(S, axis):
14931513
for axis in [0, 'index']:
14941514
pd.testing.assert_series_equal(hpat_func(S, axis), test_impl(S, axis))
14951515

1516+
@skip_parallel
14961517
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
14971518
def test_series_fillna_float_from_df(self):
14981519
'''Verifies Series.fillna() applied to a named float Series obtained from a DataFrame'''
@@ -1504,6 +1525,7 @@ def test_impl(S):
15041525
df = pd.DataFrame({'A': [1.0, 2.0, np.nan, 1.0, np.inf]})
15051526
pd.testing.assert_series_equal(hpat_func(df.A), test_impl(df.A), check_names=False)
15061527

1528+
@skip_parallel
15071529
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15081530
def test_series_fillna_float_index1(self):
15091531
'''Verifies Series.fillna() implementation for float series with default index'''
@@ -1515,6 +1537,7 @@ def test_impl(S):
15151537
S = pd.Series(data)
15161538
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15171539

1540+
@skip_parallel
15181541
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15191542
def test_series_fillna_float_index2(self):
15201543
'''Verifies Series.fillna() implementation for float series with string index'''
@@ -1525,6 +1548,7 @@ def test_impl(S):
15251548
S = pd.Series([1.0, 2.0, np.nan, 1.0, np.inf], ['a', 'b', 'c', 'd', 'e'])
15261549
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15271550

1551+
@skip_parallel
15281552
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15291553
def test_series_fillna_float_index3(self):
15301554
def test_impl(S):
@@ -1534,6 +1558,8 @@ def test_impl(S):
15341558
S = pd.Series([1.0, 2.0, np.nan, 1.0, np.inf], index=[1, 2, 5, 7, 10])
15351559
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15361560

1561+
@skip_parallel
1562+
@skip_inline
15371563
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15381564
def test_series_fillna_str_from_df(self):
15391565
'''Verifies Series.fillna() applied to a named float Series obtained from a DataFrame'''
@@ -1546,6 +1572,8 @@ def test_impl(S):
15461572
pd.testing.assert_series_equal(hpat_func(df.A),
15471573
test_impl(df.A), check_names=False)
15481574

1575+
@skip_parallel
1576+
@skip_inline
15491577
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15501578
def test_series_fillna_str_index1(self):
15511579
'''Verifies Series.fillna() implementation for series of strings with default index'''
@@ -1556,6 +1584,8 @@ def test_impl(S):
15561584
S = pd.Series(['aa', 'b', None, 'cccd', ''])
15571585
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15581586

1587+
@skip_parallel
1588+
@skip_inline
15591589
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15601590
def test_series_fillna_str_index2(self):
15611591
'''Verifies Series.fillna() implementation for series of strings with string index'''
@@ -1566,6 +1596,8 @@ def test_impl(S):
15661596
S = pd.Series(['aa', 'b', None, 'cccd', ''], ['a', 'b', 'c', 'd', 'e'])
15671597
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15681598

1599+
@skip_parallel
1600+
@skip_inline
15691601
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15701602
def test_series_fillna_str_index3(self):
15711603
def test_impl(S):
@@ -1576,6 +1608,7 @@ def test_impl(S):
15761608
S = pd.Series(['aa', 'b', None, 'cccd', ''], index=[1, 2, 5, 7, 10])
15771609
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
15781610

1611+
@skip_parallel
15791612
@skip_sdc_jit('BUG: old-style fillna impl returns series without index')
15801613
def test_series_fillna_float_inplace1(self):
15811614
'''Verifies Series.fillna() implementation for float series with default index and inplace argument True'''
@@ -1588,6 +1621,7 @@ def test_impl(S):
15881621
S2 = S1.copy()
15891622
pd.testing.assert_series_equal(hpat_func(S1), test_impl(S2))
15901623

1624+
@skip_parallel
15911625
@unittest.skip('TODO: add reflection support and check method return value')
15921626
def test_series_fillna_float_inplace2(self):
15931627
'''Verifies Series.fillna(inplace=True) results are reflected back in the original float series'''
@@ -1601,6 +1635,7 @@ def test_impl(S):
16011635
self.assertIsNone(test_impl(S2))
16021636
pd.testing.assert_series_equal(S1, S2)
16031637

1638+
@skip_parallel
16041639
def test_series_fillna_float_inplace3(self):
16051640
'''Verifies Series.fillna() implementation correcly handles omitted inplace argument as default False'''
16061641
def test_impl(S):
@@ -1612,6 +1647,7 @@ def test_impl(S):
16121647
pd.testing.assert_series_equal(hpat_func(S1), test_impl(S1))
16131648
pd.testing.assert_series_equal(S1, S2)
16141649

1650+
@skip_parallel
16151651
def test_series_fillna_inplace_non_literal(self):
16161652
'''Verifies Series.fillna() implementation handles only Boolean literals as inplace argument'''
16171653
def test_impl(S, param):
@@ -1623,6 +1659,7 @@ def test_impl(S, param):
16231659
expected = ValueError if sdc.config.config_pipeline_hpat_default else TypingError
16241660
self.assertRaises(expected, hpat_func, S, True)
16251661

1662+
@skip_parallel
16261663
@skip_numba_jit('TODO: investigate why Numba types inplace as bool (non-literal value)')
16271664
def test_series_fillna_str_inplace1(self):
16281665
'''Verifies Series.fillna() implementation for series of strings
@@ -1687,6 +1724,7 @@ def test_impl(S):
16871724
S = pd.Series([pd.NaT, pd.Timestamp('1970-12-01'), pd.Timestamp('2012-07-25')])
16881725
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
16891726

1727+
@skip_parallel
16901728
def test_series_fillna_bool_no_index1(self):
16911729
'''Verifies Series.fillna() implementation for bool series with default index'''
16921730
def test_impl(S):
@@ -2570,6 +2608,7 @@ def test_impl(S):
25702608
S = pd.Series([np.nan, -2., 3., 0.5E-01, 0xFF, 0o7, 0b101])
25712609
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))
25722610

2611+
@skip_parallel
25732612
def test_series_cov1(self):
25742613
def test_impl(S1, S2):
25752614
return S1.cov(S2)
@@ -4021,6 +4060,7 @@ def test_impl(A, B):
40214060
B = np.random.ranf(n)
40224061
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B))
40234062

4063+
@skip_parallel
40244064
def test_series_sort_values_full(self):
40254065
def test_impl(series, ascending, kind):
40264066
return series.sort_values(axis=0, ascending=ascending, inplace=False, kind=kind, na_position='last')
@@ -4068,6 +4108,7 @@ def test_impl(series, ascending, kind):
40684108
np.testing.assert_array_equal(ref_result.data, jit_result.data)
40694109
self.assertEqual(ref, jit)
40704110

4111+
@skip_parallel
40714112
def test_series_sort_values_full_idx(self):
40724113
def test_impl(series, ascending, kind):
40734114
return series.sort_values(axis=0, ascending=ascending, inplace=False, kind=kind, na_position='last')
@@ -4688,6 +4729,7 @@ def test_series_count_impl(S):
46884729
result = hpat_func(S)
46894730
self.assertEqual(result, result_ref)
46904731

4732+
@skip_parallel
46914733
@skip_sdc_jit('Series.cumsum() np.nan as input data unsupported')
46924734
def test_series_cumsum(self):
46934735
def test_impl():
@@ -4698,6 +4740,7 @@ def test_impl():
46984740
cfunc = self.jit(pyfunc)
46994741
pd.testing.assert_series_equal(pyfunc(), cfunc())
47004742

4743+
@skip_parallel
47014744
@skip_sdc_jit('Series.cumsum() np.nan as input data unsupported')
47024745
def test_series_cumsum_unboxing(self):
47034746
def test_impl(s):
@@ -4710,6 +4753,7 @@ def test_impl(s):
47104753
series = pd.Series(data)
47114754
pd.testing.assert_series_equal(pyfunc(series), cfunc(series))
47124755

4756+
@skip_parallel
47134757
@skip_sdc_jit('Series.cumsum() parameters "axis", "skipna" unsupported')
47144758
def test_series_cumsum_full(self):
47154759
def test_impl(s, axis, skipna):
@@ -4751,6 +4795,7 @@ def test_impl(s, axis):
47514795
msg = 'Method cumsum(). Unsupported parameters. Given axis: int'
47524796
self.assertIn(msg, str(raises.exception))
47534797

4798+
@skip_parallel
47544799
@skip_sdc_jit('Series.cov() parameter "min_periods" unsupported')
47554800
def test_series_cov(self):
47564801
def test_series_cov_impl(S1, S2, min_periods=None):
@@ -5146,6 +5191,7 @@ def test_impl(A, B):
51465191
B = pd.Series(np.arange(n)**2, index=np.arange(n, dtype=dtype_right))
51475192
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False)
51485193

5194+
@skip_parallel
51495195
@skip_sdc_jit('Arithmetic operations on Series with non-default indexes are not supported in old-style')
51505196
def test_series_operator_add_numeric_same_index_numeric_fixme(self):
51515197
""" Same as test_series_operator_add_same_index_numeric but with w/a for the problem.
@@ -5167,6 +5213,7 @@ def test_impl(A, B):
51675213
B = pd.Series(np.arange(n)**2, index=np.arange(n, dtype=dtype_right))
51685214
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False)
51695215

5216+
@skip_parallel
51705217
@skip_sdc_jit('Arithmetic operations on Series with non-default indexes are not supported in old-style')
51715218
def test_series_operator_add_numeric_same_index_str(self):
51725219
"""Verifies implementation of Series.operator.add between two numeric Series with the same string indexes"""
@@ -5179,6 +5226,7 @@ def test_impl(A, B):
51795226
B = pd.Series(np.arange(n)**2, index=['a', 'c', 'e', 'c', 'b', 'a', 'o'])
51805227
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False, check_names=False)
51815228

5229+
@skip_parallel
51825230
@skip_sdc_jit('Arithmetic operations on Series with non-default indexes are not supported in old-style')
51835231
def test_series_operator_add_numeric_align_index_int(self):
51845232
"""Verifies implementation of Series.operator.add between two numeric Series with non-equal integer indexes"""
@@ -5195,6 +5243,7 @@ def test_impl(A, B):
51955243
B = pd.Series(np.arange(n)**2, index=index_B)
51965244
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False, check_names=False)
51975245

5246+
@skip_parallel
51985247
@skip_sdc_jit('Arithmetic operations on Series with non-default indexes are not supported in old-style')
51995248
def test_series_operator_add_numeric_align_index_str(self):
52005249
"""Verifies implementation of Series.operator.add between two numeric Series with non-equal string indexes"""
@@ -5228,6 +5277,7 @@ def test_impl(A, B):
52285277
B = pd.Series(np.arange(n)**2, index=index_B)
52295278
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False, check_names=False)
52305279

5280+
@skip_parallel
52315281
@skip_sdc_jit('Arithmetic operations on Series with non-default indexes are not supported in old-style')
52325282
def test_series_operator_add_numeric_align_index_other_dtype(self):
52335283
"""Verifies implementation of Series.operator.add between two numeric Series
@@ -5253,6 +5303,7 @@ def test_impl(A, B):
52535303
B = pd.Series(np.arange(size_B)**2)
52545304
pd.testing.assert_series_equal(hpat_func(A, B), test_impl(A, B), check_dtype=False, check_names=False)
52555305

5306+
@skip_parallel
52565307
@skip_sdc_jit('Arithmetic operations on Series requiring alignment of indexes are not supported in old-style')
52575308
def test_series_operator_add_align_index_int_capacity(self):
52585309
"""Verifies implementation of Series.operator.add and alignment of numeric indexes of large size"""

0 commit comments

Comments
 (0)