Skip to content

Commit

Permalink
support more info in version meta
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Wang <[email protected]>
  • Loading branch information
doudoubobo committed Oct 9, 2024
1 parent 022727c commit af67dbc
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 125 deletions.
2 changes: 1 addition & 1 deletion apps/rdbms/insert_db_txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def print(self):
)
else:
duration = self.end_time - self.start_time
print("Time interval: {:.2f} second".format(duration))
print("Time interval: {:.2f} second".format(duration))


total_timer = Timer()
Expand Down
7 changes: 4 additions & 3 deletions coordinator/flex/server/controllers/graph_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ def get_graph_all_available_versions(graph_id): # noqa: E501
for idx in range(len(all_versions)):
result_dict = {}
result_dict["version_id"] = str(all_versions[idx][0])
result_dict["creation_time"] = str(all_versions[idx][1])
result_dict["num_vertices"] = str(all_versions[idx][2])
result_dict["num_edges"] = str(all_versions[idx][3])
result_dict["begin_time"] = str(all_versions[idx][1])
result_dict["end_time"] = str(all_versions[idx][2])
result_dict["num_vertices"] = str(all_versions[idx][3])
result_dict["num_edges"] = str(all_versions[idx][4])
result.append(GetGraphVersionResponse.from_dict(result_dict))
return (result, 200)

Expand Down
22 changes: 0 additions & 22 deletions coordinator/flex/server/controllers/service_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ def list_service_status(): # noqa: E501
return 'do some magic!'


def pause_data_loading(): # noqa: E501
"""pause_data_loading
Pause data loading # noqa: E501
:rtype: Union[str, Tuple[str, int], Tuple[str, int, Dict[str, str]]
"""
return 'do some magic!'


