Skip to content

Commit 6955354

Browse files
authored
Merge pull request #423 from vprashar2929/add-marklint
feat(ci): Add markdownlint workflow
2 parents 14a22cf + 8912c69 commit 6955354

File tree

13 files changed

+331
-195
lines changed

13 files changed

+331
-195
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
<!--
2-
Pull Request Template
3-
-->
1+
# Checklist for PR Author
42

53
---
64

7-
### Checklist for PR Author
8-
95
In addition to approval, the author must confirm the following check list:
106

117
- [ ] Run the following command to format your code:

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Run linters and formatters
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
markdown-lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# checkout soruce code
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
# setup Python environment
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.10"
19+
20+
# install hatch
21+
- name: Install hatch
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install hatch
25+
26+
# scan for markdown linting errors
27+
- name: Run pymarkdownlnt on markdown files
28+
shell: bash
29+
run: |
30+
make lint

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ PYTHON := python3.10
1515
DOCKERFILES_PATH := ./dockerfiles
1616
MODEL_PATH := ${PWD}/tests/models
1717

18+
.PHONY: lint
19+
lint:
20+
@hatch run pymarkdownlnt scan -r .
21+
1822
.PHONY: build
1923
build:
2024
$(CTR_CMD) build -t $(IMAGE) -f $(DOCKERFILES_PATH)/Dockerfile .

