Skip to content

Commit

Permalink
[Quantum] Output job progress messages with Knack logger (#4632)
Browse files Browse the repository at this point in the history
* Output job progress messages with Knack logger

* Update test_version_check

* Update test_version_check again
  • Loading branch information
warren-jones committed Apr 12, 2022
1 parent 42a63b8 commit 0986a8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/quantum/azext_quantum/operations/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pylint: disable=redefined-builtin,bare-except,inconsistent-return-statements

import logging
import knack.log

from azure.cli.core.azclierror import (FileOperationError, AzureInternalError,
InvalidArgumentValueError, AzureResponseError)
Expand All @@ -15,6 +16,7 @@
from .target import TargetInfo

logger = logging.getLogger(__name__)
knack_logger = knack.log.get_logger(__name__)


def list(cmd, resource_group_name=None, workspace_name=None, location=None):
Expand Down Expand Up @@ -70,7 +72,7 @@ def build(cmd, target_id=None, project=None):
logger.debug("Building project with arguments:")
logger.debug(args)

print("Building project...")
knack_logger.warning('Building project...')

import subprocess
result = subprocess.run(args, stdout=subprocess.PIPE, check=False)
Expand Down Expand Up @@ -183,7 +185,7 @@ def submit(cmd, program_args, resource_group_name=None, workspace_name=None, loc
args = _generate_submit_args(program_args, ws, target, token, project, job_name, shots, storage, job_params)
_set_cli_version()

print("Submitting job...")
knack_logger.warning('Submitting job...')

import subprocess
result = subprocess.run(args, stdout=subprocess.PIPE, check=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ def test_version_check(self):

message = check_version(test_config, test_current_reported_version, test_old_date)
assert message is None
# Note: list_versions("quantum") fails during these tests, so latest version number cannot be determined.
# No message is generated if either version number is unavailable.

message = check_version(test_config, test_old_reported_version, test_old_date)
assert message is None
assert message == f"\nVersion {test_old_reported_version} of the quantum extension is installed locally, but version {test_current_reported_version} is now available.\nYou can use 'az extension update -n quantum' to upgrade.\n"

# No message is generated if either version number is unavailable.
message = check_version(test_config, test_none_version, test_today)
assert message is None

Expand Down

0 comments on commit 0986a8c

Please sign in to comment.