Run a job in the background
You can run a remote survey in the background by passing a parameter background=True
to the run()
method. This allows you to continue working (or stop working) while your survey job completes.
You can check the progress of the job by opening the Progress Bar page view, and use the Job UUID to identify the job at your Coop account. If you also passed a remote_inference_description
and/or remote_inference_visibility
setting to the run()
method (as we do below) you can also use those to identify the job at Coop. See the Job UUID and URL that are returned in the job status table (this table is returned when any job is run remotely). Note that the Results UUID and
Results URL are not automatically updated when the job completes:
[1]:
from edsl import QuestionFreeText, Model
m = Model("gemini-1.5-flash")
q = QuestionFreeText(
question_name = "poem",
question_text = "Please write me a heartfelt poem for Valentine's Day."
)
r = q.by(m).run(
background = True, # optional
remote_inference_description = "A poem for Valentine's Day", # optional
remote_inference_results_visibility = "public" # optional
)
Job UUID | de5c9be2-020e-4cb5-a22a-d6d3de72fe7f |
Progress Bar URL | https://www.expectedparrot.com/home/remote-job-progress/de5c9be2-020e-4cb5-a22a-d6d3de72fe7f |
Exceptions Report URL | None |
Results UUID | None |
Results URL | None |
Status updates
You can also check for updates by calling the fetch()
method on the results object that you are generating. By default, this will check for results once every second. You can specify a different polling interval by passing the number of seconds for the interval.
For example, while the job above is running we check for results every 2.0 seconds until they are returned:
[2]:
r.fetch(polling_interval = 2.0)
Waiting for remote job to complete...
Waiting for remote job to complete...
Waiting for remote job to complete...
[2]:
Results observations: 1; agents: 1; models: 1; scenarios: 1; questions: 1; Survey question names: ['poem'];
poem | scenario_index | agent_index | agent_name | agent_instruction | stopSequences | inference_service | model | temperature | maxOutputTokens | topP | topK | model_index | poem_system_prompt | poem_user_prompt | poem_one_usd_buys | poem_raw_model_response | poem_cost | iteration | poem_question_text | poem_question_options | poem_question_type | poem_comment | poem_generated_tokens | poem_cache_used | poem_cache_key | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | The world outside is hushed and cold, But in my heart, a story's told, Of warmth and light, a love so true, A Valentine, my heart gives you. No diamond shines as bright as you, No ruby holds a love so new, Your laughter rings, a joyful sound, On solid ground, my love is bound. Through stormy seas and sunlit days, Your hand in mine, through winding ways, We've built a love, a sturdy thing, A song of joy, our hearts will sing. So let this day, with hearts aflame, Whisper your name, and speak your claim, Upon my soul, my love, my life, My dearest one, my precious wife. (or husband, or darling, or beloved) This Valentine, I hold you near, Dispelling doubt, erasing fear, My love for you, forever grows, | 0 | 0 | Agent_0 | You are answering questions as if you were a human. Do not break character. | [] | gemini-1.5-flash | 0.500000 | 2048 | 1 | 1 | 0 | nan | Please write me a heartfelt poem for Valentine's Day. | 15873.019014 | {'candidates': [{'content': {'parts': [{'text': "The world outside is hushed and cold,\nBut in my heart, a story's told,\nOf warmth and light, a love so true,\nA Valentine, my heart gives you.\n\nNo diamond shines as bright as you,\nNo ruby holds a love so new,\nYour laughter rings, a joyful sound,\nOn solid ground, my love is bound.\n\nThrough stormy seas and sunlit days,\nYour hand in mine, through winding ways,\nWe've built a love, a sturdy thing,\nA song of joy, our hearts will sing.\n\nSo let this day, with hearts aflame,\nWhisper your name, and speak your claim,\nUpon my soul, my love, my life,\nMy dearest one, my precious wife. (or husband, or darling, or beloved)\n\nThis Valentine, I hold you near,\nDispelling doubt, erasing fear,\nMy love for you, forever grows,\nA tender bloom, as everyone knows.\n"}], 'role': 'model'}, 'finish_reason': 1, 'safety_ratings': [{'category': 8, 'probability': 1, 'blocked': False}, {'category': 10, 'probability': 1, 'blocked': False}, {'category': 7, 'probability': 1, 'blocked': False}, {'category': 9, 'probability': 1, 'blocked': False}], 'avg_logprobs': -0.21980475457970072, 'token_count': 0, 'grounding_attributions': []}], 'usage_metadata': {'prompt_token_count': 12, 'candidates_token_count': 207, 'total_token_count': 219, 'cached_content_token_count': 0}, 'model_version': 'gemini-1.5-flash'} | 0.000063 | 0 | Please write me a heartfelt poem for Valentine's Day. | nan | free_text | nan | The world outside is hushed and cold, But in my heart, a story's told, Of warmth and light, a love so true, A Valentine, my heart gives you. No diamond shines as bright as you, No ruby holds a love so new, Your laughter rings, a joyful sound, On solid ground, my love is bound. Through stormy seas and sunlit days, Your hand in mine, through winding ways, We've built a love, a sturdy thing, A song of joy, our hearts will sing. So let this day, with hearts aflame, Whisper your name, and speak your claim, Upon my soul, my love, my life, My dearest one, my precious wife. (or husband, or darling, or beloved) This Valentine, I hold you near, Dispelling doubt, erasing fear, My love for you, forever grows, A tender bloom, as everyone knows. | False | 29877e4e1cd8969e4bd3507f301033f1 |
Now we can select and analyze the results as usual:
[3]:
r.select("model", "answer.*")
[3]:
model.model | answer.poem | |
---|---|---|
0 | gemini-1.5-flash | The world outside is hushed and cold, But in my heart, a story's told, Of warmth and light, a love so true, A Valentine, my heart gives you. No diamond shines as bright as you, No ruby holds a love so new, Your laughter rings, a joyful sound, On solid ground, my love is bound. Through stormy seas and sunlit days, Your hand in mine, through winding ways, We've built a love, a sturdy thing, A song of joy, our hearts will sing. So let this day, with hearts aflame, Whisper your name, and speak your claim, Upon my soul, my love, my life, My dearest one, my precious wife. (or husband, or darling, or beloved) This Valentine, I hold you near, Dispelling doubt, erasing fear, My love for you, forever grows, |
[4]:
from edsl import Notebook
n = Notebook("run_background.ipynb")
n.push(description = "Run a remote survey in the background", visibility = "public")
[4]:
{'description': 'Run a remote survey in the background',
'object_type': 'notebook',
'url': 'https://www.expectedparrot.com/content/fc2b8fc8-d003-494a-9a5c-3c355a7fdc8a',
'uuid': 'fc2b8fc8-d003-494a-9a5c-3c355a7fdc8a',
'version': '0.1.43.dev1',
'visibility': 'public'}
To update an object at Coop:
[4]:
from edsl import Notebook
n = Notebook("run_background.ipynb")
n.patch(uuid = "fc2b8fc8-d003-494a-9a5c-3c355a7fdc8a", value = n)
[4]:
{'status': 'success'}