-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mijanr/main
push chnages in main to test
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Update README | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install mlflow tabulate | ||
- name: Run script | ||
run: python results/gen_result.py | ||
|
||
- name: Commit results if it changed | ||
run: | | ||
git diff --exit-code --quiet results/best_runs.md || (git add results/best_runs.md && git commit -m "Update best runs") | ||
- name: Replace results in README | ||
run: | | ||
results=$(cat results/best_runs.md) # Read the results | ||
# Replace the results in the README | ||
awk -v r="$results" '/<!--START-->/ {print; print r; f=1} /<!--END-->/ {f=0} !f' README.md > temp && mv temp README.md | ||
- name: Commit and push if it changed | ||
run: | | ||
git diff | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Md Mijanur Rahman" | ||
git commit -am "Update README with test results" || exit 0 | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
We will generate a table here with the results of the experiments from mlruns | ||
""" | ||
|
||
import mlflow | ||
import git | ||
|
||
basePath = git.Repo('.', search_parent_directories=True).working_tree_dir | ||
mlflow.set_tracking_uri(f"file:{basePath}/mlruns") | ||
|
||
def get_best_runs(): | ||
|
||
all_runs = mlflow.search_runs(search_all_experiments=True) | ||
columns = ['tags.mlflow.runName', 'params.model_name', 'metrics.accuracy'] | ||
all_runs = all_runs[columns] | ||
best_runs = all_runs.groupby(['tags.mlflow.runName', 'params.model_name']).agg({'metrics.accuracy': 'max'}).reset_index() | ||
best_runs = best_runs.pivot(index='tags.mlflow.runName', columns='params.model_name', values='metrics.accuracy').reset_index() | ||
best_runs.columns.name = None | ||
best_runs = best_runs.rename(columns={'tags.mlflow.runName': 'Dataset'}) | ||
# save as markdown file | ||
with open('best_runs.md', 'w') as f: | ||
f.write(best_runs.to_markdown(index=False)) | ||
|
||
|
||
if __name__ == "__main__": | ||
get_best_runs() | ||
|