Skip to content

Commit f31a90e

Browse files
committed
update instance list and pipeline for ec2-0.7.11
Signed-off-by: Sunyanan Choochotkaew <[email protected]>
1 parent 4bdcc9c commit f31a90e

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

cmd/cmd_plot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ def metadata_plot(args, energy_source, metadata_df, output_folder, name):
155155
plt.close()
156156

157157
def power_curve_plot(args, data_path, energy_source, output_folder, name):
158-
model_toppath = data_path
158+
if 'MODEL_PATH' in os.environ:
159+
model_toppath = os.environ['MODEL_PATH']
160+
else:
161+
model_toppath = data_path
159162
pipeline_name = args.pipeline_name
160163
pipeline_path = os.path.join(model_toppath, pipeline_name)
161164
node_collection = NodeTypeIndexCollection(pipeline_path)

cmd/cmd_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def print_file_to_stdout(data_path, args):
2828

2929
def extract_time(data_path, benchmark_filename):
3030
data = load_json(data_path, benchmark_filename)
31-
if benchmark_filename != "customBenchmark":
31+
if "metadata" in data:
3232
start_str = data["metadata"]["creationTimestamp"]
3333
start = datetime.datetime.strptime(start_str, '%Y-%m-%dT%H:%M:%SZ')
3434
end_str = data["status"]["results"][-1]["repetitions"][-1]["pushedTime"].split(".")[0]

cmd/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def train(args):
394394
dyn_trainer_names = args.dyn_trainers.split(",")
395395

396396
node_type=None
397+
pipeline=None
397398
if args.id:
398399
machine_id = args.id
399400
pipeline = get_pipeline(data_path, pipeline_name, args.extractor, args.profile, args.target_hints, args.bg_hints, args.abs_pipeline_name, args.isolator, abs_trainer_names, dyn_trainer_names, energy_sources, valid_feature_groups)
@@ -749,10 +750,16 @@ def export(args):
749750
inputs = args.input.split(",")
750751

751752
pipeline_name = args.pipeline_name
752-
pipeline_path = get_pipeline_path(data_path, pipeline_name=pipeline_name)
753+
if 'MODEL_PATH' not in os.environ:
754+
os.environ['MODEL_PATH'] = data_path
755+
pipeline_path = get_pipeline_path(os.environ['MODEL_PATH'], pipeline_name=pipeline_name)
753756

754757
local_export_path = exporter.export(data_path, pipeline_path, output_path, publisher=args.publisher, collect_date=collect_date, inputs=inputs)
755758

759+
if local_export_path is None:
760+
print("failed to export")
761+
exit()
762+
756763
args.input = local_export_path
757764
args.output = local_export_path
758765
args.energy_source = ",".join(PowerSourceMap.keys())

