Skip to content

Commit

Permalink
Link checker: Qiskit legacy release notes in a single FileBatch (#881)
Browse files Browse the repository at this point in the history
The legacy release notes of qiskit were generated from qiskit 0.45 and
we need to check them loading those docs. This PR groups together all
the legacy release notes in a FileBatch to avoid loading the same docs
multiple times.
  • Loading branch information
arnaucasau authored Feb 23, 2024
1 parent 65185c1 commit 53d96eb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 49 deletions.
68 changes: 46 additions & 22 deletions scripts/commands/checkLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { hideBin } from "yargs/helpers";
import { pathExists } from "../lib/fs";
import { File } from "../lib/links/LinkChecker";
import { FileBatch } from "../lib/links/FileBatch";
import { QISKIT_MISSING_VERSION_MAPPING } from "../lib/qiskitMetapackage";

// While these files don't exist in this repository, the link
// checker should assume that they exist in production.
Expand Down Expand Up @@ -114,6 +113,7 @@ const QISKIT_GLOBS_TO_LOAD = [
"docs/build/pulse.ipynb",
"docs/start/install.mdx",
"docs/api/qiskit/release-notes/0.44.md",
"docs/api/qiskit/release-notes/index.md",
"docs/api/qiskit-ibm-provider/index.md",
"docs/api/qiskit-ibm-provider/ibm_jupyter.md",
];
Expand Down Expand Up @@ -147,6 +147,10 @@ async function determineFileBatches(args: Arguments): Promise<FileBatch[]> {

result.push(...provider, ...runtime, ...qiskit);

if (args.qiskitReleaseNotes) {
result.push(await determineQiskitLegacyReleaseNotes());
}

return result;
}

Expand Down Expand Up @@ -261,28 +265,13 @@ async function determineHistoricalFileBatches(
}

if (checkSeparateReleaseNotes) {
toCheck.push(`docs/api/${projectName}/release-notes/${folder.name}.md`);
// Qiskit legacy release notes (< 0.45) have their own FileBatch, and we don't
// need to check them here
if (projectName == "qiskit" && +folder.name < 0.45) {
continue;
}

// Some legacy release notes don't have docs, and their links point to the closest
// next version present in the repo. QISKIT_MISSING_VERSION_MAPPING contains what
// versions point to which other version
const extraVersionsToCheck = QISKIT_MISSING_VERSION_MAPPING.get(
folder.name,
);
extraVersionsToCheck?.forEach((version) => {
toCheck.push(`docs/api/${projectName}/release-notes/${version}.md`);
});

// Temporary - remove after https://github.com/Qiskit/documentation/pull/865 is merged
toLoad.push(
"docs/api/qiskit/*.{ipynb,md,mdx}",
"docs/api/qiskit/0.46/*.md",
"docs/api/qiskit/0.44/qiskit.extensions.{Hamiltonian,Unitary}Gate.md",
"docs/api/qiskit/0.45/qiskit.quantum_info.{OneQubitEuler,TwoQubitBasis,XX}Decomposer.md",
"docs/api/qiskit/0.45/qiskit.transpiler.synthesis.aqc.AQC.md",
"docs/api/qiskit/0.45/{tools,quantum_info,synthesis_aqc}.md",
"docs/api/qiskit/release-notes/index.md",
);
toCheck.push(`docs/api/${projectName}/release-notes/${folder.name}.md`);
}

const fileBatch = await FileBatch.fromGlobs(
Expand All @@ -295,4 +284,39 @@ async function determineHistoricalFileBatches(
return result;
}

async function determineQiskitLegacyReleaseNotes(): Promise<FileBatch> {
const result: FileBatch[] = [];

const legacyVersions = (
await globby("docs/api/qiskit/release-notes/[!index]*")
)
.map((releaseNotesPath) =>
releaseNotesPath.split("/").pop()!.split(".").slice(0, -1).join("."),
)
.filter(
(version) => +version < 1 && version != "0.45" && version != "0.46",
);

const toCheck = legacyVersions.map(
(legacyVersion) => `docs/api/qiskit/release-notes/${legacyVersion}.md`,
);

return await FileBatch.fromGlobs(
toCheck,
// Temporary - remove after https://github.com/Qiskit/documentation/pull/865 is merged
[
`docs/api/qiskit/0.45/*`,
"docs/api/qiskit/*.{ipynb,md,mdx}",
"docs/api/qiskit/0.46/*.md",
"docs/api/qiskit/0.44/qiskit.extensions.{Hamiltonian,Unitary}Gate.md",
"docs/api/qiskit/0.45/qiskit.quantum_info.{OneQubitEuler,TwoQubitBasis,XX}Decomposer.md",
"docs/api/qiskit/0.45/qiskit.transpiler.synthesis.aqc.AQC.md",
"docs/api/qiskit/0.45/{tools,quantum_info,synthesis_aqc}.md",
"docs/api/qiskit/release-notes/index.md",
"docs/api/qiskit-ibm-provider/index.md",
],
`qiskit legacy release notes`,
);
}

main().then(() => process.exit());
27 changes: 0 additions & 27 deletions scripts/lib/qiskitMetapackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,6 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

// Some Qiskit release notes don't have docs in the repo, and we need to change
// their links to point to the next closest version available. This map stores
// the next closest version with docs for some qiskit legacy versions.
export const QISKIT_MISSING_VERSION_MAPPING = new Map([
[
"0.19",
[
"0.5",
"0.6",
"0.7",
"0.8",
"0.9",
"0.10",
"0.11",
"0.12",
"0.13",
"0.14",
"0.15",
"0.16",
"0.17",
"0.18",
],
],
["0.24", ["0.20", "0.21", "0.22", "0.23"]],
["0.35", ["0.34"]],
]);

const QISKIT_METAPACKAGE_TO_TERRA = new Map([
["0.44", "0.25"],
["0.43", "0.24"],
Expand Down

0 comments on commit 53d96eb

Please sign in to comment.