Skip to content

Commit

Permalink
Removing some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanElsaban committed Dec 3, 2024
1 parent aa39c5a commit e30f03e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 18 deletions.
1 change: 0 additions & 1 deletion tests/core/jobrun_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def test_start_action_runs_failed(self):
assert_equal(started_runs, startable_runs[1:])

def jobrun_json(self):
# field_selector_env = {"PAASTA_POD_IP": ["status.podIP"]}
data_string = json.dumps(
{
"job_name": "example_job",
Expand Down
6 changes: 0 additions & 6 deletions tron/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,18 @@ def from_json(state_data: str):
# convert back the list of dictionaries to a list of ConfigParameter
json_data[k] = [ConfigParameter(**val) for val in json_data[k]]
elif k == "extra_volumes":
# tested locally & infrastage
json_data[k] = [ConfigVolume(**val) for val in json_data[k]]
elif k == "secret_volumes":
# tested locally & infrastage
json_data[k] = [ConfigSecretVolume(**val) for val in json_data[k]]
elif k == "projected_sa_volumes":
json_data[k] = [ConfigProjectedSAVolume(**val) for val in json_data[k]]
elif k == "node_affinities":
# tested infrastage
json_data[k] = [ConfigNodeAffinity(**val) for val in json_data[k]]
elif k == "topology_spread_constraints":
# tested infrastage
json_data[k] = [ConfigTopologySpreadConstraints(**val) for val in json_data[k]]
elif k == "secret_env":
# tested on infrastage
json_data[k] = {key: ConfigSecretSource(**val) for key, val in json_data[k].items()}
elif k == "field_selector_env":
# tested locally & infrastage
json_data[k] = {key: ConfigFieldSelectorSource(**val) for key, val in json_data[k].items()}
except Exception:
log.exception("Error deserializing ActionCommandConfig from JSON")
Expand Down
4 changes: 1 addition & 3 deletions tron/core/actionrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def to_json(state_data: dict) -> Optional[str]:
try:
return json.dumps(
{
"command_config": ActionCommandConfig.to_json(
state_data["command_config"]
), # maybe here we pass it to configAction()
"command_config": ActionCommandConfig.to_json(state_data["command_config"]),
"start_time": state_data["start_time"].isoformat() if state_data["start_time"] else None,
"end_time": state_data["end_time"].isoformat() if state_data["end_time"] else None,
"rendered_command": state_data["rendered_command"],
Expand Down
7 changes: 2 additions & 5 deletions tron/serialize/runstate/dynamodb_state_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ def restore(self, keys) -> dict:
# job_state job_run_name --> high level info about the job run
config_watcher = get_config_watcher()
config_watcher.reload_if_changed()
read_json = staticconf.read(
"read_json.enable", namespace=NAMESPACE, default=False
) # TODO: dont forget to change default to False after finishing testing
read_json = staticconf.read("read_json.enable", namespace=NAMESPACE, default=False)
first_items = self._get_first_partitions(keys)
remaining_items = self._get_remaining_partitions(first_items)
vals = self._merge_items(first_items, remaining_items, read_json)
Expand Down Expand Up @@ -145,7 +143,7 @@ def _get_remaining_partitions(self, items: list):
keys_for_remaining_items.extend(remaining_items)
return self._get_items(keys_for_remaining_items)

# TODO: should be a flag set in srv-configs to read json data or not, otherwise will read pickled data
# read_json is a flag set in srv-configs to read json data or not, otherwise will read pickled data
def _merge_items(self, first_items, remaining_items, read_json=False) -> dict:
items = defaultdict(list)
raw_items: DefaultDict[str, bytearray] = defaultdict(bytearray)
Expand All @@ -168,7 +166,6 @@ def _merge_items(self, first_items, remaining_items, read_json=False) -> dict:
log.info("read_json is enabled. Deserializing JSON items to restore them instead of pickled data.")
deserialized_items = {k: self._deserialize_item(k, val) for k, val in json_items.items()}
except Exception as e:
# test this out
log.exception(f"Error deserializing JSON items: {repr(e)}")
# if reading from json failed we want to try reading the pickled data instead
read_json = False
Expand Down
3 changes: 0 additions & 3 deletions tron/utils/trontimespec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
"""A complete time specification based on the Google App Engine GROC spec."""
import calendar
import datetime
import logging

import pytz

log = logging.getLogger(__name__)


def get_timezone(timezone_string):
"""Converts a timezone string to a pytz timezone object.
Expand Down

0 comments on commit e30f03e

Please sign in to comment.