Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Scripts for Deployment Testing to TestPypi #236

Merged
merged 23 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Upload to Test PyPi

on:
release:
types: [created]
workflow_dispatch:

jobs:
pypi_update:

# Only run this job if new work is pushed to "main"
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'

# Set up operating system
runs-on: ubuntu-latest

# Define job steps
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Check-out repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip build twine
pip install setuptools wheel twine

- name: Publish to Test PyPI
run: |
scripts/push_package_pypi.sh __token__ ${{secrets.PYPI_API_TOKEN}}
7 changes: 2 additions & 5 deletions .github/workflows/test_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
pip install .
pip install -e ./src/openqaoa-core[tests]
make dev-install-tests
pip install ipykernel
- name: Setup IBMQ account
env:
Expand Down Expand Up @@ -64,7 +63,6 @@ jobs:
run: |
source env/bin/activate
ipython kernel install --name "env" --user
pip install pytest-xdist
pytest tests/ src/*/tests -m 'not (qpu or sim)' --cov -n auto
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
Expand All @@ -88,8 +86,7 @@ jobs:
- name: Install OpenQAOA
run: |
python -m pip install --upgrade pip
pip install .
pip install -e ./src/openqaoa-core[docs]
make dev-install-docs

- name: Install qvm
run: |
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,37 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install OpenQAOA-Core
run: |
pip install openqaoa-core
python -c 'from openqaoa._version import __version__; print(__version__)'


- name: Install OpenQAOA-Qiskit
run: |
pip install openqaoa-qiskit
python -c 'from openqaoa._version import __version__; print(__version__)'


- name: Install OpenQAOA-Pyquil
run: |
pip install openqaoa-pyquil
python -c 'from openqaoa._version import __version__; print(__version__)'


- name: Install OpenQAOA-Braket
run: |
pip install openqaoa-braket
python -c 'from openqaoa._version import __version__; print(__version__)'


- name: Install OpenQAOA-Azure
run: |
pip install openqaoa-azure
python -c 'from openqaoa._version import __version__; print(__version__)'

- name: Install OpenQAOA
- name: Install OpenQAOA (Full)
run: |
pip install openqaoa
python -c 'from openqaoa._version import __version__; print(__version__)'
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN mkdir -p /openqaoa

ADD ./ /openqaoa/

RUN pip3 install /openqaoa/.
RUN cd openqaoa && make dev-install
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include src/* README.md requirements*.txt
include README.md
include _version.py
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
#This file stores instructions to install openqaoa in developer mode.
# Currently can only install all packages together for developer mode.
#Currently can only install all packages together for developer mode.

.PHONY: dev-install
dev-install:
pip install -e .
pip install -e ./src/openqaoa-core
pip install -e ./src/openqaoa-qiskit
pip install -e ./src/openqaoa-pyquil
pip install -e ./src/openqaoa-braket
pip install -e ./src/openqaoa-azure
pip install -e .

.PHONY: dev-install-tests
dev-install-tests:
pip install -e .
pip install -e ./src/openqaoa-core[tests]
pip install -e ./src/openqaoa-qiskit
pip install -e ./src/openqaoa-pyquil
pip install -e ./src/openqaoa-braket
pip install -e ./src/openqaoa-azure
pip install -e .

.PHONY: dev-install-docs
dev-install-docs:
pip install -e .
pip install -e ./src/openqaoa-core[docs]
pip install -e ./src/openqaoa-qiskit
pip install -e ./src/openqaoa-pyquil
pip install -e ./src/openqaoa-braket
pip install -e ./src/openqaoa-azure
pip install -e .

.PHONY: dev-install-all
dev-install-all:
pip install -e .
pip install -e ./src/openqaoa-core[all]
pip install -e ./src/openqaoa-qiskit
pip install -e ./src/openqaoa-pyquil
pip install -e ./src/openqaoa-braket
pip install -e ./src/openqaoa-azure
pip install -e .

.PHONY: dev-uninstall
dev-uninstall:
Expand Down
1 change: 1 addition & 0 deletions _version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.3-rc1"
12 changes: 0 additions & 12 deletions scripts/install_all_subpackages.sh

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/install_and_test_openqaoa_azure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ for entry in "${modulesList[@]}"; do
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
4 changes: 0 additions & 4 deletions scripts/install_and_test_openqaoa_braket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ for entry in "${modulesList[@]}"; do
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
6 changes: 1 addition & 5 deletions scripts/install_and_test_openqaoa_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ modulesList=("openqaoa-core")
for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
pip install .[tests]
cd "../.."
done

Expand All @@ -16,8 +16,4 @@ for entry in "${modulesList[@]}"; do
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
5 changes: 1 addition & 4 deletions scripts/install_and_test_openqaoa_dev.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#Exit immediately if a command exits with a non-zero status.
set -e

# TODO: Dynamically generate names (The order of installing is important here.)
modulesList=("src/openqaoa-core" "src/openqaoa-qiskit" "src/openqaoa-braket" "src/openqaoa-pyquil" "src/openqaoa-azure")

pip install .
pytest tests/ src/*/tests
pytest tests/ src/*/tests -n auto
pip uninstall -y openqaoa
4 changes: 0 additions & 4 deletions scripts/install_and_test_openqaoa_pyquil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ for entry in "${modulesList[@]}"; do
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
4 changes: 0 additions & 4 deletions scripts/install_and_test_openqaoa_qiskit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ for entry in "${modulesList[@]}"; do
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
modulesList=("openqaoa-core" "openqaoa-qiskit" "openqaoa-braket" "openqaoa-pyquil" "openqaoa-azure")
set -e

modulesList=("openqaoa-core" "openqaoa-qiskit" "openqaoa-braket" "openqaoa-pyquil" "openqaoa-azure" "openqaoa")

for entry in "${modulesList[@]}"; do
pip install -i https://test.pypi.org/simple/ --no-deps $entry
pip install --pre $entry
done
18 changes: 0 additions & 18 deletions scripts/push_package.sh

This file was deleted.

17 changes: 14 additions & 3 deletions scripts/test_build_dist.sh → scripts/push_package_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ set -e
# TODO: Dynamically generate names (The order of installing and pushing is important here.)
modulesList=("src/openqaoa-core" "src/openqaoa-qiskit" "src/openqaoa-braket" "src/openqaoa-pyquil" "src/openqaoa-azure")

# This script checks that all internal plugins have the same version number
python scripts/test_version.py

pip install build twine

# build and install plugins
for entry in "${modulesList[@]}"; do
echo "processing $entry/setup.py"
cd $entry
pip install -e .
rm -rf dist build
pip install .
python -m build
twine upload dist/* --username $1 --password $2
rm -rf dist build
cd "../.."
done
done

# build and install openqaoa metapackage
rm -rf dist build
pip install .
python -m build
twine upload dist/* --username $1 --password $2
8 changes: 8 additions & 0 deletions scripts/run_all_install_and_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -e

scripts/install_and_test_openqaoa_core.sh
scripts/install_and_test_openqaoa_qiskit.sh
scripts/install_and_test_openqaoa_pyquil.sh
scripts/install_and_test_openqaoa_braket.sh
scripts/install_and_test_openqaoa_azure.sh
scripts/install_and_test_openqaoa_dev.sh
6 changes: 0 additions & 6 deletions scripts/run_all_install_test.sh

This file was deleted.

3 changes: 3 additions & 0 deletions scripts/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
version_check = [
each_item == version_dict["openqaoa-core"] for each_item in version_dict.values()
]
with open("_version.py") as f:
meta_version = f.readlines()[-1].split()[-1].strip("\"'")
version_check.append(meta_version == version_dict["openqaoa-core"])
for each_check in version_check:
if not each_check:
raise Exception(
Expand Down
11 changes: 1 addition & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@
long_description = fh.read()

# Dev package will share versions with the core in it.
with open("src/openqaoa-core/openqaoa/_version.py") as f:
with open("_version.py") as f:
version = f.readlines()[-1].split()[-1].strip("\"'")

requirements = [f"{each_folder_name}=={version}" for each_folder_name in os.listdir("src") if "openqaoa-" in each_folder_name]

requirements = [
f'openqaoa-core @ file://localhost/{current_path}/src/openqaoa-core',
f'openqaoa-qiskit @ file://localhost/{current_path}/src/openqaoa-qiskit',
f'openqaoa-braket @ file://localhost/{current_path}/src/openqaoa-braket',
f'openqaoa-pyquil @ file://localhost/{current_path}/src/openqaoa-pyquil',
f'openqaoa-azure @ file://localhost/{current_path}/src/openqaoa-azure'
]

setup(
name="openqaoa",
python_requires=">=3.8, <3.11",
version=version,
author="Entropica Labs",
packages=find_namespace_packages(where=".", exclude=["dist", "build"]),
entry_points={"openqaoa.plugins": []},
url="https://github.com/entropicalabs/openqaoa",
install_requires=requirements,
Expand Down
2 changes: 1 addition & 1 deletion src/openqaoa-azure/openqaoa_azure/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.19"
__version__ = "0.1.3-rc1"
2 changes: 1 addition & 1 deletion src/openqaoa-braket/openqaoa_braket/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.19"
__version__ = "0.1.3-rc1"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"header": {
"atomic_id": "386997de-0e90-4e1c-8236-cd722801615f",
"experiment_id": "ce2f83d7-4000-4507-9e98-96e3f9afd55e",
"atomic_id": "d32eb15f-8b8c-4373-a24e-a2c38196d82f",
"experiment_id": "8d778c1a-a942-4997-bf69-13bd552f0ec6",
"project_id": null,
"algorithm": "rqaoa",
"description": null,
Expand Down Expand Up @@ -227,6 +227,7 @@
"initial_qubit_mapping": null,
"seed_simulator": null,
"qiskit_simulation_method": null,
"qiskit_optimization_level": null,
"active_reset": null,
"rewiring": null,
"disable_qubit_rewiring": null
Expand Down
Loading