Skip to content

Commit

Permalink
Merge pull request #202 from entropicalabs/dev_setup_change
Browse files Browse the repository at this point in the history
Setup file Changes for OpenQAOA Plugins
  • Loading branch information
vishal-ph authored May 12, 2023
2 parents acadb28 + 259fea1 commit 73910db
Show file tree
Hide file tree
Showing 243 changed files with 4,954 additions and 2,883 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/test_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip
pip install .[tests]
pip install .
pip install -e ./src/openqaoa-core[tests]
pip install ipykernel
- name: Setup IBMQ account
env:
Expand Down Expand Up @@ -63,8 +64,8 @@ jobs:
run: |
source env/bin/activate
ipython kernel install --name "env" --user
pytest tests/ -m 'not (qpu or sim)' --cov --cov-report=xml:coverage.xml
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
with:
Expand All @@ -87,7 +88,8 @@ jobs:
- name: Install OpenQAOA
run: |
python -m pip install --upgrade pip
pip install .[docs]
pip install .
pip install -e ./src/openqaoa-core[docs]
- name: Install qvm
run: |
Expand Down
10 changes: 9 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ sphinx:
python:
install:
- method: pip
path: .
path: ./src/openqaoa-core
extra_requirements:
- docs
- method: pip
path: ./src/openqaoa-qiskit
- method: pip
path: ./src/openqaoa-pyquil
- method: pip
path: ./src/openqaoa-azure
- method: pip
path: ./src/openqaoa-braket
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include src/* README.md requirements*.txt
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#This file stores instructions to install openqaoa in 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

.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

.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

.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

.PHONY: dev-uninstall
dev-uninstall:
pip uninstall openqaoa -y
pip uninstall openqaoa-core -y
pip uninstall openqaoa-qiskit -y
pip uninstall openqaoa-pyquil -y
pip uninstall openqaoa-braket -y
pip uninstall openqaoa-azure -y
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@ To run the test, first, make sure to have installed all the optional testing dep

> :warning: **Some tests require authentication**: Please, check the flags in `pytest.ini`. Currently these testes are marked `qpu`, `api`, `docker_aws`, `braket_api`, `sim`
> :warning: **Some tests require Rigetti's QVM or a valid AWS Jobs docker**: Please, note these tests are marked as `qvm` and `docker_aws` (see Rigetti's documentation [here](https://pyquil-docs.rigetti.com/en/v3.1.0/qvm.html) for more information).
> :warning: **Some tests require authentication**: Please, note that the PyQuil-Rigetti tests contained in `test_pyquil_qvm.py` requires an active `qvm` (see Rigetti's documentation [here](https://pyquil-docs.rigetti.com/en/v3.1.0/qvm.html))
## For Developers

This repository was packaged with `poetry`. The default `pyproject.toml` file installs the internal plugin depedencies as editable through `poetry`. If you need to create an editable install of this repository do the following in the root directory of this repository:

```bash
poetry install
```

## Contributing and feedback

If you find any bugs or errors, have feature requests, or code you would like to contribute, feel free to open an issue or send us a pull request on GitHub.
Expand Down
19 changes: 19 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath("../../"))
sys.path.insert(0, os.path.abspath("../.."))
for each_folder_name in os.listdir(os.path.abspath("../../src")):
sys.path.insert(0, os.path.abspath("../../src/" + each_folder_name))
# sys.path.insert(0, os.path.abspath("../../src/openqaoa-core"))
# sys.path.insert(0, os.path.abspath("../../src/openqaoa-qiskit"))
# sys.path.insert(0, os.path.abspath("../../src/openqaoa-pyquil"))
# sys.path.insert(0, os.path.abspath("../../src/openqaoa-braket"))
# sys.path.insert(0, os.path.abspath("../../src/openqaoa-azure"))
print(sys.path)

# from openqaoa.qaoa_parameters.baseparams import shapedArray
Expand Down Expand Up @@ -51,6 +58,18 @@
"sphinx.ext.intersphinx",
]

autodoc_mock_imports = [
"botocore",
"qiskit_aer",
"pyquil",
"azure",
"boto3",
"qcs_api_client",
"qiskit_ibm_provider",
"qiskit",
"braket",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"
12 changes: 12 additions & 0 deletions scripts/install_all_subpackages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Exit immediately if a command exits with a non-zero status.
set -e

# The order of install is important therefore the list cannot be dynamically generated
modulesList=("openqaoa-core" "openqaoa-qiskit" "openqaoa-braket" "openqaoa-pyquil" "openqaoa-azure")

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done
23 changes: 23 additions & 0 deletions scripts/install_and_test_openqaoa_azure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Exit immediately if a command exits with a non-zero status.
set -e

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

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done

for entry in "${modulesList[@]}"; do
echo "testing $entry"
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
23 changes: 23 additions & 0 deletions scripts/install_and_test_openqaoa_braket.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#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=("openqaoa-core" "openqaoa-braket")

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done

for entry in "${modulesList[@]}"; do
echo "testing $entry"
cd src/$entry
pytest -n auto tests
cd "../.."
done

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

# TODO: Dynamically generate names (The order of installing and pushing is important here.)
modulesList=("openqaoa-core")

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done

for entry in "${modulesList[@]}"; do
echo "testing $entry"
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
9 changes: 9 additions & 0 deletions scripts/install_and_test_openqaoa_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#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
pip uninstall -y openqaoa
23 changes: 23 additions & 0 deletions scripts/install_and_test_openqaoa_pyquil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Exit immediately if a command exits with a non-zero status.
set -e

# TODO: Dynamically generate names (The order of installing and pushing is important here.)
modulesList=("openqaoa-core" "openqaoa-pyquil")

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done

for entry in "${modulesList[@]}"; do
echo "testing $entry"
cd src/$entry
pytest -n auto tests
cd "../.."
done

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

# TODO: Dynamically generate names (The order of installing and pushing is important here.)
modulesList=("openqaoa-core" "openqaoa-qiskit")

for entry in "${modulesList[@]}"; do
echo "processing src/$entry/setup.py"
cd src/$entry
pip install .
cd "../.."
done

for entry in "${modulesList[@]}"; do
echo "testing $entry"
cd src/$entry
pytest -n auto tests
cd "../.."
done

for entry in "${modulesList[@]}"; do
pip uninstall -y $entry
done
18 changes: 18 additions & 0 deletions scripts/push_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Exit immediately if a command exits with a non-zero status.
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")

python scripts/test_version.py

for entry in "${modulesList[@]}"; do
echo "processing $entry/setup.py"
cd $entry
pip install .
# python -m build
python3 setup.py -q sdist
python3 setup.py -q bdist_wheel
twine upload --repository testpypi dist/* --username $1 --password $2
cd "../.."
done
6 changes: 6 additions & 0 deletions scripts/run_all_install_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
install_and_test_openqaoa_core.sh
install_and_test_openqaoa_qiskit.sh
install_and_test_openqaoa_pyquil.sh
install_and_test_openqaoa_braket.sh
install_and_test_openqaoa_azure.sh
install_and_test_openqaoa_dev.sh
16 changes: 16 additions & 0 deletions scripts/test_build_dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#Exit immediately if a command exits with a non-zero status.
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

for entry in "${modulesList[@]}"; do
echo "processing $entry/setup.py"
cd $entry
pip install -e .
python -m build
cd "../.."
done
5 changes: 5 additions & 0 deletions scripts/test_install_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
modulesList=("openqaoa-core" "openqaoa-qiskit" "openqaoa-braket" "openqaoa-pyquil" "openqaoa-azure")

for entry in "${modulesList[@]}"; do
pip install -i https://test.pypi.org/simple/ --no-deps $entry
done
31 changes: 31 additions & 0 deletions scripts/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import importlib

version_dict = {}
for each_file in os.listdir("src"):
if each_file.startswith("openqaoa-"):
__version__ = ""
if not each_file == "openqaoa-core":
exec(
open(
"./src/"
+ each_file
+ "/"
+ each_file.replace("-", "_")
+ "/_version.py"
).read()
)
else:
exec(open("./src/" + each_file + "/openqaoa/_version.py").read())
version_dict.update({each_file: __version__})

version_check = [
each_item == version_dict["openqaoa-core"] for each_item in version_dict.values()
]
for each_check in version_check:
if not each_check:
raise Exception(
"All Plugins should have the same version as the core version of OQ. {}".format(
version_dict
)
)
Loading

0 comments on commit 73910db

Please sign in to comment.