Skip to content

Commit

Permalink
use localprovider for test
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiko Kuroda <[email protected]>
  • Loading branch information
akihikokuroda committed Feb 6, 2024
1 parent 6518689 commit 0fc8fed
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ jobs:
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Build the containers
run: docker compose -f docker-compose-dev.yaml build
- name: Run the jupyter profile
run: docker compose -f docker-compose-dev.yaml up -d
- name: Give containers time to initialize
shell: bash
run: sleep 90
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: patch notebooks
shell: bash
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/examples/02_qaoa.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/examples/01_vqe.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/migration/migration_from_qiskit_runtime_programs.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/experimental/running_programs_using_decorators.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/experimental/manage_data_directory.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/experimental/file_download.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/02_arguments_and_results.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/04_distributed_workloads.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/05_retrieving_past_results.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/03_dependencies.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/01_running_program.ipynb
run: sed -i "s/import ServerlessProvider/import LocalProvider/;s/= ServerlessProvider(/= LocalProvider(/;/token=os\.environ\.get/d;/host=os\.environ\.get/d" docs/getting_started/basic/.ipynb_checkpoints/01_running_program-checkpoint.ipynb
- name: install dependencies
shell: bash
run: pip install client/ && pip install nbmake pytest
Expand Down
2 changes: 1 addition & 1 deletion client/quantum_serverless/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def run_existing( # pylint: disable=too-many-locals

def get_programs(self, **kwargs):
"""Returns list of programs."""
raise NotImplementedError
return self._patterns


class GatewayJobClient(BaseJobClient):
Expand Down
38 changes: 38 additions & 0 deletions client/quantum_serverless/core/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import logging
import warnings
import os.path
import os
from dataclasses import dataclass
from typing import Optional, List, Dict, Any, Union

Expand Down Expand Up @@ -608,6 +609,7 @@ def __init__(self):
"""
super().__init__("local-provier")
self.client = LocalJobClient()
self.in_test = os.getenv("IN_TEST")

def run(
self,
Expand All @@ -629,3 +631,39 @@ def get_jobs(self, **kwargs) -> List[Job]:

def upload(self, program: QiskitPattern):
return self.client.upload(program)

def widget(self):
"""Widget for information about provider and jobs."""
return Widget(self).show()

def get_programs(self, **kwargs) -> List[QiskitPattern]:
return self.client.get_programs(**kwargs)

def files(self) -> List[str]:
if self.in_test:
logging.warning("files method is not implemented in LocalProvider.")
return []
raise NotImplementedError("files method is not implemented in LocalProvider.")

def file_upload(self, file: str):
if self.in_test:
logging.warning("file_upload method is not implemented in LocalProvider.")
return
raise NotImplementedError("files method is not implemented in LocalProvider.")

def file_download(
self,
file: str,
target_name: Optional[str] = None,
download_location: str = "./",
):
if self.in_test:
logging.warning("file_download method is not implemented in LocalProvider.")
return None
raise NotImplementedError("files method is not implemented in LocalProvider.")

def file_delete(self, file: str):
if self.in_test:
logging.warning("file_delete method is not implemented in LocalProvider.")
return None
raise NotImplementedError("files method is not implemented in LocalProvider.")

0 comments on commit 0fc8fed

Please sign in to comment.