Sessions
Create a session
Create a session
Berechtigung
Um diese Methode aufrufen zu können, muss Ihnen mindestens eine IAM-Zugriffsrolle zugewiesen sein, die die folgenden Aktionen einschließt. Sie können Ihren Zugriff prüfen durch Aufrufen von Users > User > Access
quantum-computing.session.create
Protokollierung
Der Aufruf dieser Methode generiert die folgenden Überwachungsereignisse.
quantum-computing.session.create
Eingabe
Name, Typ | Beschreibung |
|---|---|
max_ttl integer | The maximum time (in seconds) for the session to run, subject to plan limits. Standardwert: 28800Mindestwert: 1Maximalwert: 2147483647 |
mode string | Execution mode to run the session in Gültige Werte: batchdedicated |
backend string | Backend name |
backend_name string | Backend name (fallback) |
Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions
curl -X POST \
'https://quantum.cloud.ibm.com/api/v1/sessions' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Service-CRN: YOUR-SERVICE-CRN' \
-H 'IBM-API-Version: 2024-01-01' Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions
import requests
response = requests.request(
"POST",
"https://quantum.cloud.ibm.com/api/v1/sessions",
headers={
"Accept": "application/json",
"IBM-API-Version": "2024-01-01",
"Authorization": "Bearer YOUR-TOKEN",
"Service-CRN": "YOUR-SERVICE-CRN"
},
)
print(response.json())Ausgabe
Statuscode | Beschreibung |
|---|---|
| 200 | Ok |
| 400 | Bad Request |
| 401 | Unauthorized |
| 500 | Internal error |
{
"id": "example",
"backend_name": "example",
"started_at": "example",
"activated_at": "example",
"closed_at": "example",
"last_job_started": "example",
"last_job_completed": "example",
"interactive_ttl": 1,
"max_ttl": 1,
"active_ttl": 1,
"state": "open",
"state_reason": "example",
"accepting_jobs": true,
"mode": "batch",
"timestamps": [
{
"status": "open",
"timestamp": "example"
}
],
"user_id": "example",
"elapsed_time": 2,
"usage": {
"value": 1,
"unit": "resource_units",
"details": [
{
"value": 1,
"unit": "resource_units",
"metric": {
"id": "example",
"value": 1
}
}
]
}
}{
"type": "object",
"description": "Job session",
"properties": {
"id": {
"type": "string",
"description": "Job ID"
},
"backend_name": {
"type": "string",
"description": "Backend name. May not be set when in the \"open\" state.",
"nullable": true
},
"started_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session was started"
},
"activated_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session state was changed to active"
},
"closed_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session was closed"
},
"last_job_started": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the last job in the session started"
},
"last_job_completed": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the last job in the session completed"
},
"interactive_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The maximum time (in seconds) between jobs to keep the session active"
},
"max_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The maximum time (in seconds) for session to run, subject to plan limits"
},
"active_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The remaining time (in seconds) for the session to be in the active state while jobs are running."
},
"state": {
"type": "string",
"enum": [
"open",
"active",
"inactive",
"closed"
],
"description": "The state of the session.\n- open: The session is waiting to run jobs.\n- active: The session has priority to run jobs on the backend and is running jobs or is waiting for more jobs to run.\n- inactive: The session does not have priority and is not running any jobs.\n- closed: The session is not running any jobs and will not accept/run new jobs.\n"
},
"state_reason": {
"type": "string",
"description": "The reason for the state change."
},
"accepting_jobs": {
"type": "boolean",
"description": "If true, the session is actively accepting new jobs to be queued. If false, jobs will be rejected on create and the session will be immediately closed when there are no more jobs to run in the session."
},
"mode": {
"type": "string",
"description": "Execution mode to run the session in",
"enum": [
"batch",
"dedicated"
]
},
"timestamps": {
"type": "array",
"items": {
"type": "object",
"description": "Contains information about the time a specific status transition happened",
"properties": {
"status": {
"type": "string",
"enum": [
"open",
"active",
"inactive",
"closed"
],
"description": "The state of the session.\n- open: The session is waiting to run jobs.\n- active: The session has priority to run jobs on the backend and is running jobs or is waiting for more jobs to run.\n- inactive: The session does not have priority and is not running any jobs.\n- closed: The session is not running any jobs and will not accept/run new jobs.\n"
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session transitioned into the given status"
}
},
"required": [
"status",
"timestamp"
]
}
},
"user_id": {
"type": "string",
"description": "The id of the user who created the session."
},
"elapsed_time": {
"type": "number",
"description": "Usage in seconds. Can be null for ongoing sessions.",
"example": 2
},
"usage": {
"title": "Usage",
"description": "The usage for the session split into billable metrics if there are multiple.",
"type": "object",
"properties": {
"value": {
"type": "number",
"format": "float",
"description": "The amount of usage for this metric, in resource units.",
"minimum": 0
},
"unit": {
"type": "string",
"description": "The unit of the value field.",
"enum": [
"resource_units"
]
},
"details": {
"type": "array",
"description": "A breakdown of the usage by metric.",
"minItems": 1,
"items": {
"title": "UsageDetail",
"description": "A single billable metric contributing to a job's overall usage.",
"type": "object",
"properties": {
"value": {
"type": "number",
"format": "float",
"description": "The amount of usage for this metric, in resource units.",
"minimum": 0
},
"unit": {
"type": "string",
"description": "The unit of the value field.",
"enum": [
"resource_units"
]
},
"metric": {
"title": "UsageDetailMetric",
"description": "Identifies the metric definition from which a usage detail was calculated.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The identifier of the metric definition from which this usage was calculated.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"minLength": 36,
"maxLength": 36
},
"value": {
"type": "number",
"description": "The amount of usage for this metric, in seconds.",
"minimum": 0
}
},
"required": [
"id",
"value"
]
}
},
"required": [
"value",
"unit",
"metric"
]
}
}
},
"required": [
"value",
"unit",
"details"
]
}
},
"required": [
"id",
"backend_name",
"mode"
]
}Get a session
Get a session
Berechtigung
Um diese Methode aufrufen zu können, muss Ihnen mindestens eine IAM-Zugriffsrolle zugewiesen sein, die die folgenden Aktionen einschließt. Sie können Ihren Zugriff prüfen durch Aufrufen von Users > User > Access
quantum-computing.session.read
Protokollierung
Der Aufruf dieser Methode generiert die folgenden Überwachungsereignisse.
quantum-computing.session.read
Eingabe
Name, Typ | Beschreibung |
|---|---|
id Erforderlich string | Job Session ID |
Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}
curl -X GET \
'https://quantum.cloud.ibm.com/api/v1/sessions/{id}' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Service-CRN: YOUR-SERVICE-CRN' \
-H 'IBM-API-Version: 2024-01-01' Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}
import requests
response = requests.request(
"GET",
"https://quantum.cloud.ibm.com/api/v1/sessions/{id}",
headers={
"Accept": "application/json",
"IBM-API-Version": "2024-01-01",
"Authorization": "Bearer YOUR-TOKEN",
"Service-CRN": "YOUR-SERVICE-CRN"
},
)
print(response.json())Ausgabe
Statuscode | Beschreibung |
|---|---|
| 200 | OK |
| 401 | Unauthorized |
| 404 | Not Found |
| 500 | Internal error |
{
"id": "example",
"backend_name": "example",
"started_at": "example",
"activated_at": "example",
"closed_at": "example",
"last_job_started": "example",
"last_job_completed": "example",
"interactive_ttl": 1,
"max_ttl": 1,
"active_ttl": 1,
"state": "open",
"state_reason": "example",
"accepting_jobs": true,
"mode": "batch",
"timestamps": [
{
"status": "open",
"timestamp": "example"
}
],
"user_id": "example",
"elapsed_time": 2,
"usage": {
"value": 1,
"unit": "resource_units",
"details": [
{
"value": 1,
"unit": "resource_units",
"metric": {
"id": "example",
"value": 1
}
}
]
}
}{
"type": "object",
"description": "Job session",
"properties": {
"id": {
"type": "string",
"description": "Job ID"
},
"backend_name": {
"type": "string",
"description": "Backend name. May not be set when in the \"open\" state.",
"nullable": true
},
"started_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session was started"
},
"activated_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session state was changed to active"
},
"closed_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session was closed"
},
"last_job_started": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the last job in the session started"
},
"last_job_completed": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the last job in the session completed"
},
"interactive_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The maximum time (in seconds) between jobs to keep the session active"
},
"max_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The maximum time (in seconds) for session to run, subject to plan limits"
},
"active_ttl": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 2147483647,
"description": "The remaining time (in seconds) for the session to be in the active state while jobs are running."
},
"state": {
"type": "string",
"enum": [
"open",
"active",
"inactive",
"closed"
],
"description": "The state of the session.\n- open: The session is waiting to run jobs.\n- active: The session has priority to run jobs on the backend and is running jobs or is waiting for more jobs to run.\n- inactive: The session does not have priority and is not running any jobs.\n- closed: The session is not running any jobs and will not accept/run new jobs.\n"
},
"state_reason": {
"type": "string",
"description": "The reason for the state change."
},
"accepting_jobs": {
"type": "boolean",
"description": "If true, the session is actively accepting new jobs to be queued. If false, jobs will be rejected on create and the session will be immediately closed when there are no more jobs to run in the session."
},
"mode": {
"type": "string",
"description": "Execution mode to run the session in",
"enum": [
"batch",
"dedicated"
]
},
"timestamps": {
"type": "array",
"items": {
"type": "object",
"description": "Contains information about the time a specific status transition happened",
"properties": {
"status": {
"type": "string",
"enum": [
"open",
"active",
"inactive",
"closed"
],
"description": "The state of the session.\n- open: The session is waiting to run jobs.\n- active: The session has priority to run jobs on the backend and is running jobs or is waiting for more jobs to run.\n- inactive: The session does not have priority and is not running any jobs.\n- closed: The session is not running any jobs and will not accept/run new jobs.\n"
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp of when the session transitioned into the given status"
}
},
"required": [
"status",
"timestamp"
]
}
},
"user_id": {
"type": "string",
"description": "The id of the user who created the session."
},
"elapsed_time": {
"type": "number",
"description": "Usage in seconds. Can be null for ongoing sessions.",
"example": 2
},
"usage": {
"title": "Usage",
"description": "The usage for the session split into billable metrics if there are multiple.",
"type": "object",
"properties": {
"value": {
"type": "number",
"format": "float",
"description": "The amount of usage for this metric, in resource units.",
"minimum": 0
},
"unit": {
"type": "string",
"description": "The unit of the value field.",
"enum": [
"resource_units"
]
},
"details": {
"type": "array",
"description": "A breakdown of the usage by metric.",
"minItems": 1,
"items": {
"title": "UsageDetail",
"description": "A single billable metric contributing to a job's overall usage.",
"type": "object",
"properties": {
"value": {
"type": "number",
"format": "float",
"description": "The amount of usage for this metric, in resource units.",
"minimum": 0
},
"unit": {
"type": "string",
"description": "The unit of the value field.",
"enum": [
"resource_units"
]
},
"metric": {
"title": "UsageDetailMetric",
"description": "Identifies the metric definition from which a usage detail was calculated.",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The identifier of the metric definition from which this usage was calculated.",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
"minLength": 36,
"maxLength": 36
},
"value": {
"type": "number",
"description": "The amount of usage for this metric, in seconds.",
"minimum": 0
}
},
"required": [
"id",
"value"
]
}
},
"required": [
"value",
"unit",
"metric"
]
}
}
},
"required": [
"value",
"unit",
"details"
]
}
},
"required": [
"id",
"backend_name",
"mode"
]
}Update a session
Update a session
Berechtigung
Um diese Methode aufrufen zu können, muss Ihnen mindestens eine IAM-Zugriffsrolle zugewiesen sein, die die folgenden Aktionen einschließt. Sie können Ihren Zugriff prüfen durch Aufrufen von Users > User > Access
quantum-computing.session.update
Protokollierung
Der Aufruf dieser Methode generiert die folgenden Überwachungsereignisse.
quantum-computing.session.update
Eingabe
Name, Typ | Beschreibung |
|---|---|
id Erforderlich string | Job Session ID |
Name, Typ | Beschreibung |
|---|---|
accepting_jobs Erforderlich boolean | If true, the session is actively accepting new jobs to be queued. If false, jobs will be rejected on create and the session will be immediately closed when there are no more jobs to run in the session. |
Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}
curl -X PATCH \
'https://quantum.cloud.ibm.com/api/v1/sessions/{id}' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Service-CRN: YOUR-SERVICE-CRN' \
-H 'IBM-API-Version: 2024-01-01' \
-H 'Content-Type: application/json' \
-d '{"accepting_jobs":true}' Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}
import requests
response = requests.request(
"PATCH",
"https://quantum.cloud.ibm.com/api/v1/sessions/{id}",
headers={
"Accept": "application/json",
"IBM-API-Version": "2024-01-01",
"Authorization": "Bearer YOUR-TOKEN",
"Service-CRN": "YOUR-SERVICE-CRN",
"Content-Type": "application/json"
},
data="{\"accepting_jobs\":true}"
)
print(response.json())Ausgabe
Statuscode | Beschreibung |
|---|---|
| 204 | Successfully updated session |
| 401 | Unauthorized |
| 404 | Not Found |
| 500 | Internal error |
Close job session
Closes the runtime session. The session stops accepting new jobs and queued jobs will not run.
Existing running jobs will run to completion. This is analogous to the cancel() function in Qiskit.
Berechtigung
Um diese Methode aufrufen zu können, muss Ihnen mindestens eine IAM-Zugriffsrolle zugewiesen sein, die die folgenden Aktionen einschließt. Sie können Ihren Zugriff prüfen durch Aufrufen von Users > User > Access
quantum-computing.session.update
Protokollierung
Der Aufruf dieser Methode generiert die folgenden Überwachungsereignisse.
quantum-computing.session.update
Eingabe
Name, Typ | Beschreibung |
|---|---|
id Erforderlich string | Session Id |
Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}/close
curl -X DELETE \
'https://quantum.cloud.ibm.com/api/v1/sessions/{id}/close' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR-TOKEN' \
-H 'Service-CRN: YOUR-SERVICE-CRN' \
-H 'IBM-API-Version: 2024-01-01' Wenn sich Ihre Instanz in der Region „eu-de“ befindet, verwenden Sie stattdessen diesen Link: URL: https://eu-de.quantum.cloud.ibm.com/api/v1/sessions/{id}/close
import requests
response = requests.request(
"DELETE",
"https://quantum.cloud.ibm.com/api/v1/sessions/{id}/close",
headers={
"Accept": "application/json",
"IBM-API-Version": "2024-01-01",
"Authorization": "Bearer YOUR-TOKEN",
"Service-CRN": "YOUR-SERVICE-CRN"
},
)
print(response.json())Ausgabe
Statuscode | Beschreibung |
|---|---|
| 204 | Successfully closed runtime session |