Skip to content

Commit 845999f

Browse files
authored
mdformat pre-commit rules (#928)
# Pull Request ## Title Enable and apply mdformat pre-commit rules --- ## Type of Change - 🔄 Refactor ---
1 parent 440b237 commit 845999f

File tree

17 files changed

+293
-262
lines changed

17 files changed

+293
-262
lines changed

.github/pull_request_template.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
_A brief, descriptive title of your changes (e.g., `Fix bug in data parser for edge cases`)_
66

7-
---
7+
______________________________________________________________________
88

99
## Description
1010

1111
_Provide a concise summary of what this PR does. Explain why this change is necessary and what problems it addresses._
1212

1313
- **Issue link**: (optional) _Link the relevant issue number or GitHub Issue link if applicable (e.g., Closes #123)._
1414

15-
---
15+
______________________________________________________________________
1616

1717
## Type of Change
1818

@@ -25,16 +25,16 @@ _Indicate the type of change by choosing one (or more) of the following:_
2525
- 📝 Documentation update
2626
- 🧪 Tests
2727

28-
---
28+
______________________________________________________________________
2929

3030
## Testing
3131

3232
_Describe briefly how you tested your changes._
3333

34-
---
34+
______________________________________________________________________
3535

3636
## Additional Notes (optional)
3737

3838
_Add any additional context or information for reviewers._
3939

40-
---
40+
______________________________________________________________________

.pre-commit-config.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ repos:
6262
hooks:
6363
- id: docformatter
6464
stages: [pre-commit, manual]
65+
- repo: https://github.com/executablebooks/mdformat
66+
rev: 0.7.17
67+
hooks:
68+
- id: mdformat
69+
additional_dependencies:
70+
- mdformat-gfm
71+
- mdformat-black
72+
- mdformat_frontmatter
73+
- mdformat-toc
74+
6575
#
6676
# Linting
6777
#

CONTRIBUTING.md

+52-50
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ Simply open the project in VSCode and follow the prompts to build and open the d
3434
3535
1. Create the `mlos` Conda environment.
3636

37-
```sh
38-
conda env create -f conda-envs/mlos.yml
39-
```
37+
```sh
38+
conda env create -f conda-envs/mlos.yml
39+
```
4040

41-
> See the [`conda-envs/`](./conda-envs/) directory for additional conda environment files, including those used for Windows (e.g. [`mlos-windows.yml`](./conda-envs/mlos-windows.yml)).
41+
> See the [`conda-envs/`](./conda-envs/) directory for additional conda environment files, including those used for Windows (e.g. [`mlos-windows.yml`](./conda-envs/mlos-windows.yml)).
4242
4343
or
4444

45-
```sh
46-
# This will also ensure the environment is update to date using "conda env update -f conda-envs/mlos.yml"
47-
make conda-env
48-
```
45+
```sh
46+
# This will also ensure the environment is update to date using "conda env update -f conda-envs/mlos.yml"
47+
make conda-env
48+
```
4949

50-
> Note: the latter expects a *nix environment.
50+
> Note: the latter expects a \*nix environment.
5151
5252
1. Initialize the shell environment.
5353

54-
```sh
55-
conda activate mlos
56-
```
54+
```sh
55+
conda activate mlos
56+
```
5757

5858
### Details
5959

@@ -62,45 +62,47 @@ Simply open the project in VSCode and follow the prompts to build and open the d
6262
We expect development to follow a typical "forking" style workflow:
6363

6464
1. Fork a copy of the [MLOS repo in Github](https://github.com/microsoft/MLOS).
65+
6566
1. Create a development (a.k.a. topic) branch off of `main` to work on changes.
6667

67-
For instance:
68+
For instance:
6869

69-
```shell
70-
git checkout -b YourDevName/some-topic-description main
71-
```
70+
```shell
71+
git checkout -b YourDevName/some-topic-description main
72+
```
7273

7374
1. Ensure all of the lint checks and tests pass.
7475

75-
The easiest way to do this is to run the `make` commands that are also used in the CI pipeline:
76+
The easiest way to do this is to run the `make` commands that are also used in the CI pipeline:
7677

77-
```shell
78-
# All at once in parallel.
79-
make all
78+
```shell
79+
# All at once in parallel.
80+
make all
8081

81-
# Or individually (for easier debugging)
82-
make format
83-
make check
84-
make test
85-
make dist-test
86-
make doc-test
87-
```
82+
# Or individually (for easier debugging)
83+
make format
84+
make check
85+
make test
86+
make dist-test
87+
make doc-test
88+
```
8889

89-
> Note: `make format` and `make check` use [`pre-commit`](https://pre-commit.com/) to run checks and auto-formatting.
90-
> See the [`.pre-commit-config.yaml`](./.pre-commit-config.yaml) file for more details.
91-
> You can also run `pre-commit install` to enable the checks in your local git hooks.
92-
>
93-
> See the [documentation README](./doc/README.md) for more information on documentation and its testing.
90+
> Note: `make format` and `make check` use [`pre-commit`](https://pre-commit.com/) to run checks and auto-formatting.
91+
> See the [`.pre-commit-config.yaml`](./.pre-commit-config.yaml) file for more details.
92+
> You can also run `pre-commit install` to enable the checks in your local git hooks.
93+
>
94+
> See the [documentation README](./doc/README.md) for more information on documentation and its testing.
9495
9596
1. Submit changes for inclusion as a [Pull Request on Github](https://github.com/microsoft/MLOS/pulls).
9697

97-
Some notes on organizing changes to help reviewers:
98+
Some notes on organizing changes to help reviewers:
9899

99-
1. Please try to keep PRs small whenver possible and don't include unnecessaary formatting changes.
100-
1. Larger changes can be planned in [Issues](https://github.com/microsoft/MLOS/issues), prototyped in a large draft PR for early feedback, and split into smaller PRs via discussion.
101-
1. All changes should include test coverage (either new or existing).
100+
1. Please try to keep PRs small whenver possible and don't include unnecessaary formatting changes.
101+
1. Larger changes can be planned in [Issues](https://github.com/microsoft/MLOS/issues), prototyped in a large draft PR for early feedback, and split into smaller PRs via discussion.
102+
1. All changes should include test coverage (either new or existing).
102103

103104
1. PRs are associated with [Github Issues](https://github.com/microsoft/MLOS/issues) and need [MLOS-committers](https://github.com/orgs/microsoft/teams/MLOS-committers) to sign-off (in addition to other CI pipeline checks like tests and lint checks to pass).
105+
104106
1. Once approved, the PR can be completed using a squash merge in order to keep a nice linear history.
105107

106108
## Distributing
@@ -109,24 +111,24 @@ You can also locally build and install from wheels like so:
109111

110112
1. Build the *wheel* file(s)
111113

112-
```sh
113-
make dist
114-
```
114+
```sh
115+
make dist
116+
```
115117

116-
2. Install it.
118+
1. Install it.
117119

118-
```sh
119-
# this will install just the optimizer component with SMAC support:
120-
pip install "dist/tmp/mlos_core-latest-py3-none-any.whl[smac]"
121-
```
120+
```sh
121+
# this will install just the optimizer component with SMAC support:
122+
pip install "dist/tmp/mlos_core-latest-py3-none-any.whl[smac]"
123+
```
122124

123-
```sh
124-
# this will install both the optimizer and the experiment runner:
125-
pip install "dist/mlos_bench-latest-py3-none-any.whl[azure]"
126-
```
125+
```sh
126+
# this will install both the optimizer and the experiment runner:
127+
pip install "dist/mlos_bench-latest-py3-none-any.whl[azure]"
128+
```
127129

128-
> Note: exact versions may differ due to automatic versioning so the `-latest-` part is a symlink.
129-
> If distributing elsewhere, adjust for the current version number in the module's `dist` directory.
130+
> Note: exact versions may differ due to automatic versioning so the `-latest-` part is a symlink.
131+
> If distributing elsewhere, adjust for the current version number in the module's `dist` directory.
130132
131133
### See Also
132134

MAINTAINING.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,51 @@ See the [documentation README](./doc/README.md) for more information on writing
1010

1111
1. Bump the version using the [`update-version.sh`](./scripts/update-version.sh) script:
1212

13-
```sh
14-
git checkout -b bump-version main
15-
./scripts/update-version.sh --no-tag patch # or minor or major
16-
```
13+
```sh
14+
git checkout -b bump-version main
15+
./scripts/update-version.sh --no-tag patch # or minor or major
16+
```
1717

18-
> By default this would create a local tag, but we would have to overwrite it later, so we skip that step.
18+
> By default this would create a local tag, but we would have to overwrite it later, so we skip that step.
1919
20-
2. Test it!
20+
1. Test it!
2121

22-
```sh
23-
make dist-test
22+
```sh
23+
make dist-test
2424

25-
# Make sure that the version number on the wheels looks correct.
26-
ls */dist/*.whl
27-
```
25+
# Make sure that the version number on the wheels looks correct.
26+
ls */dist/*.whl
27+
```
2828

29-
3. Make and merge a PR.
29+
1. Make and merge a PR.
3030

31-
4. Update the tag locally.
31+
1. Update the tag locally.
3232

33-
Once the PR with the new version files is merged.
33+
Once the PR with the new version files is merged.
3434

35-
```sh
36-
git checkout main
37-
git pull
38-
git tag vM.m.p
39-
```
35+
```sh
36+
git checkout main
37+
git pull
38+
git tag vM.m.p
39+
```
4040

41-
> Note: `M.m.p` is the version number you just bumped to above.
41+
> Note: `M.m.p` is the version number you just bumped to above.
4242
43-
5. Retest!
43+
1. Retest!
4444

45-
```sh
46-
make dist-clean
47-
make dist-test
48-
```
45+
```sh
46+
make dist-clean
47+
make dist-test
48+
```
4949

50-
6. Update the tag remotely to the MLOS upstream repo.
50+
1. Update the tag remotely to the MLOS upstream repo.
5151

52-
```sh
53-
git push --tags # upstream (if that's what you called your upstream git remote)
54-
```
52+
```sh
53+
git push --tags # upstream (if that's what you called your upstream git remote)
54+
```
5555

56-
7. Make a "Release" on Github.
56+
1. Make a "Release" on Github.
5757

58-
> Once this is done, the rules in [`.github/workflows/devcontainer.yml`](./.github/workflows/devcontainer.yml) will automatically publish the wheels to [pypi](https://pypi.org/project/mlos-core/) and tagged docker images to ACR.
59-
> \
60-
> Note: This may fail if the version number is already published to pypi, in which case start from the beginning with a new patch version.
58+
> Once this is done, the rules in [`.github/workflows/devcontainer.yml`](./.github/workflows/devcontainer.yml) will automatically publish the wheels to [pypi](https://pypi.org/project/mlos-core/) and tagged docker images to ACR.
59+
> \
60+
> Note: This may fail if the version number is already published to pypi, in which case start from the beginning with a new patch version.

0 commit comments

Comments
 (0)