def restart_service(): # noqa: E501
"""restart_service
Expand All @@ -55,17 +44,6 @@ def restart_service(): # noqa: E501
return 'do some magic!'


def resume_data_loading(): # noqa: E501
"""resume_data_loading
Resume data loading # noqa: E501
:rtype: Union[str, Tuple[str, int], Tuple[str, int, Dict[str, str]]
"""
return 'do some magic!'


def start_service(start_service_request=None): # noqa: E501
"""start_service
Expand Down
64 changes: 46 additions & 18 deletions coordinator/flex/server/models/get_graph_version_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class GetGraphVersionResponse(Model):
Do not edit the class manually.
"""

def __init__(self, creation_time=None, version_id=None, num_vertices=None, num_edges=None): # noqa: E501
def __init__(self, begin_time=None, end_time=None, version_id=None, num_vertices=None, num_edges=None): # noqa: E501
"""GetGraphVersionResponse - a model defined in OpenAPI
:param creation_time: The creation_time of this GetGraphVersionResponse. # noqa: E501
:type creation_time: str
:param begin_time: The begin_time of this GetGraphVersionResponse. # noqa: E501
:type begin_time: str
:param end_time: The end_time of this GetGraphVersionResponse. # noqa: E501
:type end_time: str
:param version_id: The version_id of this GetGraphVersionResponse. # noqa: E501
:type version_id: str
:param num_vertices: The num_vertices of this GetGraphVersionResponse. # noqa: E501
Expand All @@ -25,20 +27,23 @@ def __init__(self, creation_time=None, version_id=None, num_vertices=None, num_e
:type num_edges: str
"""
self.openapi_types = {
'creation_time': str,
'begin_time': str,
'end_time': str,
'version_id': str,
'num_vertices': str,
'num_edges': str
}

self.attribute_map = {
'creation_time': 'creation_time',
'begin_time': 'begin_time',
'end_time': 'end_time',
'version_id': 'version_id',
'num_vertices': 'num_vertices',
'num_edges': 'num_edges'
}

self._creation_time = creation_time
self._begin_time = begin_time
self._end_time = end_time
self._version_id = version_id
self._num_vertices = num_vertices
self._num_edges = num_edges
Expand All @@ -55,27 +60,50 @@ def from_dict(cls, dikt) -> 'GetGraphVersionResponse':
return util.deserialize_model(dikt, cls)

@property
def creation_time(self) -> str:
"""Gets the creation_time of this GetGraphVersionResponse.
def begin_time(self) -> str:
"""Gets the begin_time of this GetGraphVersionResponse.
:return: The creation_time of this GetGraphVersionResponse.
:return: The begin_time of this GetGraphVersionResponse.
:rtype: str
"""
return self._creation_time
return self._begin_time

@creation_time.setter
def creation_time(self, creation_time: str):
"""Sets the creation_time of this GetGraphVersionResponse.
@begin_time.setter
def begin_time(self, begin_time: str):
"""Sets the begin_time of this GetGraphVersionResponse.
:param creation_time: The creation_time of this GetGraphVersionResponse.
:type creation_time: str
:param begin_time: The begin_time of this GetGraphVersionResponse.
:type begin_time: str
"""
if creation_time is None:
raise ValueError("Invalid value for `creation_time`, must not be `None`") # noqa: E501
if begin_time is None:
raise ValueError("Invalid value for `begin_time`, must not be `None`") # noqa: E501

self._creation_time = creation_time
self._begin_time = begin_time

@property
def end_time(self) -> str:
"""Gets the end_time of this GetGraphVersionResponse.
:return: The end_time of this GetGraphVersionResponse.
:rtype: str
"""
return self._end_time

@end_time.setter
def end_time(self, end_time: str):
"""Sets the end_time of this GetGraphVersionResponse.
:param end_time: The end_time of this GetGraphVersionResponse.
:type end_time: str
"""
if end_time is None:
raise ValueError("Invalid value for `end_time`, must not be `None`") # noqa: E501

self._end_time = end_time

@property
def version_id(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion coordinator/flex/server/models/job_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def status(self, status: str):
:param status: The status of this JobStatus.
:type status: str
"""
allowed_values = ["RUNNING", "SUCCESS", "FAILED", "CANCELLED", "WAITING","PAUSED"] # noqa: E501
allowed_values = ["RUNNING", "SUCCESS", "FAILED", "CANCELLED", "WAITING", "PAUSED"] # noqa: E501
if status not in allowed_values:
raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}"
Expand Down
53 changes: 9 additions & 44 deletions coordinator/flex/server/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2150,26 +2150,6 @@ paths:
tags:
- Service
x-openapi-router-controller: flex.server.controllers.service_controller
/api/v1/service/pause:
post:
description: Pause data loading
operationId: pause_data_loading
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/APIResponse'
description: Successfully paused data loading
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Server error
tags:
- Service
x-openapi-router-controller: flex.server.controllers.service_controller
/api/v1/service/restart:
post:
description: Restart current service
Expand All @@ -2190,26 +2170,6 @@ paths:
tags:
- Service
x-openapi-router-controller: flex.server.controllers.service_controller
/api/v1/service/resume:
post:
description: Resume data loading
operationId: resume_data_loading
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/APIResponse'
description: Successfully resume data loading
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Server error
tags:
- Service
x-openapi-router-controller: flex.server.controllers.service_controller
/api/v1/service/start:
post:
description: Start service
Expand Down Expand Up @@ -3709,13 +3669,17 @@ components:
title: GetGraphResponse
GetGraphVersionResponse:
example:
creation_time: creation_time
num_vertices: num_vertices
end_time: end_time
begin_time: begin_time
version_id: version_id
num_edges: num_edges
properties:
creation_time:
title: creation_time
begin_time:
title: begin_time
type: string
end_time:
title: end_time
type: string
version_id:
title: version_id
Expand All @@ -3727,7 +3691,8 @@ components:
title: num_edges
type: string
required:
- creation_time
- begin_time
- end_time
- num_edges
- num_vertices
- version_id
Expand Down
30 changes: 0 additions & 30 deletions coordinator/flex/server/test/test_service_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ def test_list_service_status(self):
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))

