Skip to content

Commit

Permalink
Rename str_to_state function to load_state
Browse files Browse the repository at this point in the history
  • Loading branch information
giffels committed Aug 29, 2022
1 parent 8d9aa33 commit e941638
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tardis/resources/drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .dronestates import DownState
from ..plugins.sqliteregistry import SqliteRegistry
from ..utilities.attributedict import AttributeDict
from ..utilities.utils import str_to_state
from ..utilities.utils import load_state
from cobald.daemon import service
from cobald.interfaces import Pool

Expand Down Expand Up @@ -71,7 +71,7 @@ def _database(self) -> Optional[SqliteRegistry]:

async def database_state(self) -> Optional[Type[State]]:
try:
return str_to_state(
return load_state(
await self._database.get_resource_state(
self.resource_attributes.drone_uuid
)
Expand Down
4 changes: 2 additions & 2 deletions tardis/resources/poolfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..agents.siteagent import SiteAgent
from ..configuration.configuration import Configuration
from ..resources.drone import Drone
from ..utilities.utils import str_to_state
from ..utilities.utils import load_state

from cobald.composite.weighted import WeightedComposite
from cobald.composite.factory import FactoryPool
Expand Down Expand Up @@ -109,7 +109,7 @@ def get_drones_to_restore(plugins: dict, site, machine_type: str):
except KeyError:
return []
else:
return str_to_state(
return load_state(
sql_registry.get_resources(site_name=site.name, machine_type=machine_type)
)

Expand Down
2 changes: 1 addition & 1 deletion tardis/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def machine_meta_data_translation(
raise


def str_to_state(resources):
def load_state(resources):
import tardis.resources.dronestates

for entry in resources:
Expand Down
4 changes: 2 additions & 2 deletions tests/utilities_t/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
csv_parser,
disable_logging,
htcondor_cmd_option_formatter,
str_to_state,
load_state,
submit_cmd_option_formatter,
)

Expand Down Expand Up @@ -121,7 +121,7 @@ def test_disable_logging(self):
class TestStrToState(TestCase):
def test_str_to_state(self):
test = [{"state": "RequestState", "drone_uuid": "test-abc123"}]
converted_test = str_to_state(test)
converted_test = load_state(test)
self.assertTrue(converted_test[0]["state"], RequestState)
self.assertEqual(converted_test[0]["drone_uuid"], "test-abc123")

Expand Down

0 comments on commit e941638

Please sign in to comment.