Skip to content

Commit

Permalink
Fix memory format (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
KanchiShimono authored Jul 9, 2021
1 parent ec36303 commit e206b60
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ sco = SparkConfOptimizer(executor_instance, num_nodes, deploy_mode)
print(sco)

# spark.driver.cores: 5
# spark.driver.memory: 36
# spark.driver.memoryOvearhead: 5
# spark.driver.memory: 36g
# spark.driver.memoryOvearhead: 5g
# spark.executor.cores: 5
# spark.executor.memory: 36
# spark.executor.memoryOvearhead: 5
# spark.executor.memory: 36g
# spark.executor.memoryOvearhead: 5g
# spark.executor.instances: 60
# spark.default.parallelism: 600
# spark.sql.shuffle.partitions: 600
Expand All @@ -48,11 +48,11 @@ sco = SparkConfOptimizer(executor_instance, num_nodes, deploy_mode)
print(sco)

# spark.driver.cores: 5
# spark.driver.memory: 36
# spark.driver.memoryOvearhead: 5
# spark.driver.memory: 36g
# spark.driver.memoryOvearhead: 5g
# spark.executor.cores: 5
# spark.executor.memory: 36
# spark.executor.memoryOvearhead: 5
# spark.executor.memory: 36g
# spark.executor.memoryOvearhead: 5g
# spark.executor.instances: 59
# spark.default.parallelism: 590
# spark.sql.shuffle.partitions: 590
Expand All @@ -75,11 +75,11 @@ sco = SparkConfOptimizer(
print(sco)

# spark.driver.cores: 3
# spark.driver.memory: 26
# spark.driver.memoryOvearhead: 3
# spark.driver.memory: 26g
# spark.driver.memoryOvearhead: 3g
# spark.executor.cores: 5
# spark.executor.memory: 36
# spark.executor.memoryOvearhead: 5
# spark.executor.memory: 36g
# spark.executor.memoryOvearhead: 5g
# spark.executor.instances: 60
# spark.default.parallelism: 600
# spark.sql.shuffle.partitions: 600
Expand Down Expand Up @@ -108,11 +108,11 @@ print(conf.getAll())
conf.setAll(sco.as_list())
# dict_items([
# ('spark.driver.cores', '5'),
# ('spark.driver.memory', '36'),
# ('spark.driver.memoryOvearhead', '5'),
# ('spark.driver.memory', '36g'),
# ('spark.driver.memoryOvearhead', '5g'),
# ('spark.executor.cores', '5'),
# ('spark.executor.memory', '36'),
# ('spark.executor.memoryOvearhead', '5'),
# ('spark.executor.memory', '36g'),
# ('spark.executor.memoryOvearhead', '5g'),
# ('spark.executor.instances', '60'),
# ('spark.default.parallelism', '600'),
# ('spark.sql.shuffle.partitions', '600')
Expand Down
24 changes: 12 additions & 12 deletions src/scopt/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ class SparkConfOptimizer:
>>> print(sco)
spark.driver.cores: 5
spark.driver.memory: 36
spark.driver.memoryOvearhead: 5
spark.driver.memory: 36g
spark.driver.memoryOvearhead: 5g
spark.executor.cores: 5
spark.executor.memory: 36
spark.executor.memoryOvearhead: 5
spark.executor.memory: 36g
spark.executor.memoryOvearhead: 5g
spark.executor.instances: 60
spark.default.parallelism: 600
spark.sql.shuffle.partitions: 600
Expand All @@ -255,11 +255,11 @@ class SparkConfOptimizer:
>>> print(conf.getAll())
dict_items([
('spark.driver.cores', '5'),
('spark.driver.memory', '36'),
('spark.driver.memoryOvearhead', '5'),
('spark.driver.memory', '36g'),
('spark.driver.memoryOvearhead', '5g'),
('spark.executor.cores', '5'),
('spark.executor.memory', '36'),
('spark.executor.memoryOvearhead', '5'),
('spark.executor.memory', '36g'),
('spark.executor.memoryOvearhead', '5g'),
('spark.executor.instances', '60'),
('spark.default.parallelism', '600'),
('spark.sql.shuffle.partitions', '600')
Expand Down Expand Up @@ -326,11 +326,11 @@ def _repr_html_(self) -> str:
def as_dict(self) -> Dict[str, Union[int, str]]:
return {
'spark.driver.cores': self.optimizer.driver_cores,
'spark.driver.memory': self.optimizer.driver_memory,
'spark.driver.memoryOvearhead': self.optimizer.driver_memory_overhead, # noqa: E501
'spark.driver.memory': f'{self.optimizer.driver_memory}g',
'spark.driver.memoryOvearhead': f'{self.optimizer.driver_memory_overhead}g', # noqa: E501
'spark.executor.cores': self.optimizer.executor_cores,
'spark.executor.memory': self.optimizer.executor_memory,
'spark.executor.memoryOvearhead': self.optimizer.executor_memory_overhead, # noqa: E501
'spark.executor.memory': f'{self.optimizer.executor_memory}g',
'spark.executor.memoryOvearhead': f'{self.optimizer.executor_memory_overhead}g', # noqa: E501
'spark.executor.instances': self.optimizer.executor_instances,
'spark.default.parallelism': self.optimizer.default_parallelism,
'spark.sql.shuffle.partitions': self.optimizer.sql_shuffle_partitions, # noqa: E501
Expand Down
16 changes: 8 additions & 8 deletions tests/test_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def test_as_dict(self) -> None:
optimizer = SparkConfOptimizer(Instance(32, 248), 10, 'client')
expected = {
'spark.driver.cores': 5,
'spark.driver.memory': 36,
'spark.driver.memoryOvearhead': 5,
'spark.driver.memory': '36g',
'spark.driver.memoryOvearhead': '5g',
'spark.executor.cores': 5,
'spark.executor.memory': 36,
'spark.executor.memoryOvearhead': 5,
'spark.executor.memory': '36g',
'spark.executor.memoryOvearhead': '5g',
'spark.executor.instances': 60,
'spark.default.parallelism': 600,
'spark.sql.shuffle.partitions': 600,
Expand All @@ -116,11 +116,11 @@ def test_as_list(self) -> None:
optimizer = SparkConfOptimizer(Instance(32, 248), 10, 'client')
expected = [
('spark.driver.cores', 5),
('spark.driver.memory', 36),
('spark.driver.memoryOvearhead', 5),
('spark.driver.memory', '36g'),
('spark.driver.memoryOvearhead', '5g'),
('spark.executor.cores', 5),
('spark.executor.memory', 36),
('spark.executor.memoryOvearhead', 5),
('spark.executor.memory', '36g'),
('spark.executor.memoryOvearhead', '5g'),
('spark.executor.instances', 60),
('spark.default.parallelism', 600),
('spark.sql.shuffle.partitions', 600),
Expand Down

0 comments on commit e206b60

Please sign in to comment.