def test_pause_data_loading(self):
"""Test case for pause_data_loading
"""
headers = {
'Accept': 'application/json',
}
response = self.client.open(
'/api/v1/service/pause',
method='POST',
headers=headers)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))

def test_restart_service(self):
"""Test case for restart_service
Expand All @@ -71,21 +56,6 @@ def test_restart_service(self):
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))

def test_resume_data_loading(self):
"""Test case for resume_data_loading
"""
headers = {
'Accept': 'application/json',
}
response = self.client.open(
'/api/v1/service/resume',
method='POST',
headers=headers)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))

def test_start_service(self):
"""Test case for start_service
Expand Down
34 changes: 28 additions & 6 deletions scripts/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def get_graph_schema():
@app.route("/get-all-available-read-epochs", methods=["GET"])
def get_all_available_read_epochs():
all_epochs = get_all_available_read_epochs_internal()[0]
all_epochs.reverse()
if len(all_epochs) == 0:
return "No available read epochs", 200
return json.dumps(all_epochs), 200
Expand All @@ -335,19 +336,32 @@ def get_read_epoch_by_timestamp():
unix_time = int(dt.timestamp())
epoch_unix_time_pairs = get_all_available_read_epochs_internal()[1]
# iterate through the list of epoch_unix_time pairs from end to start
for epoch, unix_time_epoch, num_vertices, num_edges in reversed(
epoch_unix_time_pairs
):
for (
epoch,
previous_unix_time_epoch,
unix_time_epoch,
num_vertices,
num_edges,
) in reversed(epoch_unix_time_pairs):
if unix_time_epoch <= unix_time:
converted_time = datetime.fromtimestamp(unix_time_epoch)
# convert time into local time zone
converted_time = converted_time.replace(tzinfo=timezone.utc).astimezone(
tz=None
)
formatted_time = converted_time.strftime("%Y-%m-%d %H:%M:%S")
previous_formatted_time = "-"
if epoch != 0:
converted_time = datetime.fromtimestamp(previous_unix_time_epoch)
# convert time into local time zone
converted_time = converted_time.replace(tzinfo=timezone.utc).astimezone(
tz=None
)
previous_formatted_time = converted_time.strftime("%Y-%m-%d %H:%M:%S")
result = {
"version_id": str(epoch),
"creation_time": formatted_time,
"begin_time": previous_formatted_time,
"end_time": formatted_time,
"num_vertices": num_vertices,
"num_edges": num_edges,
}
Expand Down Expand Up @@ -560,6 +574,7 @@ def get_all_available_read_epochs_internal():
available_epochs_internal = []
for epoch in range(latest_read_epoch + 1):
latest_timestamp = None
previous_timestamp = "-"
num_vertices = 0
num_edges = 0
for frag_id in range(int(num_fragment)):
Expand All @@ -573,10 +588,17 @@ def get_all_available_read_epochs_internal():
# convert time into local time zone
converted_time = converted_time.replace(tzinfo=timezone.utc).astimezone(tz=None)
formatted_time = converted_time.strftime("%Y-%m-%d %H:%M:%S")
available_epochs.append([epoch, formatted_time, num_vertices, num_edges])
available_epochs.append(
[epoch, previous_timestamp, formatted_time, num_vertices, num_edges]
)
available_epochs_internal.append(
[epoch, latest_timestamp, num_vertices, num_edges]
[epoch, previous_timestamp, latest_timestamp, num_vertices, num_edges]
)

for epoch in range(latest_read_epoch, 0, -1):
available_epochs[epoch][1] = available_epochs[epoch - 1][2]
available_epochs_internal[epoch][1] = available_epochs_internal[epoch - 1][2]

return [available_epochs, available_epochs_internal]


Expand Down

0 comments on commit af67dbc

Please sign in to comment.