Skip to content

Commit 3c8659b

Browse files
CaptainSameSameer SharmaSameer Sharma
authored
COREML-3036 | Add Spark conf log and console progress config (#75)
* COREML-3036 | Add Spark conf log and console progress config * COREML-3036 | Tests for Spark conf log and console progress config * COREML-3036 | Version bump Co-authored-by: Sameer Sharma <[email protected]> Co-authored-by: Sameer Sharma <[email protected]>
1 parent 1bbd10b commit 3c8659b

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

service_configuration_lib/spark_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ def _get_k8s_volume_hostpath_dict(host_path: str, container_path: str, mode: str
206206
}
207207

208208

209+
def _append_spark_config(spark_opts: Dict[str, str], config_name: str, config_value: str) -> Dict[str, str]:
210+
# config already defined by the user, don't modify
211+
if config_name in spark_opts:
212+
return spark_opts
213+
214+
# append the config
215+
spark_opts[config_name] = config_value
216+
return spark_opts
217+
218+
209219
def _append_sql_shuffle_partitions_conf(spark_opts: Dict[str, str]) -> Dict[str, str]:
210220
if 'spark.sql.shuffle.partitions' in spark_opts:
211221
return spark_opts
@@ -677,6 +687,12 @@ def get_spark_conf(
677687

678688
# configure sql shuffle partitions
679689
spark_conf = _append_sql_shuffle_partitions_conf(spark_conf)
690+
691+
# configure spark conf log
692+
spark_conf = _append_spark_config(spark_conf, 'spark.logConf', 'true')
693+
694+
# configure spark Console Progress
695+
spark_conf = _append_spark_config(spark_conf, 'spark.ui.showConsoleProgress', 'true')
680696
return spark_conf
681697

682698

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='service-configuration-lib',
20-
version='2.10.0',
20+
version='2.10.1',
2121
provides=['service_configuration_lib'],
2222
description='Start, stop, and inspect Yelp SOA services',
2323
url='https://github.com/Yelp/service_configuration_lib',

tests/spark_config_test.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,54 @@ def test_append_sql_shuffle_partitions_conf(
507507
key = 'spark.sql.shuffle.partitions'
508508
assert output[key] == expected_output
509509

510+
@pytest.mark.parametrize(
511+
'user_spark_opts,expected_output', [
512+
# not configured by user
513+
({}, 'true'),
514+
# configured by user
515+
({'spark.logConf': 'false'}, 'false'),
516+
],
517+
)
518+
def test_append_spark_conf_log(
519+
self, user_spark_opts, expected_output,
520+
):
521+
key = 'spark.logConf'
522+
output = spark_config._append_spark_config(user_spark_opts, key, 'true')
523+
524+
assert output[key] == expected_output
525+
526+
@pytest.mark.parametrize(
527+
'user_spark_opts,expected_output', [
528+
# not configured by user
529+
({}, 'true'),
530+
# configured by user
531+
({'spark.ui.showConsoleProgress': 'false'}, 'false'),
532+
],
533+
)
534+
def test_append_console_progress_conf(
535+
self, user_spark_opts, expected_output,
536+
):
537+
key = 'spark.ui.showConsoleProgress'
538+
output = spark_config._append_spark_config(user_spark_opts, key, 'true')
539+
540+
assert output[key] == expected_output
541+
542+
@pytest.fixture
543+
def mock_append_spark_conf_log(self):
544+
return_value = {'spark.logConf': 'true'}
545+
with MockConfigFunction(
546+
'_append_spark_config', return_value,
547+
) as m:
548+
yield m
549+
550+
@pytest.fixture
551+
def mock_append_console_progress_conf(self):
552+
return_value = {'spark.ui.showConsoleProgress': 'true'}
553+
with MockConfigFunction(
554+
'_append_spark_config', return_value,
555+
) as m:
556+
yield m
557+
510558
@pytest.fixture
511559
def mock_get_mesos_docker_volumes_conf(self):
512560
return_value = {'spark.mesos.executor.docker.volumes': '/tmp:/tmp:ro'}
@@ -768,6 +816,8 @@ def test_get_spark_conf_mesos(
768816
assert_ui_port,
769817
assert_app_name,
770818
mock_log,
819+
mock_append_spark_conf_log,
820+
mock_append_console_progress_conf,
771821
):
772822
other_spark_opts = {'spark.driver.memory': '2g', 'spark.executor.memoryOverhead': '1024'}
773823
not_allowed_opts = {'spark.executorEnv.PAASTA_SERVICE': 'random-service'}
@@ -810,7 +860,9 @@ def test_get_spark_conf_mesos(
810860
list(mock_get_mesos_docker_volumes_conf.return_value.keys()) +
811861
list(mock_adjust_spark_requested_resources_mesos.return_value.keys()) +
812862
list(mock_append_event_log_conf.return_value.keys()) +
813-
list(mock_append_sql_shuffle_partitions_conf.return_value.keys()),
863+
list(mock_append_sql_shuffle_partitions_conf.return_value.keys()) +
864+
list(mock_append_spark_conf_log.return_value.keys()) +
865+
list(mock_append_console_progress_conf.return_value.keys()),
814866
)
815867
assert len(set(output.keys()) - verified_keys) == 0
816868
mock_get_mesos_docker_volumes_conf.mocker.assert_called_once_with(

0 commit comments

Comments
 (0)