Function
class qiskit_serverless.core.function.RunnableQiskitFunction
A Quantum Function loaded with FunctionsCatalog.load(). Its class is RunnableQiskitFunction. You don't create it directly.
Methods
get_default_size
get_default_size()
Returns the size label used when a run doesn't pass function_size.
print(qesem_function.get_default_size())Output:
NoneReturn type
str | None – None if the function doesn't declare a default.
jobs
jobs(**kwargs)
Lists the jobs created with this function. Replaces the deprecated get_jobs().
for job in qesem_function.jobs():
print(job.job_id, job.status())Output:
f6c29f49-4d5f-4fff-aca6-2e9a115b9763 DONE
7f08c9d5-471b-4da2-92e7-4f2cb94c23a8 ERRORReturn type
list[Job]
run
run(**kwargs)
Starts a job and returns immediately.
job = qesem_function.run(
pubs=[(circuit, observable)],
backend_name="ibm_fez",
)
print(job.job_id)Output:
f6c29f49-4d5f-4fff-aca6-2e9a115b9763Parameters
- **kwargs – The function's inputs. See the function's API reference.
- function_size (str | None) – Size label, if the function declares sizes. Reserved keyword.
- config (Configuration | None) – Job configuration. Reserved keyword.
Return type
Raises
QiskitServerlessException – If the arguments are invalid.
sizes
sizes()
Returns the size labels the function declares.
print(qesem_function.sizes())Output:
{}Return type
dict[str, str] – Empty if the function declares no sizes.
validate_arguments
validate_arguments(arguments)
Checks arguments against the function's schema without creating a job.
qesem_function.validate_arguments(
{"pubs": [(circuit, observable)], "backend_name": "ibm_fez"}
)Output:
{'valid': True}Parameters
- arguments (dict) – The arguments to check.
Return type
dict – {"valid": True} if the arguments are valid.
Raises
QiskitServerlessException – If the arguments are invalid.