Skip to content

Migrate closed source documentation#70

Merged
Eric-Arellano merged 9 commits intomainfrom
EA/migrate-iqp-programmatic
Oct 4, 2023
Merged

Migrate closed source documentation#70
Eric-Arellano merged 9 commits intomainfrom
EA/migrate-iqp-programmatic

Conversation

@Eric-Arellano
Copy link
Copy Markdown
Collaborator

@Eric-Arellano Eric-Arellano commented Oct 4, 2023

Closes #21.

The code was copied with the below script. The closed source repository got most of its content from open source, but did not use a Git migration to transfer over commit history. So rather than using a Git migration like we did with qiskit-tutorials (Qiskit/qiskit#10710), this manually attributes relevant contributors for the files they had an influence on.

import shutil
import subprocess
from dataclasses import dataclass
from pathlib import Path

IQP_ROOT = Path("../<>")
DOCS_ROOT = Path("./")


@dataclass(frozen=True)
class Author:
    name: str
    email: str

    def commit_line(self) -> str:
        return f"Co-authored-by: {self.name} <{self.email}>"


AXEL = Author("Axel Hernández Ferrera", "[email protected]")
ABBY_C = Author("Abby Cross", "[email protected]")
BECKY = Author("Rebecca Dimock", "[email protected]")
FRANK = Author("Frank Harkins", "[email protected]")
KEVIN = Author("Kevin Tian", "[email protected]")
JESSIE = Author("Jessie Yu", "[email protected]")
ELENA = Author("Elena Peña Tapia", "[email protected]")
PAUL_N = Author("Paul Nation", "[email protected]")
SOOLU = Author("Soolu Thomas", "[email protected]")
THOMAS_A = Author("Thomas Alexander", "[email protected]")
JAKE_L = Author("Jake Lishman", "[email protected]")
MICHAEL_H = Author("Michael Healy", "[email protected]")
MARIUS = Author("Marius Hillenbrand", "[email protected]")
REZA = Author("Reza Jokar", "[email protected]")


def main() -> None:
    # Copy images
    copy_image_folders(
        [
            "build",
            "migration",
            "optimize",
            "qiskit-ibm-runtime",
            "run",
            "start",
        ]
    )
    commit("Migrate images from closed source", [])

    # Copy TOC files
    copy_docs_files(
        [
            "build/_toc.json",
            "optimize/_toc.json",
            "run/_toc.json",
            "start/_toc.json",
            "test/_toc.json",
        ]
    )
    commit("Migrate TOC files from closed source", [AXEL])

    # Copy original content
    copy_docs_files(
        [
            "start/index.mdx",
            "start/install.mdx",
            "start/intro-to-qiskit.ipynb",
            "start/runtime.mdx",
            "build/index.mdx",
            "build/first-circuit.mdx",
            "build/operators_overview.ipynb",
            "build/primitives.mdx",
            "build/primitives-get-started.mdx",
            "build/primitives-examples.mdx",
            "build/feature-table.mdx",
            "build/backend_reset.ipynb",
            "build/pulse.ipynb",
            "test/index.mdx",
            "test/simulators.mdx",
            "optimize/index.mdx",
            "run/hardware.mdx",
            "run/instances.mdx",
            "run/backends.mdx",
            "run/estimate-job.mdx",
            "run/queue.mdx",
            "run/circuit-execution.mdx",
            "run/reserve-system-time.mdx",
            "run/retired-systems.mdx",
        ]
    )
    commit("Migrate original content from closed source", [ABBY_C, BECKY])

    # Copy hello world
    copy_docs_files(["start/hello-world.ipynb"])
    commit("Migrate Hello World guide from closed source", [FRANK, BECKY, ABBY_C])

    # Copy runtime migration guides
    copy_docs_files(
        ["start/compare.mdx", "start/migrate.mdx", "start/migrate-examples.mdx"]
    )
    commit(
        "Migrate Runtime migration guides from closed source",
        [JESSIE, KEVIN, BECKY, FRANK, ELENA],
    )

    # Copy dynamic circuits
    copy_docs_files(
        [
            "build/getting-started-with-dynamic-circuits.ipynb",
            "build/midcircuit_measurement.ipynb",
            "build/dynamic-circuits-basics-with-qiskit.ipynb",
            "build/dynamic-circuits-basics-with-openqasm3.ipynb",
        ]
    )
    commit(
        "Migrate Dynamic Circuits content from closed source",
        [SOOLU, THOMAS_A, JAKE_L, MARIUS, MICHAEL_H, REZA, BECKY, ABBY_C],
    )

    # Copy runtime content
    copy_docs_files(
        [
            "build/primitive-options.mdx",
            "test/noise.mdx",
            "optimize/algorithm-tuning-options.mdx",
            "optimize/error-mitigation.mdx",
            "optimize/error-suppression.mdx",
            "run/account-management.mdx",
            "run/sessions.mdx",
            "run/run-sessions.mdx",
            "run/monitor.mdx",
            "run/cost.mdx",
            "run/max-execution-time.mdx",
        ]
    )
    commit(
        "Migrate Runtime content from closed source",
        [JESSIE, KEVIN, BECKY, ABBY_C],
    )

    # Copy Aer tutorial
    copy_docs_files(["test/building_noise_models.ipynb"])
    commit("Migrate Aer noise model from closed source", [PAUL_N])


def copy_docs_files(files: list[str]) -> None:
    for f in files:
        dest = DOCS_ROOT / "docs" / f
        dest.parent.mkdir(parents=True, exist_ok=True)
        shutil.copy(IQP_ROOT / "docs" / f, dest)


def copy_image_folders(folders: list[str]) -> None:
    for folder in folders:
        shutil.copytree(
            IQP_ROOT / "packages" / "web" / "public" / "images" / folder,
            DOCS_ROOT / "public" / "images" / folder,
        )


def commit(msg: str, authors: list[Author]) -> None:
    subprocess.run(["git", "add", "."], check=True)
    if authors:
        author_lines = "\n".join(author.commit_line() for author in authors)
        msg += f"\n\n{author_lines}"
    subprocess.run(["git", "commit", "-m", msg], check=True)


main()

Copy link
Copy Markdown
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Script is very clean and the results match up with what I'd expect.

How did you get the authors for each file?

@Eric-Arellano
Copy link
Copy Markdown
Collaborator Author

How did you get the authors for each file?

For most of them, based on Abby's recommendation in #70. But some of them like the migration guides I looked at GitHub history.

I asked @abbycross @beckykd and @javabster to take a look today at the author lists to see if I missed something, like original content was instead pulled from another repo.

Copy link
Copy Markdown
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on my end, thanks!

@javabster
Copy link
Copy Markdown
Contributor

javabster commented Oct 4, 2023

I think there are some files that are in this migration list that dont need to be migrated over, give me a second to check. Things like the pulse file and operators overview

@javabster
Copy link
Copy Markdown
Contributor

oh wait, did we decide to just migrate them over but then immediately replace them with the equivalent qiskit tutorials after?

@Eric-Arellano
Copy link
Copy Markdown
Collaborator Author

did we decide to just migrate them over but then immediately replace them with the equivalent qiskit tutorials after?

Yep, exactly! Make this migration as easy as possible. We want to keep separate logical changes from simply copy and paste.

Copy link
Copy Markdown
Contributor

@javabster javabster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, if we realise we forgot to add any authors we can always add them in a follow up PR.

Great work! 🚀

Eric-Arellano and others added 8 commits October 4, 2023 12:33
Co-authored-by: Axel Hernández Ferrera <[email protected]>
Co-authored-by: Abby Cross <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
Co-authored-by: Frank Harkins <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
Co-authored-by: Abby Cross <[email protected]>
Co-authored-by: Jessie Yu <[email protected]>
Co-authored-by: Kevin Tian <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
Co-authored-by: Frank Harkins <[email protected]>
Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: Soolu Thomas <[email protected]>
Co-authored-by: Thomas Alexander <[email protected]>
Co-authored-by: Jake Lishman <[email protected]>
Co-authored-by: Marius Hillenbrand <[email protected]>
Co-authored-by: Michael Healy <[email protected]>
Co-authored-by: Reza Jokar <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
Co-authored-by: Abby Cross <[email protected]>
Co-authored-by: Jessie Yu <[email protected]>
Co-authored-by: Kevin Tian <[email protected]>
Co-authored-by: Rebecca Dimock <[email protected]>
Co-authored-by: Abby Cross <[email protected]>
@Eric-Arellano
Copy link
Copy Markdown
Collaborator Author

Thanks for the reviews! FYI I just re-ran the script to pull in new changes from closed source. Merging once this goes green.

@Eric-Arellano Eric-Arellano merged commit fa3a05f into main Oct 4, 2023
@Eric-Arellano Eric-Arellano deleted the EA/migrate-iqp-programmatic branch October 4, 2023 16:47
Eric-Arellano added a commit that referenced this pull request Oct 4, 2023
I left these off in #70 on
accident. The files are copy and pasted without changes.
Eric-Arellano added a commit that referenced this pull request Oct 10, 2023
This improves upon #70.
These files were basically copy and pasted from open source, so we want
to bring in the proper Git history for them.

This PR is split into four commits—and we won't squash and merge—so that
Git properly detects how the files have changed.

This update also results in us bringing in some improvements to
operators_overview that had been made in open source, like fixing typos.
frankharkins pushed a commit to frankharkins/documentation that referenced this pull request Jul 22, 2024
Closes Qiskit#21. 

The code was copied with the below script. The closed source repository
got most of its content from open source, but did not use a Git
migration to transfer over commit history. So rather than using a Git
migration like we did with `qiskit-tutorials`
(Qiskit/qiskit#10710), this manually attributes
relevant contributors for the files they had an influence on.

```python
import shutil
import subprocess
from dataclasses import dataclass
from pathlib import Path

IQP_ROOT = Path("../iqp-channel-docs")
DOCS_ROOT = Path("./")


@DataClass(frozen=True)
class Author:
    name: str
    email: str

    def commit_line(self) -> str:
        return f"Co-authored-by: {self.name} <{self.email}>"


AXEL = Author("Axel Hernández Ferrera", "[email protected]")
ABBY_C = Author("Abby Cross", "[email protected]")
BECKY = Author("Rebecca Dimock", "[email protected]")
FRANK = Author("Frank Harkins", "[email protected]")
KEVIN = Author("Kevin Tian", "[email protected]")
JESSIE = Author("Jessie Yu", "[email protected]")
ELENA = Author("Elena Peña Tapia", "[email protected]")
PAUL_N = Author("Paul Nation", "[email protected]")
SOOLU = Author("Soolu Thomas", "[email protected]")
THOMAS_A = Author("Thomas Alexander", "[email protected]")
JAKE_L = Author("Jake Lishman", "[email protected]")
MICHAEL_H = Author("Michael Healy", "[email protected]")
MARIUS = Author("Marius Hillenbrand", "[email protected]")
REZA = Author("Reza Jokar", "[email protected]")


def main() -> None:
    # Copy images
    copy_image_folders(
        [
            "build",
            "migration",
            "optimize",
            "qiskit-ibm-runtime",
            "run",
            "start",
        ]
    )
    commit("Migrate images from closed source", [])

    # Copy TOC files
    copy_docs_files(
        [
            "build/_toc.json",
            "optimize/_toc.json",
            "run/_toc.json",
            "start/_toc.json",
            "test/_toc.json",
        ]
    )
    commit("Migrate TOC files from closed source", [AXEL])

    # Copy original content
    copy_docs_files(
        [
            "start/index.mdx",
            "start/install.mdx",
            "start/intro-to-qiskit.ipynb",
            "start/runtime.mdx",
            "build/index.mdx",
            "build/first-circuit.mdx",
            "build/operators_overview.ipynb",
            "build/primitives.mdx",
            "build/primitives-get-started.mdx",
            "build/primitives-examples.mdx",
            "build/feature-table.mdx",
            "build/backend_reset.ipynb",
            "build/pulse.ipynb",
            "test/index.mdx",
            "test/simulators.mdx",
            "optimize/index.mdx",
            "run/hardware.mdx",
            "run/instances.mdx",
            "run/backends.mdx",
            "run/estimate-job.mdx",
            "run/queue.mdx",
            "run/circuit-execution.mdx",
            "run/reserve-system-time.mdx",
            "run/retired-systems.mdx",
        ]
    )
    commit("Migrate original content from closed source", [ABBY_C, BECKY])

    # Copy hello world
    copy_docs_files(["start/hello-world.ipynb"])
    commit("Migrate Hello World guide from closed source", [FRANK, BECKY, ABBY_C])

    # Copy runtime migration guides
    copy_docs_files(
        ["start/compare.mdx", "start/migrate.mdx", "start/migrate-examples.mdx"]
    )
    commit(
        "Migrate Runtime migration guides from closed source",
        [JESSIE, KEVIN, BECKY, FRANK, ELENA],
    )

    # Copy dynamic circuits
    copy_docs_files(
        [
            "build/getting-started-with-dynamic-circuits.ipynb",
            "build/midcircuit_measurement.ipynb",
            "build/dynamic-circuits-basics-with-qiskit.ipynb",
            "build/dynamic-circuits-basics-with-openqasm3.ipynb",
        ]
    )
    commit(
        "Migrate Dynamic Circuits content from closed source",
        [SOOLU, THOMAS_A, JAKE_L, MARIUS, MICHAEL_H, REZA, BECKY, ABBY_C],
    )

    # Copy runtime content
    copy_docs_files(
        [
            "build/primitive-options.mdx",
            "test/noise.mdx",
            "optimize/algorithm-tuning-options.mdx",
            "optimize/error-mitigation.mdx",
            "optimize/error-suppression.mdx",
            "run/account-management.mdx",
            "run/sessions.mdx",
            "run/run-sessions.mdx",
            "run/monitor.mdx",
            "run/cost.mdx",
            "run/max-execution-time.mdx",
        ]
    )
    commit(
        "Migrate Runtime content from closed source",
        [JESSIE, KEVIN, BECKY, ABBY_C],
    )

    # Copy Aer tutorial
    copy_docs_files(["test/building_noise_models.ipynb"])
    commit("Migrate Aer noise model from closed source", [PAUL_N])


def copy_docs_files(files: list[str]) -> None:
    for f in files:
        dest = DOCS_ROOT / "docs" / f
        dest.parent.mkdir(parents=True, exist_ok=True)
        shutil.copy(IQP_ROOT / "docs" / f, dest)


def copy_image_folders(folders: list[str]) -> None:
    for folder in folders:
        shutil.copytree(
            IQP_ROOT / "packages" / "web" / "public" / "images" / folder,
            DOCS_ROOT / "public" / "images" / folder,
        )


def commit(msg: str, authors: list[Author]) -> None:
    subprocess.run(["git", "add", "."], check=True)
    if authors:
        author_lines = "\n".join(author.commit_line() for author in authors)
        msg += f"\n\n{author_lines}"
    subprocess.run(["git", "commit", "-m", msg], check=True)


main()
```
frankharkins pushed a commit to frankharkins/documentation that referenced this pull request Jul 22, 2024
I left these off in Qiskit#70 on
accident. The files are copy and pasted without changes.
frankharkins pushed a commit to frankharkins/documentation that referenced this pull request Jul 22, 2024
This improves upon Qiskit#70.
These files were basically copy and pasted from open source, so we want
to bring in the proper Git history for them.

This PR is split into four commits—and we won't squash and merge—so that
Git properly detects how the files have changed.

This update also results in us bringing in some improvements to
operators_overview that had been made in open source, like fixing typos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migrate files from closed source to Qiskit/docs

3 participants