forked from Qiskit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API generation script uses Box to download CI artifacts (Qiskit#737)
Part of Qiskit#719 This PR modifies the API generation script to download the CI artifacts stored in the Box folder https://ibm.ent.box.com/folder/246867649571 and removes the `-a <artifact-url>` argument. The PR also renames the old `scripts/lib/api/downloadCIArtifacts.ts` to `scripts/lib/api/apiArtifacts.ts` to make it more generic, and it removes the associated test. The test file only was related to the `-a` argument that was removed. --------- Co-authored-by: Eric Arellano <[email protected]>
- Loading branch information
1 parent
7439931
commit ce433e9
Showing
6 changed files
with
144 additions
and
87 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
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,35 @@ | ||
{ | ||
"qiskit": { | ||
"0.45": "https://ibm.box.com/shared/static/e2rwbrztml4dg6lkk1w3e0kmevkw9w7s.zip", | ||
"0.44": "https://ibm.box.com/shared/static/yudjd08saugb3z9stciz4zxhpkroqrv4.zip", | ||
"0.43": "https://ibm.box.com/shared/static/odcdrizljwpcz96upbu8umb5xpfvf73h.zip", | ||
"0.42": "https://ibm.box.com/shared/static/muj1v0m4x36fuqyqo22wknexj9cq8yfv.zip", | ||
"0.41": "https://ibm.box.com/shared/static/2j2qw33dgy5swf9vno0tfpq8ahey14uu.zip", | ||
"0.40": "https://ibm.box.com/shared/static/6j9mbwbeqx0kfi20zl22hzp6524kvqz8.zip", | ||
"0.39": "https://ibm.box.com/shared/static/za2u7phhpyd6lrsalv48xsxhz1ud17rd.zip", | ||
"0.38": "https://ibm.box.com/shared/static/rcyb5ugvgjc6gpgb5hkdedz5r5buashu.zip", | ||
"0.37": "https://ibm.box.com/shared/static/4nfrhcnu5ixod1i5ct1fps2qpoyfmgnb.zip", | ||
"0.36": "https://ibm.box.com/shared/static/eekpk9r8kawwxr1bfaswrcc073mien1j.zip", | ||
"0.35": "https://ibm.box.com/shared/static/dkqlxxllnhrq4yyae9fqlifab36fq2av.zip", | ||
"0.33": "https://ibm.box.com/shared/static/kmgdgi0imgam3o7jzumyjhwdz00i9y5w.zip", | ||
"0.32": "https://ibm.box.com/shared/static/tzkb58t2vgzz21i6ydg7r9g4m4995waq.zip", | ||
"0.31": "https://ibm.box.com/shared/static/d4m9d1f4uaq95ovpqo9yot1mnm1jnofw.zip", | ||
"0.30": "https://ibm.box.com/shared/static/loueznt45qyoo925gwt6cb5n1a0lp4o0.zip", | ||
"0.29": "https://ibm.box.com/shared/static/uc8s5lcrmxuy23vkb2bkn8y930m533rk.zip", | ||
"0.28": "https://ibm.box.com/shared/static/656e5bsov004vpnlmc9z40q718eq0ze2.zip", | ||
"0.27": "https://ibm.box.com/shared/static/y2lb96gl2v32si02xgbswmjc06vfvfje.zip", | ||
"0.26": "https://ibm.box.com/shared/static/5wlx2c8wr5xka5buzmlf1mqmz0zl600p.zip", | ||
"0.25": "https://ibm.box.com/shared/static/h9dw4iq19f6nz6vp0egpoyjhxqnx7ot5.zip", | ||
"0.24": "https://ibm.box.com/shared/static/pmcnjymbenwhwa3psxqsptvexs7hwrpd.zip", | ||
"0.19": "https://ibm.box.com/shared/static/ov1hqihl0hlsai31dwyjyjj06k86k2nt.zip" | ||
}, | ||
"qiskit-ibm-provider": { | ||
"0.7": "https://ibm.box.com/shared/static/o5tjrdefdz72yi35nw09l9zbjjjecips.zip" | ||
}, | ||
"qiskit-ibm-runtime": { | ||
"0.17": "https://ibm.box.com/shared/static/5r7r2x65bst3hdtcyuowwfvno5o23xw0.zip", | ||
"0.16": "https://ibm.box.com/shared/static/xbtjc270jc2uu3s8tp7tqn8o9pckl37i.zip", | ||
"0.15": "https://ibm.box.com/shared/static/j9wiuo9mga3lwihhqy9sdeqtsr4taanm.zip", | ||
"0.14": "https://ibm.box.com/shared/static/bhv1xl2pid74qsanmphx3zm49cup6owv.zip" | ||
} | ||
} |
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
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,65 @@ | ||
// This code is a Qiskit project. | ||
// | ||
// (C) Copyright IBM 2023. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0. You may | ||
// obtain a copy of this license in the LICENSE file in the root directory | ||
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
|
||
import { $ } from "zx"; | ||
import { createWriteStream } from "node:fs"; | ||
import { finished } from "stream/promises"; | ||
import { Readable } from "stream"; | ||
import fs from "fs"; | ||
|
||
import { pathExists, getRoot } from "../fs"; | ||
import { mkdirp } from "mkdirp"; | ||
import { Pkg } from "./Pkg"; | ||
|
||
async function downloadFromBox( | ||
pkgName: string, | ||
artifactUrl: string, | ||
destination: string, | ||
) { | ||
const response = await fetch(artifactUrl); | ||
if (response.ok) { | ||
const stream = createWriteStream(destination); | ||
await finished(Readable.fromWeb(response.body as any).pipe(stream)); | ||
} else { | ||
throw new Error(`Error downloading the ${pkgName} artifact from Box.`); | ||
} | ||
} | ||
|
||
export async function downloadCIArtifact(pkg: Pkg, artifactFolder: string) { | ||
if (await pathExists(artifactFolder)) { | ||
await $`rm -rf ${artifactFolder}/*`; | ||
} else { | ||
await mkdirp(artifactFolder); | ||
} | ||
|
||
const artifactJson = JSON.parse( | ||
fs.readFileSync(`${getRoot()}/scripts/api-html-artifacts.json`, "utf-8"), | ||
); | ||
|
||
if (!(`${pkg.versionWithoutPatch}` in artifactJson[`${pkg.name}`])) { | ||
throw new Error( | ||
`Package ${pkg.name} version ${pkg.versionWithoutPatch} doesn't have an artifact stored. You can add one to https://ibm.ent.box.com/folder/246867452622 | ||
following the steps detailed in the \`Generate the API docs\` section on the repo's README. If you are not an IBMer with access to the Box folder, | ||
you can ask in your pull request for a maintainer to help you. In the meantime, you can use another URL in api-html-artifacts.json, such as GitHub or | ||
even localhost for a server you start up; the URL needs to result in downloading the zip file.`, | ||
); | ||
} | ||
const artifactUrl = artifactJson[`${pkg.name}`][`${pkg.versionWithoutPatch}`]; | ||
|
||
await downloadFromBox( | ||
pkg.name, | ||
artifactUrl, | ||
`${artifactFolder}/artifact.zip`, | ||
); | ||
|
||
await $`unzip -qqo ${artifactFolder}/artifact.zip -d ${artifactFolder}/artifact`; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.