From 3f892605636253357c7dbcb494dfba70e84b8511 Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:58:30 -0400 Subject: [PATCH] Move config files to scripts/config (#1748) This is meant to better split config files vs source code, to make it more obvious what should be changed by everyday script users. Not all of the scripts use `config/` yet, but could be refactored in the future if we want. --- README.md | 6 +++--- package.json | 2 +- scripts/{ => config}/api-html-artifacts.json | 0 {cspell => scripts/config/cspell}/cSpell.json | 8 ++++---- {cspell => scripts/config/cspell}/dictionaries/people.txt | 0 {cspell => scripts/config/cspell}/dictionaries/qiskit.txt | 0 .../notebooks.toml => config/notebook-testing.toml} | 0 scripts/js/lib/api/sphinxArtifacts.ts | 2 +- scripts/nb-tester/test/test_notebook_classification.py | 4 +--- tox.ini | 2 +- 10 files changed, 11 insertions(+), 13 deletions(-) rename scripts/{ => config}/api-html-artifacts.json (100%) rename {cspell => scripts/config/cspell}/cSpell.json (88%) rename {cspell => scripts/config/cspell}/dictionaries/people.txt (100%) rename {cspell => scripts/config/cspell}/dictionaries/qiskit.txt (100%) rename scripts/{nb-tester/notebooks.toml => config/notebook-testing.toml} (100%) diff --git a/README.md b/README.md index 1f87430d64..7e2e6286bb 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ API docs authors can preview their changes to one of the APIs by using the `-a` ### Add a new notebook When adding a new notebook, you'll need to tell the testing tools how to handle it. -To do this, add the file path to `scripts/nb-tester/notebooks.toml`. There are +To do this, add the file path to `scripts/config/notebook-testing.toml`. There are four categories: - `notebooks_normal_test`: Notebooks to be run normally in CI. These notebooks @@ -316,7 +316,7 @@ There are two ways to deal with cSpell incorrectly complaining about a word, suc Ayyyyy, this is a fake description. ``` -2. If the word is a name, add it to the `cspell/dictionaries/people.txt` file. If it is a scientific or quantum specific word, add it to the `cspell/dictionaries/qiskit.txt` file. If it doesn't fit in either category, add it to the `words` section in `cspell/cSpell.json`. The word is not case-sensitive. +2. If the word is a name, add it to the `scripts/config/cspell/dictionaries/people.txt` file. If it is a scientific or quantum specific word, add it to the `scripts/config/cspell/dictionaries/qiskit.txt` file. If it doesn't fit in either category, add it to the `words` section in `scripts/config/cspell/cSpell.json`. The word is not case-sensitive. If the word appears in multiple files, prefer the second approach to add it to one of the dictionaries or `cSpell.json`. @@ -386,7 +386,7 @@ This is useful when new docs content is published, usually corresponding to new 7. Select `People with the link` and go to `Link Settings`. 8. Under `Link Expiration` select `Disable Shared Link on` and set an expiration date of ~10 years into the future. 9. Copy the direct link at the end of the `Shared Link Settings` tab. -10. Modify the `scripts/api-html-artifacts.json` file adding the new versions with the direct link from step 9. +10. Modify the `scripts/config/api-html-artifacts.json` file, adding the new versions with the direct link from step 9. 11. Run `npm run gen-api -- -p -v `, e.g. `npm run gen-api -- -p qiskit -v 0.45.0` diff --git a/package.json b/package.json index f1221030ed..40d22d81ae 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "typecheck": "tsc", "check": "npm run check:qiskit-bot && npm run check:patterns-index && npm run check:metadata && npm run check:spelling && npm run check:internal-links && npm run check:orphan-pages && npm run check:fmt", "check:metadata": "node -r esbuild-register scripts/js/commands/checkMetadata.ts", - "check:spelling": "cspell --relative --no-progress docs/**/*.md* docs/api/**/*.md* --config cspell/cSpell.json", + "check:spelling": "cspell --no-progress docs/**/*.mdx docs/api/**/*.mdx --config scripts/config/cspell/cSpell.json", "check:fmt": "prettier --check .", "check:internal-links": "node -r esbuild-register scripts/js/commands/checkInternalLinks.ts", "check:external-links": "node -r esbuild-register scripts/js/commands/checkExternalLinks.ts", diff --git a/scripts/api-html-artifacts.json b/scripts/config/api-html-artifacts.json similarity index 100% rename from scripts/api-html-artifacts.json rename to scripts/config/api-html-artifacts.json diff --git a/cspell/cSpell.json b/scripts/config/cspell/cSpell.json similarity index 88% rename from cspell/cSpell.json rename to scripts/config/cspell/cSpell.json index ee7e03fd5a..3527971e61 100644 --- a/cspell/cSpell.json +++ b/scripts/config/cspell/cSpell.json @@ -50,9 +50,9 @@ ], "ignorePaths": [ // We cannot easily control these API docs since they live in other repositories. - "../docs/api/qiskit/**/*.mdx", - "../docs/api/qiskit-ibm-runtime/**/*.mdx", - "../docs/api/qiskit-ibm-provider/**/*.mdx", - "../docs/api/qiskit-transpiler-service/**/*.mdx" + "../../../docs/api/qiskit/**/*.mdx", + "../../../docs/api/qiskit-ibm-runtime/**/*.mdx", + "../../../docs/api/qiskit-ibm-provider/**/*.mdx", + "../../../docs/api/qiskit-transpiler-service/**/*.mdx" ] } diff --git a/cspell/dictionaries/people.txt b/scripts/config/cspell/dictionaries/people.txt similarity index 100% rename from cspell/dictionaries/people.txt rename to scripts/config/cspell/dictionaries/people.txt diff --git a/cspell/dictionaries/qiskit.txt b/scripts/config/cspell/dictionaries/qiskit.txt similarity index 100% rename from cspell/dictionaries/qiskit.txt rename to scripts/config/cspell/dictionaries/qiskit.txt diff --git a/scripts/nb-tester/notebooks.toml b/scripts/config/notebook-testing.toml similarity index 100% rename from scripts/nb-tester/notebooks.toml rename to scripts/config/notebook-testing.toml diff --git a/scripts/js/lib/api/sphinxArtifacts.ts b/scripts/js/lib/api/sphinxArtifacts.ts index 56c21f281d..01a9648e40 100644 --- a/scripts/js/lib/api/sphinxArtifacts.ts +++ b/scripts/js/lib/api/sphinxArtifacts.ts @@ -42,7 +42,7 @@ export async function downloadSphinxArtifact(pkg: Pkg, artifactFolder: string) { } const artifactJson = JSON.parse( - fs.readFileSync(`scripts/api-html-artifacts.json`, "utf-8"), + fs.readFileSync(`scripts/config/api-html-artifacts.json`, "utf-8"), ); const artifactName = pkg.isDev() ? "dev" : `${pkg.versionWithoutPatch}`; diff --git a/scripts/nb-tester/test/test_notebook_classification.py b/scripts/nb-tester/test/test_notebook_classification.py index ed914ec899..4308ef7ee5 100644 --- a/scripts/nb-tester/test/test_notebook_classification.py +++ b/scripts/nb-tester/test/test_notebook_classification.py @@ -9,12 +9,10 @@ def test_all_notebooks_are_classified(): filenames=None, write=False, submit_jobs=True, - config_path="scripts/nb-tester/notebooks.toml" + config_path="scripts/config/notebook-testing.toml" ) - config = Config.from_args(args) - unclassified = [ path for path in Path(".").glob("[!.]*/**/*.ipynb") if not matches(path, config.all_notebooks) diff --git a/tox.ini b/tox.ini index d52f5525ba..ef5e90f9b4 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = -e scripts/nb-tester -r scripts/nb-tester/requirements.txt setenv = PYDEVD_DISABLE_FILE_VALIDATION=1 -commands = test-docs-notebooks {posargs} --config-path scripts/nb-tester/notebooks.toml +commands = test-docs-notebooks {posargs} --config-path scripts/config/notebook-testing.toml [testenv:{lint,fix}] deps = squeaky==0.7.0