Skip to content

Commit

Permalink
Merge pull request #43 from Qiskit/files-integration
Browse files Browse the repository at this point in the history
Apply changes for the files functionality
  • Loading branch information
Tansito authored Feb 4, 2025
2 parents dc8dbed + c79190e commit 8aacdf0
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ authors = []
dependencies = [
"certifi>=2021.5.30",
"importlib_metadata>=4.8.1",
"qiskit_serverless>=0.18.0, <0.19.0",
"qiskit_serverless>=0.19.0, <0.20.0",
]

[project.optional-dependencies]
Expand Down
51 changes: 39 additions & 12 deletions qiskit_ibm_catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,56 @@ def get_job_by_id(self, job_id: str) -> Optional[Job]:
)
return self.job(job_id=job_id)

def files(self, provider: Optional[str] = None) -> List[str]:
"""Returns list of available files produced by programs to download."""
return self._client.files(provider)
def files(self, function: QiskitFunction) -> List[str]:
"""Returns the list of files available for the user in the Qiskit Function folder."""
return self._client.files(function)

def provider_files(self, function: QiskitFunction) -> List[str]:
"""Returns the list of files available for the provider in the Qiskit Function folder."""
return self._client.provider_files(function)

def file_download(
self,
file: str,
function: QiskitFunction,
target_name: Optional[str] = None,
download_location: str = "./",
provider: Optional[str] = None,
):
"""Download file."""
"""Download a file available to the user for the specific Qiskit Function."""
return self._client.file_download(
file, target_name, download_location, provider
file, function, target_name, download_location
)

def provider_file_download(
self,
file: str,
function: QiskitFunction,
target_name: Optional[str] = None,
download_location: str = "./",
):
"""Download a file available to the provider for the specific Qiskit Function."""
return self._client.provider_file_download(
file,
function,
target_name,
download_location,
)

def file_delete(self, file: str, provider: Optional[str] = None):
"""Deletes file uploaded or produced by the programs,"""
return self._client.file_delete(file, provider)
def file_delete(self, file: str, function: QiskitFunction):
"""Deletes a file available to the user for the specific Qiskit Function."""
return self._client.file_delete(file, function)

def provider_file_delete(self, file: str, function: QiskitFunction):
"""Deletes a file available to the provider for the specific Qiskit Function."""
return self._client.provider_file_delete(file, function)

def file_upload(self, file: str, function: QiskitFunction):
"""Uploads a file in the specific user's Qiskit Function folder."""
return self._client.file_upload(file, function)

def file_upload(self, file: str, provider: Optional[str] = None):
"""Upload file."""
return self._client.file_upload(file, provider)
def provider_file_upload(self, file: str, function: QiskitFunction):
"""Uploads a file in the specific provider's Qiskit Function folder."""
return self._client.provider_file_upload(file, function)

def __repr__(self) -> str:
return "<QiskitFunctionsCatalog>"
Expand Down
51 changes: 39 additions & 12 deletions qiskit_ibm_catalog/serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,56 @@ def get_job_by_id(self, job_id: str) -> Optional[Job]:
)
return self.job(job_id=job_id)

def files(self, provider: Optional[str] = None) -> List[str]:
"""Returns list of available files produced by programs to download."""
return self._client.files(provider)
def files(self, function: QiskitFunction) -> List[str]:
"""Returns the list of files available for the user in the Qiskit Function folder."""
return self._client.files(function)

def provider_files(self, function: QiskitFunction) -> List[str]:
"""Returns the list of files available for the provider in the Qiskit Function folder."""
return self._client.provider_files(function)

def file_download(
self,
file: str,
function: QiskitFunction,
target_name: Optional[str] = None,
download_location: str = "./",
provider: Optional[str] = None,
):
"""Download file."""
"""Download a file available to the user for the specific Qiskit Function."""
return self._client.file_download(
file, target_name, download_location, provider
file, function, target_name, download_location
)

def provider_file_download(
self,
file: str,
function: QiskitFunction,
target_name: Optional[str] = None,
download_location: str = "./",
):
"""Download a file available to the provider for the specific Qiskit Function."""
return self._client.provider_file_download(
file,
function,
target_name,
download_location,
)

def file_delete(self, file: str, provider: Optional[str] = None):
"""Deletes file uploaded or produced by the programs,"""
return self._client.file_delete(file, provider)
def file_delete(self, file: str, function: QiskitFunction):
"""Deletes a file available to the user for the specific Qiskit Function."""
return self._client.file_delete(file, function)

def provider_file_delete(self, file: str, function: QiskitFunction):
"""Deletes a file available to the provider for the specific Qiskit Function."""
return self._client.provider_file_delete(file, function)

def file_upload(self, file: str, function: QiskitFunction):
"""Uploads a file in the specific user's Qiskit Function folder."""
return self._client.file_upload(file, function)

def file_upload(self, file: str, provider: Optional[str] = None):
"""Upload file."""
return self._client.file_upload(file, provider)
def provider_file_upload(self, file: str, function: QiskitFunction):
"""Uploads a file in the specific provider's Qiskit Function folder."""
return self._client.provider_file_upload(file, function)

def __repr__(self) -> str:
return "<QiskitServerless>"
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ commands =
; treon docs --threads 2

[testenv:lint]
allowlist_externals =
bash
extras = dev
commands =
black --check .
Expand All @@ -27,6 +29,8 @@ commands =
mypy .

[testenv:black]
allowlist_externals =
black
skip_install = true
commands = black .

Expand All @@ -37,7 +41,7 @@ setenv =
commands =
coverage3 run --source qiskit_ibm_catalog --parallel-mode -m pytest --doctest-modules
coverage3 combine
coverage3 report --fail-under=70
coverage3 report --fail-under=50

[testenv:docs]
skip_install = false
Expand Down

0 comments on commit 8aacdf0

Please sign in to comment.