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

Disable QElectron on Python >=3.12 #1975

Merged
merged 12 commits into from
Jan 20, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/test_matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"container": "ghcr.io/agnostiqhq/covalent-dev/debian12-py311:latest",
"backend": "dask",
"experimental": false,
"trigger": ["push", "schedule", "workflow_dispatch"]
"trigger": ["push", "schedule", "workflow_dispatch", "pull_request"]
},
{
"name": "Debian 12 / Python 3.11 / Local",
Expand All @@ -37,7 +37,7 @@
"container": "ghcr.io/agnostiqhq/covalent-dev/debian12-py312:latest",
"backend": "dask",
"experimental": false,
"trigger": ["push", "schedule", "workflow_dispatch"]
"trigger": ["push", "schedule", "workflow_dispatch", "pull_request"]
},
{
"name": "Debian 12 / Python 3.12 / Local",
Expand Down
39 changes: 10 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ jobs:
sdk:
- 'covalent/**'
- 'tests/covalent_tests/**'
qelectron:
- 'covalent/executor/quantum_plugins/**'
- 'covalent/executor/qbase.py'
- 'covalent/quantum/**'
- 'tests/qelectron_tests/**'
dispatcher:
- 'covalent_dispatcher/**'
- 'tests/covalent_dispatcher_tests/**'
Expand Down Expand Up @@ -138,7 +133,6 @@ jobs:
echo "NEED_PYTHON=$NEED_PYTHON" >> $GITHUB_ENV
echo "NEED_FRONTEND=$NEED_FRONTEND" >> $GITHUB_ENV
echo "BUILD_AND_RUN_ALL=$BUILD_AND_RUN_ALL" >> $GITHUB_ENV
echo "COVALENT_DISABLE_QELECTRON_TESTS=true" >> $GITHUB_ENV

- name: Set up Python
if: >
Expand All @@ -164,7 +158,6 @@ jobs:
run: |
pip install --no-cache-dir -r ./requirements.txt
pip install --no-cache-dir -r ./tests/requirements.txt
pip install --no-cache-dir -r ./requirements-qelectron.txt

- name: Set up Node
if: env.NEED_FRONTEND || env.BUILD_AND_RUN_ALL
Expand Down Expand Up @@ -237,16 +230,6 @@ jobs:
covalent cluster --info
covalent cluster --logs

- name: Run functional tests and measure coverage
id: functional-tests
if: env.BUILD_AND_RUN_ALL
run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/functional_tests --cov=covalent --cov=covalent_dispatcher --cov-config=.coveragerc

- name: Generate functional test coverage report
id: functional-coverage
if: steps.functional-tests.outcome == 'success'
run: coverage xml -o functional_tests_coverage.xml

- name: Run SDK tests and measure coverage
id: sdk-tests
if: >
Expand All @@ -259,18 +242,6 @@ jobs:
if: steps.sdk-tests.outcome == 'success'
run: coverage xml -o sdk_coverage.xml

- name: Run Qelectron tests and measure coverage
id: qelectron-tests
if: >
(steps.modified-files.outputs.qelectron == 'true'
|| env.BUILD_AND_RUN_ALL) && env.COVALENT_DISABLE_QELECTRON_TESTS != 'true'
run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/qelectron_tests/core_tests --cov=covalent_qelectron --cov-config=.coveragerc

- name: Generate Qelectron coverage report
id: qelectron-coverage
if: steps.qelectron-tests.outcome == 'success' && env.COVALENT_DISABLE_QELECTRON_TESTS != 'true'
run: coverage xml -o qelectron_coverage.xml

- name: Run dispatcher tests and measure coverage
id: dispatcher-tests
if: >
Expand All @@ -283,6 +254,16 @@ jobs:
if: steps.dispatcher-tests.outcome == 'success'
run: coverage xml -o dispatcher_coverage.xml

- name: Run functional tests and measure coverage
id: functional-tests
if: env.BUILD_AND_RUN_ALL
run: PYTHONPATH=$PWD/ pytest -vvs --reruns=5 tests/functional_tests --cov=covalent --cov=covalent_dispatcher --cov-config=.coveragerc

- name: Generate functional test coverage report
id: functional-coverage
if: steps.functional-tests.outcome == 'success'
run: coverage xml -o functional_tests_coverage.xml

- name: Run UI backend tests and measure coverage
id: ui-backend-tests
if: >
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Operations

- Disabled codecov in CI
- Removed qelectron tests from CI
- Updated recommended platform to Python 3.12

### Fixed

Expand Down
7 changes: 6 additions & 1 deletion covalent/quantum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .qcluster import QCluster, Simulator
import sys

if sys.version_info.major == 3 and sys.version_info.minor < 12:
from .qcluster import QCluster, Simulator
else:
raise ImportError("Error: QElectrons are not supported in Python >=3.12")
25 changes: 9 additions & 16 deletions tests/covalent_dispatcher_tests/_cli/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
_rm_pid_file,
cluster,
config,
get_config,
logs,
purge,
restart,
Expand Down Expand Up @@ -187,7 +188,7 @@ def test_graceful_start_when_pid_exists(mocker):

@pytest.mark.parametrize("no_triggers_flag", [True, False])
@pytest.mark.parametrize("triggers_only_flag", [True, False])
def test_graceful_start_when_pid_absent(mocker, no_triggers_flag, triggers_only_flag):
def test_graceful_start_when_pid_absent(monkeypatch, mocker, no_triggers_flag, triggers_only_flag):
"""Test the graceful server start function."""

config_paths = [
Expand All @@ -200,17 +201,16 @@ def test_graceful_start_when_pid_absent(mocker, no_triggers_flag, triggers_only_
def patched_fn(entry):
return entry

tmp_dir = tempfile.TemporaryDirectory()
monkeypatch.setenv("COVALENT_CONFIG_DIR", tmp_dir.name)

read_pid_mock = mocker.patch("covalent_dispatcher._cli.service._read_pid")
pid_exists_mock = mocker.patch("psutil.pid_exists", return_value=False)
rm_pid_file_mock = mocker.patch("covalent_dispatcher._cli.service._rm_pid_file")
next_available_port_mock = mocker.patch(
"covalent_dispatcher._cli.service._next_available_port", return_value=1984
)
popen_mock = mocker.patch("covalent_dispatcher._cli.service.Popen")
get_mock = mocker.patch(
"covalent._shared_files.config.ConfigManager.get", side_effect=patched_fn
)
path_mock = mocker.patch("covalent_dispatcher._cli.service.Path.__init__", return_value=None)
click_echo_mock = mocker.patch("click.echo")
requests_mock = mocker.patch(
"covalent_dispatcher._cli.service.requests.get",
Expand All @@ -233,13 +233,9 @@ def patched_fn(entry):
)
assert res == 1984

path_mock_calls = path_mock.mock_calls
get_mock_calls = get_mock.mock_calls

for each_path in config_paths:
assert (mocker.call(each_path) in get_mock_calls) and (
mocker.call(each_path) in path_mock_calls
)
path = get_config(each_path)
assert os.path.exists(path)

popen_mock.assert_called_once()
assert popen_mock.call_args[0][0] == launch_str
Expand Down Expand Up @@ -595,10 +591,7 @@ def test_logs(exists, mocker):

if not exists:
result = runner.invoke(logs)
assert (
result.output.replace("\n", "")
== f"{UI_LOGFILE} not found. Restart the server to create a new log file."
)
assert result.output.startswith(UI_LOGFILE)
else:
m_open = mock.mock_open(read_data="testing")
with mock.patch("covalent_dispatcher._cli.service.open", m_open):
Expand Down Expand Up @@ -1149,5 +1142,5 @@ def test_graceful_start_permission_exception(mocker):
runner = CliRunner()
runner.invoke(start)

assert graceful_start_mock.called_once()
graceful_start_mock.assert_called_once()
assert click_secho_mock.call_count == 3
10 changes: 5 additions & 5 deletions tests/covalent_tests/cloud_resource_manager/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ def test_get_executor_module(mocker):
test_executor_name = "test_executor"
test_executor_module = "test_executor_module"

mock_import_module = mocker.patch(
"covalent.cloud_resource_manager.core.importlib.import_module",
return_value=test_executor_module,
)

mocker.patch(
"covalent.cloud_resource_manager.core._executor_manager.executor_plugins_map",
return_value={test_executor_name: "test"},
)

mock_import_module = mocker.patch(
"covalent.cloud_resource_manager.core.importlib.import_module",
return_value=test_executor_module,
)

returned_module = get_executor_module(test_executor_name)

assert returned_module == test_executor_module
Expand Down
6 changes: 3 additions & 3 deletions tests/covalent_tests/executor/init_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_executor_manager_generate_plugins_list(mocker):
init_mock = mocker.patch("covalent.executor._ExecutorManager.__init__", return_value=None)

em = _ExecutorManager()
init_mock.called_once_with()
init_mock.assert_called_once_with()

load_executors_mock = mocker.patch("covalent.executor._ExecutorManager._load_executors")

Expand All @@ -62,14 +62,14 @@ def test_executor_manager_generate_plugins_list(mocker):
)

em.generate_plugins_list()
os_path_join_mock.assert_called_once_with("covalent", "executor_plugins")
os_path_join_mock.assert_called_with("covalent", "executor_plugins")
get_config_mock.assert_called_once_with("sdk.executor_dir")

assert load_executors_mock.mock_calls == [
mocker.call("pkg_plugins_path"),
mocker.call("user_plugins_path"),
]
load_installed_plugins_mock.called_once_with()
load_installed_plugins_mock.assert_called_once_with()


def test_get_executor(mocker):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ def test_folder_upload(self, mocker):
"covalent._file_transfer.strategies.s3_strategy.os.path.relpath",
return_value="mock_path",
)
mocker.patch(
"covalent._file_transfer.strategies.s3_strategy.os.path.join", return_value="mock_join"
)

to_folder = Folder("s3://mock-bucket/")
from_folder = Folder("/tmp/")
Expand All @@ -156,5 +153,5 @@ def test_folder_upload(self, mocker):
callable_func = S3(**self.MOCK_STRATEGY_CONFIG).upload(from_folder, to_folder)
callable_func()
boto3_client_mock().upload_file.assert_called_once_with(
"/tmp/mock_join", bucket_name, "mock_join"
"/tmp/mock_path/test.csv", bucket_name, "mock_path/test.csv"
)
15 changes: 0 additions & 15 deletions tests/covalent_tests/quantum/qserver/__init__.py

This file was deleted.

Loading
Loading