Skip to content

Commit

Permalink
jobService variable camelCase to snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
korgan00 committed Oct 24, 2024
1 parent 021efb8 commit 018e6d9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion client/qiskit_serverless/core/clients/local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def run(
if results:
result = results.group(1)

job = Job(job_id=str(uuid4()), jobService=self)
job = Job(job_id=str(uuid4()), job_service=self)
self._jobs[job.job_id] = {
"status": status,
"logs": output,
Expand Down
7 changes: 4 additions & 3 deletions client/qiskit_serverless/core/clients/ray_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def jobs(self, **kwargs) -> List[Job]:
list of jobs.
"""
return [
Job(job.job_id, jobService=self)
Job(job.job_id, job_service=self)
for job in self.job_submission_client.list_jobs()
]

Expand All @@ -94,7 +94,8 @@ def job(self, job_id: str) -> Optional[Job]:
Job instance
"""
return Job(
self.job_submission_client.get_job_info(job_id).submission_id, jobService=self
self.job_submission_client.get_job_info(job_id).submission_id,
job_service=self,
)

def run(
Expand Down Expand Up @@ -129,7 +130,7 @@ def run(
"env_vars": env_vars,
},
)
return Job(job_id=job_id, jobService=self)
return Job(job_id=job_id, job_service=self)

def status(self, job_id: str) -> str:
"""Check status."""
Expand Down
6 changes: 3 additions & 3 deletions client/qiskit_serverless/core/clients/serverless_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def jobs(self, **kwargs) -> List[Job]:
)

return [
Job(job.get("id"), jobService=self, raw_data=job)
Job(job.get("id"), job_service=self, raw_data=job)
for job in response_data.get("results", [])
]

Expand All @@ -185,7 +185,7 @@ def job(self, job_id: str) -> Optional[Job]:
if job_id is not None:
job = Job(
job_id=job_id,
jobService=self,
job_service=self,
)

return job
Expand Down Expand Up @@ -232,7 +232,7 @@ def run(
job_id = response_data.get("id")
span.set_attribute("job.id", job_id)

return Job(job_id, jobService=self)
return Job(job_id, job_service=self)

def status(self, job_id: str):
tracer = trace.get_tracer("client.tracer")
Expand Down
12 changes: 6 additions & 6 deletions client/qiskit_serverless/core/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ class RunnableQiskitFunction(QiskitFunction):
version: version of a program
"""

_runService: RunService = None
_run_service: RunService = None

def __init__( # pylint: disable=too-many-positional-arguments
self, client: RunService, **kwargs
):
self._runService = client
self._run_service = client
super().__init__(**kwargs)

@classmethod
Expand All @@ -169,7 +169,7 @@ def run(self, **kwargs):
Returns:
Job: job handler for function execution
"""
if self._runService is None:
if self._run_service is None:
raise ValueError("No clients specified for a function.")

if self.validate:
Expand All @@ -181,7 +181,7 @@ def run(self, **kwargs):
)

config = kwargs.pop("config", None)
return self._runService.run(
return self._run_service.run(
program=self,
arguments=kwargs,
config=config,
Expand Down Expand Up @@ -215,7 +215,7 @@ def jobs(self):
[Job] : list of jobs
"""

if self._runService is None:
if self._run_service is None:
raise ValueError("No clients specified for a function.")

if self.validate:
Expand All @@ -226,7 +226,7 @@ def jobs(self):
f"Function validation failed. Validation errors:\n {error_string}",
)

jobs = self._runService.jobs(
jobs = self._run_service.jobs(
title=self.title,
provider=self.provider,
)
Expand Down
14 changes: 7 additions & 7 deletions client/qiskit_serverless/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Job:
def __init__(
self,
job_id: str,
jobService: JobService,
job_service: JobService,
raw_data: Optional[Dict[str, Any]] = None,
):
"""Job class for async script execution.
Expand All @@ -124,12 +124,12 @@ def __init__(
client: client
"""
self.job_id = job_id
self._jobService = jobService
self._job_service = job_service
self.raw_data = raw_data or {}

def status(self):
"""Returns status of the job."""
return _map_status_to_serverless(self._jobService.status(self.job_id))
return _map_status_to_serverless(self._job_service.status(self.job_id))

def stop(self, service: Optional[QiskitRuntimeService] = None):
"""Stops the job from running."""
Expand All @@ -143,19 +143,19 @@ def stop(self, service: Optional[QiskitRuntimeService] = None):

def cancel(self, service: Optional[QiskitRuntimeService] = None):
"""Cancels the job."""
return self._jobService.stop(self.job_id, service=service)
return self._job_service.stop(self.job_id, service=service)

def logs(self) -> str:
"""Returns logs of the job."""
return self._jobService.logs(self.job_id)
return self._job_service.logs(self.job_id)

def filtered_logs(self, **kwargs) -> str:
"""Returns logs of the job.
Args:
include: rex expression finds match in the log line to be included
exclude: rex expression finds match in the log line to be excluded
"""
return self._jobService.filtered_logs(job_id=self.job_id, **kwargs)
return self._job_service.filtered_logs(job_id=self.job_id, **kwargs)

def result(self, wait=True, cadence=5, verbose=False, maxwait=0):
"""Return results of the job.
Expand All @@ -178,7 +178,7 @@ def result(self, wait=True, cadence=5, verbose=False, maxwait=0):
logging.info(count)

# Retrieve the results. If they're string format, try to decode to a dictionary.
results = self._jobService.result(self.job_id)
results = self._job_service.result(self.job_id)
if isinstance(results, str):
try:
results = json.loads(results, cls=QiskitObjectsDecoder)
Expand Down

0 comments on commit 018e6d9

Please sign in to comment.