From 4af7d4fd3f6245008925684b489782e84d3fd3dd Mon Sep 17 00:00:00 2001 From: Milan Krneta Date: Wed, 24 Apr 2024 14:46:18 -0700 Subject: [PATCH] fixing version location --- .gitignore | 1 + pyproject.toml | 3 -- setup.py | 29 ++----------------- src/braket/simulator_v2/__init__.py | 3 +- .../simulator_v2/{version.py => _version.py} | 0 src/braket/version.py | 16 ---------- .../gate_model_device_testing_utils.py | 1 - .../test_local_braket_simulator.py | 3 +- .../test_local_noise_simulator.py | 3 +- .../test_density_matrix_simulator.py | 4 +-- .../test_state_vector_simulator.py | 4 +-- tox.ini | 4 +-- 12 files changed, 12 insertions(+), 59 deletions(-) rename src/braket/simulator_v2/{version.py => _version.py} (100%) delete mode 100644 src/braket/version.py diff --git a/.gitignore b/.gitignore index 3b56787..18da756 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ __pycache__/ *.ipynb_checkpoints/ pip-wheel-metadata/ +coverage.xml /.coverage /.coverage.* /.cache diff --git a/pyproject.toml b/pyproject.toml index 0020ec7..91727d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,6 @@ build-backend = "setuptools.build_meta" [project] name = "amazon-braket-simulator-v2" version = "0.0.1" -authors = [ - {name = "Katharine Hyatt", email = "hyatkath@amazon.com"}, -] description = "Local simulation of quantum circuits" readme = {file = "README.md", content-type = "text/markdown"} license = {file = "LICENSE"} diff --git a/setup.py b/setup.py index 3118db2..ee9650b 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,9 @@ -import os - from setuptools import setup -if os.path.exists(".git"): - kwargs = { - "use_scm_version": { - "write_to": "src/braket/version.py", - }, - "setup_requires": ["setuptools", "setuptools_scm"], - } -else: - # Read from pyproject.toml directly - import re - - with open(os.path.join(os.path.dirname(__file__), "pyproject.toml")) as f: - data = f.read() - # Find the version - version = re.search(r'version = "(.*)"', data).group(1) - - # Write the version to version.py - with open( - os.path.join(os.path.dirname(__file__), "src", "braket", "version.py"), - "w", - ) as f: - f.write(f'__version__ = "{version}"') - - kwargs = {"version": version} +with open("src/braket/simulator_v2/_version.py") as f: + version = f.readlines()[-1].split()[-1].strip("\"'") +kwargs = {"version": version} # Build options are managed in pyproject.toml setup(**kwargs) diff --git a/src/braket/simulator_v2/__init__.py b/src/braket/simulator_v2/__init__.py index 195ade0..21245e1 100644 --- a/src/braket/simulator_v2/__init__.py +++ b/src/braket/simulator_v2/__init__.py @@ -7,8 +7,7 @@ StateVectorSimulatorV2, ) -# This file is created by setuptools_scm during the build process: -from .version import __version__ +from ._version import __version__ # noqa: F401 __all__ = [ "jl", diff --git a/src/braket/simulator_v2/version.py b/src/braket/simulator_v2/_version.py similarity index 100% rename from src/braket/simulator_v2/version.py rename to src/braket/simulator_v2/_version.py diff --git a/src/braket/version.py b/src/braket/version.py deleted file mode 100644 index c3100cd..0000000 --- a/src/braket/version.py +++ /dev/null @@ -1,16 +0,0 @@ -# file generated by setuptools_scm -# don't change, don't track in version control -TYPE_CHECKING = False -if TYPE_CHECKING: - from typing import Tuple, Union - VERSION_TUPLE = Tuple[Union[int, str], ...] -else: - VERSION_TUPLE = object - -version: str -__version__: str -__version_tuple__: VERSION_TUPLE -version_tuple: VERSION_TUPLE - -__version__ = version = '0.1.dev36+g39f25c0.d20240410' -__version_tuple__ = version_tuple = (0, 1, 'dev36', 'g39f25c0.d20240410') diff --git a/test/integ_tests/braket/simulator_v2/gate_model_device_testing_utils.py b/test/integ_tests/braket/simulator_v2/gate_model_device_testing_utils.py index a580db5..d48ee72 100644 --- a/test/integ_tests/braket/simulator_v2/gate_model_device_testing_utils.py +++ b/test/integ_tests/braket/simulator_v2/gate_model_device_testing_utils.py @@ -16,7 +16,6 @@ from typing import Any, Dict, Union import numpy as np - from braket.aws import AwsDevice from braket.circuits import Circuit, Gate, Instruction, Observable, ResultType from braket.circuits.quantum_operator_helpers import get_pauli_eigenvalues diff --git a/test/integ_tests/braket/simulator_v2/test_local_braket_simulator.py b/test/integ_tests/braket/simulator_v2/test_local_braket_simulator.py index fc1ef48..6f2b8bc 100644 --- a/test/integ_tests/braket/simulator_v2/test_local_braket_simulator.py +++ b/test/integ_tests/braket/simulator_v2/test_local_braket_simulator.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. import pytest +from braket.devices import LocalSimulator from gate_model_device_testing_utils import ( multithreaded_bell_pair_testing, no_result_types_bell_pair_testing, @@ -34,8 +35,6 @@ result_types_zero_shots_bell_pair_testing, ) -from braket.devices import LocalSimulator - DEVICE = LocalSimulator("braket_sv_v2") SHOTS = 8000 diff --git a/test/integ_tests/braket/simulator_v2/test_local_noise_simulator.py b/test/integ_tests/braket/simulator_v2/test_local_noise_simulator.py index d96d6be..3eda2da 100644 --- a/test/integ_tests/braket/simulator_v2/test_local_noise_simulator.py +++ b/test/integ_tests/braket/simulator_v2/test_local_noise_simulator.py @@ -12,6 +12,7 @@ # language governing permissions and limitations under the License. import pytest +from braket.devices import LocalSimulator from gate_model_device_testing_utils import ( no_result_types_bell_pair_testing, noisy_circuit_1qubit_noise_full_probability, @@ -33,8 +34,6 @@ result_types_tensor_z_z_testing, ) -from braket.devices import LocalSimulator - DEVICE = LocalSimulator("braket_dm_v2") SHOTS = 8000 diff --git a/test/unit_tests/braket/simulator_v2/test_density_matrix_simulator.py b/test/unit_tests/braket/simulator_v2/test_density_matrix_simulator.py index 82135ce..c2d68f4 100644 --- a/test/unit_tests/braket/simulator_v2/test_density_matrix_simulator.py +++ b/test/unit_tests/braket/simulator_v2/test_density_matrix_simulator.py @@ -18,7 +18,6 @@ import numpy as np import pytest - from braket.device_schema.simulators import ( GateModelSimulatorDeviceCapabilities, GateModelSimulatorDeviceParameters, @@ -26,9 +25,10 @@ from braket.ir.jaqcd import Expectation from braket.ir.jaqcd import Program as JaqcdProgram from braket.ir.openqasm import Program as OpenQASMProgram -from braket.simulator_v2 import DensityMatrixSimulatorV2 as DensityMatrixSimulator from braket.task_result import AdditionalMetadata, TaskMetadata +from braket.simulator_v2 import DensityMatrixSimulatorV2 as DensityMatrixSimulator + CircuitData = namedtuple("CircuitData", "circuit_ir probability_zero") diff --git a/test/unit_tests/braket/simulator_v2/test_state_vector_simulator.py b/test/unit_tests/braket/simulator_v2/test_state_vector_simulator.py index d3e2282..0a24dbe 100644 --- a/test/unit_tests/braket/simulator_v2/test_state_vector_simulator.py +++ b/test/unit_tests/braket/simulator_v2/test_state_vector_simulator.py @@ -21,7 +21,6 @@ import numpy as np import pytest - from braket.default_simulator import observables from braket.device_schema.simulators import ( GateModelSimulatorDeviceCapabilities, @@ -31,9 +30,10 @@ from braket.ir.jaqcd import Program as JaqcdProgram from braket.ir.jaqcd import StateVector, Variance from braket.ir.openqasm import Program as OpenQASMProgram -from braket.simulator_v2 import StateVectorSimulatorV2 as StateVectorSimulator from braket.task_result import AdditionalMetadata, TaskMetadata +from braket.simulator_v2 import StateVectorSimulatorV2 as StateVectorSimulator + CircuitData = namedtuple("CircuitData", "circuit_ir probability_zero") diff --git a/tox.ini b/tox.ini index 39cd8a1..6efaff0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = linters,docs,unit-tests,integ-tests +envlist = linters,docs,unit-tests [testenv:unit-tests] basepython = python3 @@ -12,7 +12,6 @@ deps = allowlist_externals = pytest commands = - python julia_private_repo_setup/setup_private_repos.py pytest {posargs} --cov-report term-missing --cov-report html --cov-report xml --cov=braket extras = test @@ -27,7 +26,6 @@ deps = allowlist_externals = pytest commands = - python julia_private_repo_setup/setup_private_repos.py pytest {posargs} --cov-report term-missing --cov-report html --cov-report xml --cov=braket extras = test