src/train/ec2_pipeline.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
DATAPATH=/path/to/models python cmd/main.py plot --target-data estimate --input /path/to/data/i3.metal/kepler_query.json --pipeline-name ec2 --energy-source intel_rapl --model-name LogarithmicRegressionTrainer_4 --output-type AbsPower --output i3metal-ec2 --feature-group BPFOnly
1313
1414
example of export command:
15-
DATAPATH=/path/to/models python cmd/main.py export --pipeline-name ec2 -o /path/to/kepler-model-db/models --publisher sunya-ch --zip=true --collect-date "July 2024"
15+
DATAPATH=/path/to/models python cmd/main.py export --pipeline-name ec2-0.7.11 -o /path/to/kepler-model-db/models --publisher sunya-ch --zip=true --collect-date "July 2024"
1616
"""
1717

1818
import os
@@ -40,10 +40,13 @@
4040
from saver import save_json
4141
from config import model_toppath
4242

43-
node_profiles = ["m5zn.metal", "c5d.metal", "i3en.metal", "m7i.metal-24xl", "i3.metal"]
43+
data_path = os.path.join(model_toppath, "..", "data")
44+
45+
node_profiles = ["m5.metal", "i3.metal", "c5.metal", "r5.metal", "m5zn.metal", "m7i.metal-24xl"]
4446
node_image = "ami-0e4d0bb9670ea8db0"
4547

4648
import boto3
49+
last_modified = None
4750

4851
aws_access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
4952
aws_secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
@@ -56,8 +59,9 @@
5659
def read_response_in_json(key):
5760
print(key)
5861
response = s3.get_object(Bucket=bucket_name, Key=key)
59-
last_modified_str = response['LastModified']
60-
print("{} last modified time: {}".format(key, last_modified_str))
62+
global last_modified
63+
last_modified = response['LastModified']
64+
print("{} last modified time: {}".format(key, last_modified))
6165
return json.loads(response['Body'].read().decode('utf-8'))
6266

6367
class Ec2PipelineRun():
@@ -77,15 +81,15 @@ def process(self):
7781
spec_json = read_response_in_json(spec_key)
7882

7983
# save raw data from response in local path models/../data/<instance profile>
80-
profile_datapath = os.path.join(model_toppath, "..", "data", profile)
84+
profile_datapath = os.path.join(data_path, profile)
8185
os.makedirs(profile_datapath, exist_ok=True)
8286
save_json(path=profile_datapath, name="kepler_query.json", data=query_response)
83-
save_json(path=profile_datapath, name=machine_spec_filename, data=spec_json)
87+
machine_spec_path = os.path.join(profile_datapath, "machine_spec")
88+
save_json(path=machine_spec_path, name=machine_spec_filename, data=spec_json)
8489

8590
# process pipeline
86-
spec = NodeTypeSpec(**spec_json['attrs'])
87-
spec.attrs[NodeAttribute.MEMORY] = unknown
88-
spec.attrs[NodeAttribute.FREQ] = unknown
91+
spec = NodeTypeSpec()
92+
spec.load(spec_json)
8993
node_type = self.pipeline.node_collection.index_train_machine(machine_id, spec)
9094
query_results = prom_responses_to_results(query_response)
9195
query_results[node_info_column] = node_type
@@ -101,8 +105,14 @@ def archive_pipeline(self):
101105
self.pipeline.archive_pipeline()
102106

103107
if __name__ == "__main__":
104-
pipeline_name = "ec2"
108+
pipeline_name = "ec2-0.7.11"
105109
pipelinerun = Ec2PipelineRun(name=pipeline_name)
106110
pipelinerun.process()
107111
pipelinerun.save_metadata()
108-
pipelinerun.archive_pipeline()
112+
pipelinerun.archive_pipeline()
113+
print("Collection time:", last_modified)
114+
item = dict()
115+
item["startTimeUTC"] = last_modified.strftime("%Y-%m-%dT%H:%M:%SZ")
116+
item["endTimeUTC"] = last_modified.strftime("%Y-%m-%dT%H:%M:%SZ")
117+
print(item)
118+
save_json(path=data_path, name=pipeline_name, data=item)

src/train/profiler/node_type_index.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#p
33
# Usage:
44
# index_collection = NodeTypeIndexCollection(pipeline_path)
5-
# node_type = index_collection.index_train_machine(processor, cores, chips, cache_kb, memory_gb, cpu_freq_mhz, power_mgt, minmax_watt)
5+
# node_type = index_collection.index_train_machine(machine_id, new_spec)
66
# index_collection.save()
77

88
import sys
@@ -68,8 +68,8 @@ def generate_spec(data_path, machine_id):
6868
"processor": processor,
6969
"cores": cores,
7070
"chips": chips,
71-
"memory_gb": memory_gb,
72-
"cpu_freq_mhz": cpu_freq_mhz,
71+
"memory": memory_gb,
72+
"frequency": cpu_freq_mhz,
7373
"threads_per_core": threads_per_core
7474
}
7575
spec = NodeTypeSpec(**spec_values)
@@ -102,8 +102,8 @@ def __init__(self, **kwargs):
102102
self.attrs[NodeAttribute.PROCESSOR] = kwargs.get('processor', no_data)
103103
self.attrs[NodeAttribute.CORES] = kwargs.get('cores', no_data)
104104
self.attrs[NodeAttribute.CHIPS] = kwargs.get('chips', no_data)
105-
self.attrs[NodeAttribute.MEMORY] = kwargs.get('memory_gb', no_data)
106-
self.attrs[NodeAttribute.FREQ] = kwargs.get('cpu_freq_mhz', no_data)
105+
self.attrs[NodeAttribute.MEMORY] = kwargs.get('memory', no_data)
106+
self.attrs[NodeAttribute.FREQ] = kwargs.get('frequency', no_data)
107107
self.members = []
108108

109109
def load(self, json_obj):

tests/pipeline_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"processor": "test",
2222
"cores": 1,
2323
"chips": 1,
24-
"memory_gb": -1,
25-
"cpu_freq_mhz": -1
24+
"memory": -1,
25+
"frequency": -1
2626
}
2727
spec = NodeTypeSpec(**spec_values)
2828

0 commit comments

Comments
 (0)