README.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Kepler Power Model
2+
23
[Get started with Kepler Model Server.](https://sustainable-computing.io/kepler_model_server/get_started/)
34

45
This repository contains source code related to Kepler power model. The modules in this repository connects to [core Kepler project](https://github.com/sustainable-computing-io/kepler) and [kepler-model-db](https://github.com/sustainable-computing-io/kepler-model-db) as below.
5-
![](./fig/comm_diagram.png)
6+
7+
![Diagram](./fig/comm_diagram.png)
8+
69
For more details, check [the component diagram](./fig/model-server-components-simplified.png).
710

8-
## Model server and estimator deployment
11+
## Model server and estimator deployment
912

1013
### Using Kepler Operator
1114

@@ -28,25 +31,32 @@ spec:
2831
initUrl: <static model URL>
2932
```
3033
31-
### Using manifests with setup script:
34+
### Using manifests with setup script
35+
3236
Deploy with estimator sidecar
33-
```sh
37+
38+
```bash
3439
OPTS="ESTIMATOR" make deploy
3540
```
3641

37-
Deploy with estimator sidecar and model server
38-
```sh
42+
Deploy with estimator sidecar and model server
43+
44+
```bash
3945
OPTS="ESTIMATOR SERVER" make deploy
4046
```
4147

4248
## Model Training
49+
4350
- [Use Tekton pipeline](./model_training/tekton/README.md)
4451
- [Use Bash script with CPE operator](./model_training/cpe_script_instruction.md)
4552

4653
## Local test
47-
### via docker
48-
1. Build image for testing, run
49-
```sh
54+
55+
### Via docker
56+
57+
1. Build image for testing, run
58+
59+
```bash
5060
make build-test
5161
```
5262

@@ -61,27 +71,29 @@ OPTS="ESTIMATOR SERVER" make deploy
6171

6272
For more test information, check [here](./tests/).
6373

64-
### with native python environment
74+
### With native python environment
75+
6576
Compatible version: `python 3.10`
6677

6778
1. Install [`hatch`](https://hatch.pypa.io/latest/install/)
6879
2. Prepare environment
6980

7081
```bash
71-
hatch shell
82+
hatch shell
7283
```
7384

7485
3. Run the test
7586

76-
|Test case|Command|
77-
|---|---|
78-
|[Training pipeline](./tests/README.md#pipeline)|python -u ./tests/pipeline_test.py|
79-
|[Model server](./tests/README.md#estimator-model-request-to-model-server)|Terminal 1: export MODEL_PATH=$(pwd)/tests/models;python src/server/model_server.py <br>Terminal 2: python -u tests/estimator_model_request_test.py|
80-
|[Estimator](./tests/README.md#estimator-power-request-from-collector)|Terminal 1: python src/estimate/estimator.py<br>Terminal 2: python -u tests/estimator_power_request_test.py|
81-
|Estimator with Model Server|Terminal 1: export MODEL_PATH=$(pwd)/tests/models;python src/server/model_server.py <br>Terminal 2: export MODEL_SERVER_URL=http://localhost:8100;export MODEL_SERVER_ENABLE=true;python -u src/estimate/estimator.py<br>Terminal 3: python -u tests/estimator_power_request_test.py
82-
|[Offline Trainer](./tests/README.md#offline-trainer)|Terminal 1: python src/train/offline_trainer.py<br>Terminal 2: python -u tests/offline_trainer_test.py|
87+
| Test case | Command |
88+
|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
89+
| [Training pipeline](./tests/README.md#pipeline)| python -u ./tests/pipeline_test.py |
90+
| [Model server](./tests/README.md#estimator-model-request-to-model-server)| Terminal 1: export MODEL_PATH=$(pwd)/tests/models;python src/server/model_server.py Terminal 2: python -u tests/estimator_model_request_test.py |
91+
| [Estimator](./tests/README.md#estimator-power-request-from-collector) | Terminal 1: python src/estimate/estimator.py Terminal 2: python -u tests/estimator_power_request_test.py |
92+
| Estimator with Model Server | Terminal 1: export MODEL_PATH=$(pwd)/tests/models;python src/server/model_server.py Terminal 2: export MODEL_SERVER_URL=<http://localhost:8100>;export MODEL_SERVER_ENABLE=true;python -u src/estimate/estimator.py Terminal 3: python -u tests/estimator_power_request_test.py |
93+
| [Offline Trainer](./tests/README.md#offline-trainer) | Terminal 1: python src/train/offline_trainer.py Terminal 2: python -u tests/offline_trainer_test.py |
8394

84-
For more test information, check [here](./tests/).
95+
For more test information, check [here](./tests/).
8596

8697
### Contributing
98+
8799
Please check the roadmap and guidelines to join us [here](./contributing.md).

contributing.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,71 @@
11
# Contributing
2+
23
[Get started with Kepler Model Server.](https://sustainable-computing.io/kepler_model_server/get_started/)
34

45
- The main source codes are in [src directory](./src/).
56

67
## PR Hands-on
78

8-
- Create related [issue](https://github.com/sustainable-computing-io/kepler-model-server/issues) with your name assigned first (if not exist).
9+
- Create related [issue](https://github.com/sustainable-computing-io/kepler-model-server/issues) with your name assigned first (if not exist).
910

1011
- Set required secret and environment for local repository test if needed. Check below table.
1112

12-
Objective|Required Secret|Required Environment
13-
---|---|---
14-
Push to private repo|BOT_NAME, BOT_TOKEN|IMAGE_REPO
15-
Change on base image|BOT_NAME, BOT_TOKEN|IMAGE_REPO
16-
Save data/models to AWS COS|AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION|
13+
| Objective | Required Secret | Required Environment |
14+
| --------- | --------------- |----------------------|
15+
| Push to private repo |BOT_NAME, BOT_TOKEN | IMAGE_REPO |
16+
| Change on base image | BOT_NAME, BOT_TOKEN | IMAGE_REPO |
17+
| Save data/models to AWS COS | AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION | |
1718

1819
## Improve components in training pipelines
20+
1921
Learn more details about [Training Pipeline](https://sustainable-computing.io/kepler_model_server/pipeline/)
2022

2123
### Introduce new feature group
24+
2225
- Define new feature group name `FeatureGroup` and update metric list map `FeatureGroups` in [train types](./src/util/train_types.py)
2326

2427
### Introduce new energy sources
28+
2529
- Define new energy source map `PowerSourceMap` in [train types](./src/util/train_types.py)
2630

2731
### Improve preprocessing method
32+
2833
- [extractor](./src/train/extractor/): convert from numerically aggregated metrics to per-second value
2934
- [isolator](./src/train/isolator/): isolate background (idle) power from the collected power
3035

3136
### Introduce new learning method
37+
3238
- [trainer](./src/train/trainer/): apply learning method to build a model using extracted data and isolated data
3339

3440
## Model training
41+
3542
Learn more details about [model training](./model_training/)
3643

3744
### Introduce new benchmarks
45+
3846
The new benchmark must be supported by [CPE operator](https://github.com/IBM/cpe-operator) for automation.
3947
Find [examples](https://github.com/IBM/cpe-operator/tree/main/examples).
4048

4149
### CPE-based (deprecated)
50+
4251
`Benchmark` CR has a dependency on `BenchmarkOperator`. Default `BechmarkOperator` is to support [batch/v1/Job API](https://github.com/IBM/cpe-operator/blob/main/examples/none/cpe_v1_none_operator.yaml).
4352

4453
### Tekton
54+
4555
Create workload `Task` and provide example `Pipeline` to run.
4656

4757
### Add new trained models
58+
4859
TBD
4960

5061
## Source improvement
62+
5163
Any improvement in `src` and `cmd`.
5264

5365
## Test and CI improvement
66+
5467
Any improvement in `tests`, `dockerfiles`, `manifests` and `.github/workflows`
5568

5669
## Documentation
5770

58-
Detailed documentation should be posted to [kepler-doc](https://github.com/sustainable-computing-io/kepler-doc) repository.
71+
Detailed documentation should be posted to [kepler-doc](https://github.com/sustainable-computing-io/kepler-doc) repository.

docs/developer/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
### 0. Temporarily add `__init__.py` to all directories
1+
# Developer Guide
22

3-
```
3+
- Temporarily add `__init__.py` to all directories
4+
5+
```bash
46
find ./src -type d -exec touch {}/__init__.py \;
57
```
68

7-
### 1. Generate `classes.plantuml` and `packages.plantuml` using the following commands
8-
```
9+
- Generate `classes.plantuml` and `packages.plantuml` using the following commands
10+
11+
```bash
912
pyreverse --colorized --output plantuml --module-names y --show-stdlib --show-associated 2 --show-ancestors 1 --verbose -d umls/server/ --source-roots ./src/ ./src/server/
1013
pyreverse --colorized --output plantuml --module-names y --show-stdlib --show-associated 2 --show-ancestors 1 --verbose -d umls/estimate/ --source-roots ./src/ ./src/estimate/
1114
pyreverse --colorized --output plantuml --module-names y --show-stdlib --show-associated 2 --show-ancestors 1 --verbose -d umls/train/ --source-roots ./src/ ./src/train/
1215
pyreverse --colorized --output plantuml --module-names y --show-stdlib --show-associated 2 --show-ancestors 1 --verbose -d umls/train/trainer/ --source-roots ./src/ ./src/train/trainer/
1316
```
1417

15-
### 2. Use [plantuml](https://plantuml.com/download) to convert planuml files to `svg` files
18+
- Use [plantuml](https://plantuml.com/download) to convert planuml files to `svg` files
1619
NeoVim plugin `neovim-soil` was used to generate svg files from plantuml files

model_training/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contribute to power profiling and model training
22

33
<!--toc:start-->
4+
45
- [Contribute to power profiling and model training](#contribute-to-power-profiling-and-model-training)
56
- [Requirements](#requirements)
67
- [Pre-step](#pre-step)
@@ -10,8 +11,8 @@
1011
- [For managed cluster](#for-managed-cluster)
1112
- [Run benchmark and collect metrics](#run-benchmark-and-collect-metrics)
1213
- [With manual execution](#with-manual-execution)
13-
- [[Manual Metric Collection and Training with Entrypoint](./cmd_instruction.md)](#manual-metric-collection-and-training-with-entrypointcmdinstructionmd)
1414
- [Clean up](#clean-up)
15+
1516
<!--toc:end-->
1617

1718
## Requirements
@@ -68,7 +69,7 @@ There are two options to run the benchmark and collect the metrics, [CPE-operato
6869

6970
- [CPE Operator Instruction](./cpe_script_instruction.md)
7071

71-
With manual execution
72+
### With manual execution
7273

7374
In addition to the above two automation approach, you can manually run your own benchmarks, then collect, train, and export the models by the entrypoint `cmd/main.py`
7475

model_training/cmd_instruction.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Manual Metric Collection and Training with Entrypoint
22

33
## 1. Collect metrics
4+
45
Without benchmark/pipeline automation, kepler metrics can be collected by `query` function by setting `BENCHMARK`, `PROM_URL`, `COLLECT_ID` and either one of the following time options.
56

67
> It is recommend to set BENCHMARK name as a part of the pod name such as `stressng` to filter the validated results. BENCHMARK name will be also used by the TrainerIsolator to filter the target pods. If the BENCHMARK cannot be used to filter the target pods, the validated results will show result from all pods.
@@ -32,8 +33,10 @@ INTERVAL= # in second
3233
DATAPATH=/path/to/workspace python cmd/main.py query --benchmark $BENCHMARK --server $PROM_URL --output kepler_query --interval $INTERVAL --id $COLLECT_ID
3334
```
3435

35-
### Output:
36+
### Output
37+
3638
There will three files created in the `/path/to/workspace`, those are:
39+
3740
- `kepler_query.json`: raw prometheus query response
3841
- `<COLLECT_ID>.json`: machine system features (spec)
3942
- `<BENCHMARK>.json`: an item contains startTimeUTC and endTimeUTC
@@ -50,6 +53,7 @@ DATAPATH=/path/to/workspace MODEL_PATH=/path/to/workspace python cmd/main.py tra
5053
```
5154

5255
## 3. Export models
56+
5357
Export function is to archive the model that has an error less than threshold from the trained pipeline and make a report in the format that is ready to push to kepler-model-db. To use export function, need to set `EXPORTER_PATH` and `PUBLISHER`, and collect date option.
5458

5559
```bash
@@ -81,4 +85,3 @@ COLLECT_DATE= # collect date
8185
# require PIPELINE_NAME from train step
8286
DATAPATH=/path/to/workspace MODEL_PATH=/path/to/workspace python cmd/main.py export --pipeline-name $PIPELINE_NAME -o $EXPORT_PATH --publisher $PUBLISHER --zip=true --collect-date $COLLECT_DATE
8387
```
84-

0 commit comments

Comments
 (0)