edsl 0.1.49__py3-none-any.whl → 0.1.51__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edsl/__init__.py +124 -53
- edsl/__version__.py +1 -1
- edsl/agents/agent.py +21 -21
- edsl/agents/agent_list.py +2 -5
- edsl/agents/exceptions.py +119 -5
- edsl/base/__init__.py +10 -35
- edsl/base/base_class.py +71 -36
- edsl/base/base_exception.py +204 -0
- edsl/base/data_transfer_models.py +1 -1
- edsl/base/exceptions.py +94 -0
- edsl/buckets/__init__.py +15 -1
- edsl/buckets/bucket_collection.py +3 -4
- edsl/buckets/exceptions.py +107 -0
- edsl/buckets/model_buckets.py +1 -2
- edsl/buckets/token_bucket.py +11 -6
- edsl/buckets/token_bucket_api.py +27 -12
- edsl/buckets/token_bucket_client.py +9 -7
- edsl/caching/cache.py +12 -4
- edsl/caching/cache_entry.py +10 -9
- edsl/caching/exceptions.py +113 -7
- edsl/caching/remote_cache_sync.py +6 -7
- edsl/caching/sql_dict.py +20 -14
- edsl/cli.py +43 -0
- edsl/config/__init__.py +1 -1
- edsl/config/config_class.py +32 -6
- edsl/conversation/Conversation.py +8 -4
- edsl/conversation/car_buying.py +1 -3
- edsl/conversation/exceptions.py +58 -0
- edsl/conversation/mug_negotiation.py +2 -8
- edsl/coop/__init__.py +28 -6
- edsl/coop/coop.py +120 -29
- edsl/coop/coop_functions.py +1 -1
- edsl/coop/ep_key_handling.py +1 -1
- edsl/coop/exceptions.py +188 -9
- edsl/coop/price_fetcher.py +5 -8
- edsl/coop/utils.py +4 -6
- edsl/dataset/__init__.py +5 -4
- edsl/dataset/dataset.py +177 -86
- edsl/dataset/dataset_operations_mixin.py +98 -76
- edsl/dataset/dataset_tree.py +11 -7
- edsl/dataset/display/table_display.py +0 -2
- edsl/dataset/display/table_renderers.py +6 -4
- edsl/dataset/exceptions.py +125 -0
- edsl/dataset/file_exports.py +18 -11
- edsl/dataset/r/ggplot.py +13 -6
- edsl/display/__init__.py +27 -0
- edsl/display/core.py +147 -0
- edsl/display/plugin.py +189 -0
- edsl/display/utils.py +52 -0
- edsl/inference_services/__init__.py +9 -1
- edsl/inference_services/available_model_cache_handler.py +1 -1
- edsl/inference_services/available_model_fetcher.py +5 -6
- edsl/inference_services/data_structures.py +10 -7
- edsl/inference_services/exceptions.py +132 -1
- edsl/inference_services/inference_service_abc.py +2 -2
- edsl/inference_services/inference_services_collection.py +2 -6
- edsl/inference_services/registry.py +4 -3
- edsl/inference_services/service_availability.py +4 -3
- edsl/inference_services/services/anthropic_service.py +4 -1
- edsl/inference_services/services/aws_bedrock.py +13 -12
- edsl/inference_services/services/azure_ai.py +12 -10
- edsl/inference_services/services/deep_infra_service.py +1 -4
- edsl/inference_services/services/deep_seek_service.py +1 -5
- edsl/inference_services/services/google_service.py +7 -3
- edsl/inference_services/services/groq_service.py +1 -1
- edsl/inference_services/services/mistral_ai_service.py +4 -2
- edsl/inference_services/services/ollama_service.py +1 -1
- edsl/inference_services/services/open_ai_service.py +7 -5
- edsl/inference_services/services/perplexity_service.py +6 -2
- edsl/inference_services/services/test_service.py +8 -7
- edsl/inference_services/services/together_ai_service.py +2 -3
- edsl/inference_services/services/xai_service.py +1 -1
- edsl/instructions/__init__.py +1 -1
- edsl/instructions/change_instruction.py +7 -5
- edsl/instructions/exceptions.py +61 -0
- edsl/instructions/instruction.py +6 -2
- edsl/instructions/instruction_collection.py +6 -4
- edsl/instructions/instruction_handler.py +12 -15
- edsl/interviews/ReportErrors.py +0 -3
- edsl/interviews/__init__.py +9 -2
- edsl/interviews/answering_function.py +11 -13
- edsl/interviews/exception_tracking.py +15 -8
- edsl/interviews/exceptions.py +79 -0
- edsl/interviews/interview.py +33 -30
- edsl/interviews/interview_status_dictionary.py +4 -2
- edsl/interviews/interview_status_log.py +2 -1
- edsl/interviews/interview_task_manager.py +5 -5
- edsl/interviews/request_token_estimator.py +5 -2
- edsl/interviews/statistics.py +3 -4
- edsl/invigilators/__init__.py +7 -1
- edsl/invigilators/exceptions.py +79 -0
- edsl/invigilators/invigilator_base.py +0 -1
- edsl/invigilators/invigilators.py +9 -13
- edsl/invigilators/prompt_constructor.py +1 -5
- edsl/invigilators/prompt_helpers.py +8 -4
- edsl/invigilators/question_instructions_prompt_builder.py +1 -1
- edsl/invigilators/question_option_processor.py +9 -5
- edsl/invigilators/question_template_replacements_builder.py +3 -2
- edsl/jobs/__init__.py +42 -5
- edsl/jobs/async_interview_runner.py +25 -23
- edsl/jobs/check_survey_scenario_compatibility.py +11 -10
- edsl/jobs/data_structures.py +8 -5
- edsl/jobs/exceptions.py +177 -8
- edsl/jobs/fetch_invigilator.py +1 -1
- edsl/jobs/jobs.py +74 -69
- edsl/jobs/jobs_checks.py +6 -7
- edsl/jobs/jobs_component_constructor.py +4 -4
- edsl/jobs/jobs_pricing_estimation.py +4 -3
- edsl/jobs/jobs_remote_inference_logger.py +5 -4
- edsl/jobs/jobs_runner_asyncio.py +3 -4
- edsl/jobs/jobs_runner_status.py +8 -9
- edsl/jobs/remote_inference.py +27 -24
- edsl/jobs/results_exceptions_handler.py +10 -7
- edsl/key_management/__init__.py +3 -1
- edsl/key_management/exceptions.py +62 -0
- edsl/key_management/key_lookup.py +1 -1
- edsl/key_management/key_lookup_builder.py +37 -14
- edsl/key_management/key_lookup_collection.py +2 -0
- edsl/language_models/__init__.py +1 -1
- edsl/language_models/exceptions.py +302 -14
- edsl/language_models/language_model.py +9 -8
- edsl/language_models/model.py +4 -4
- edsl/language_models/model_list.py +1 -1
- edsl/language_models/price_manager.py +1 -1
- edsl/language_models/raw_response_handler.py +14 -9
- edsl/language_models/registry.py +17 -21
- edsl/language_models/repair.py +0 -6
- edsl/language_models/unused/fake_openai_service.py +0 -1
- edsl/load_plugins.py +69 -0
- edsl/logger.py +146 -0
- edsl/notebooks/__init__.py +24 -1
- edsl/notebooks/exceptions.py +82 -0
- edsl/notebooks/notebook.py +7 -3
- edsl/notebooks/notebook_to_latex.py +1 -2
- edsl/plugins/__init__.py +63 -0
- edsl/plugins/built_in/export_example.py +50 -0
- edsl/plugins/built_in/pig_latin.py +67 -0
- edsl/plugins/cli.py +372 -0
- edsl/plugins/cli_typer.py +283 -0
- edsl/plugins/exceptions.py +31 -0
- edsl/plugins/hookspec.py +51 -0
- edsl/plugins/plugin_host.py +128 -0
- edsl/plugins/plugin_manager.py +633 -0
- edsl/plugins/plugins_registry.py +168 -0
- edsl/prompts/__init__.py +24 -1
- edsl/prompts/exceptions.py +107 -5
- edsl/prompts/prompt.py +15 -7
- edsl/questions/HTMLQuestion.py +5 -11
- edsl/questions/Quick.py +0 -1
- edsl/questions/__init__.py +6 -4
- edsl/questions/answer_validator_mixin.py +318 -323
- edsl/questions/compose_questions.py +3 -3
- edsl/questions/descriptors.py +11 -50
- edsl/questions/exceptions.py +278 -22
- edsl/questions/loop_processor.py +7 -5
- edsl/questions/prompt_templates/question_list.jinja +3 -0
- edsl/questions/question_base.py +46 -19
- edsl/questions/question_base_gen_mixin.py +2 -2
- edsl/questions/question_base_prompts_mixin.py +13 -7
- edsl/questions/question_budget.py +503 -98
- edsl/questions/question_check_box.py +660 -160
- edsl/questions/question_dict.py +345 -194
- edsl/questions/question_extract.py +401 -61
- edsl/questions/question_free_text.py +80 -14
- edsl/questions/question_functional.py +119 -9
- edsl/questions/{derived/question_likert_five.py → question_likert_five.py} +2 -2
- edsl/questions/{derived/question_linear_scale.py → question_linear_scale.py} +3 -4
- edsl/questions/question_list.py +275 -28
- edsl/questions/question_matrix.py +643 -96
- edsl/questions/question_multiple_choice.py +219 -51
- edsl/questions/question_numerical.py +361 -32
- edsl/questions/question_rank.py +401 -124
- edsl/questions/question_registry.py +7 -5
- edsl/questions/{derived/question_top_k.py → question_top_k.py} +3 -3
- edsl/questions/{derived/question_yes_no.py → question_yes_no.py} +3 -4
- edsl/questions/register_questions_meta.py +2 -2
- edsl/questions/response_validator_abc.py +13 -15
- edsl/questions/response_validator_factory.py +10 -12
- edsl/questions/templates/dict/answering_instructions.jinja +1 -0
- edsl/questions/templates/rank/question_presentation.jinja +1 -1
- edsl/results/__init__.py +1 -1
- edsl/results/exceptions.py +141 -7
- edsl/results/report.py +1 -2
- edsl/results/result.py +11 -9
- edsl/results/results.py +480 -321
- edsl/results/results_selector.py +8 -4
- edsl/scenarios/PdfExtractor.py +2 -2
- edsl/scenarios/construct_download_link.py +69 -35
- edsl/scenarios/directory_scanner.py +33 -14
- edsl/scenarios/document_chunker.py +1 -1
- edsl/scenarios/exceptions.py +238 -14
- edsl/scenarios/file_methods.py +1 -1
- edsl/scenarios/file_store.py +7 -3
- edsl/scenarios/handlers/__init__.py +17 -0
- edsl/scenarios/handlers/docx_file_store.py +0 -5
- edsl/scenarios/handlers/pdf_file_store.py +0 -1
- edsl/scenarios/handlers/pptx_file_store.py +0 -5
- edsl/scenarios/handlers/py_file_store.py +0 -1
- edsl/scenarios/handlers/sql_file_store.py +1 -4
- edsl/scenarios/handlers/sqlite_file_store.py +0 -1
- edsl/scenarios/handlers/txt_file_store.py +1 -1
- edsl/scenarios/scenario.py +1 -3
- edsl/scenarios/scenario_list.py +179 -27
- edsl/scenarios/scenario_list_pdf_tools.py +1 -0
- edsl/scenarios/scenario_selector.py +0 -1
- edsl/surveys/__init__.py +3 -4
- edsl/surveys/dag/__init__.py +4 -2
- edsl/surveys/descriptors.py +1 -1
- edsl/surveys/edit_survey.py +1 -0
- edsl/surveys/exceptions.py +165 -9
- edsl/surveys/memory/__init__.py +5 -3
- edsl/surveys/memory/memory_management.py +1 -0
- edsl/surveys/memory/memory_plan.py +6 -15
- edsl/surveys/rules/__init__.py +5 -3
- edsl/surveys/rules/rule.py +1 -2
- edsl/surveys/rules/rule_collection.py +1 -1
- edsl/surveys/survey.py +12 -24
- edsl/surveys/survey_css.py +3 -3
- edsl/surveys/survey_export.py +6 -3
- edsl/surveys/survey_flow_visualization.py +10 -1
- edsl/surveys/survey_simulator.py +2 -1
- edsl/tasks/__init__.py +23 -1
- edsl/tasks/exceptions.py +72 -0
- edsl/tasks/question_task_creator.py +3 -3
- edsl/tasks/task_creators.py +1 -3
- edsl/tasks/task_history.py +8 -10
- edsl/tasks/task_status_log.py +1 -2
- edsl/tokens/__init__.py +29 -1
- edsl/tokens/exceptions.py +37 -0
- edsl/tokens/interview_token_usage.py +3 -2
- edsl/tokens/token_usage.py +4 -3
- edsl/utilities/__init__.py +21 -1
- edsl/utilities/decorators.py +1 -2
- edsl/utilities/markdown_to_docx.py +2 -2
- edsl/utilities/markdown_to_pdf.py +1 -1
- edsl/utilities/repair_functions.py +0 -1
- edsl/utilities/restricted_python.py +0 -1
- edsl/utilities/template_loader.py +2 -3
- edsl/utilities/utilities.py +8 -29
- {edsl-0.1.49.dist-info → edsl-0.1.51.dist-info}/METADATA +32 -2
- edsl-0.1.51.dist-info/RECORD +365 -0
- edsl-0.1.51.dist-info/entry_points.txt +3 -0
- edsl/dataset/smart_objects.py +0 -96
- edsl/exceptions/BaseException.py +0 -21
- edsl/exceptions/__init__.py +0 -54
- edsl/exceptions/configuration.py +0 -16
- edsl/exceptions/general.py +0 -34
- edsl/questions/derived/__init__.py +0 -0
- edsl/study/ObjectEntry.py +0 -173
- edsl/study/ProofOfWork.py +0 -113
- edsl/study/SnapShot.py +0 -80
- edsl/study/Study.py +0 -520
- edsl/study/__init__.py +0 -6
- edsl/utilities/interface.py +0 -135
- edsl-0.1.49.dist-info/RECORD +0 -347
- {edsl-0.1.49.dist-info → edsl-0.1.51.dist-info}/LICENSE +0 -0
- {edsl-0.1.49.dist-info → edsl-0.1.51.dist-info}/WHEEL +0 -0
edsl/coop/exceptions.py
CHANGED
@@ -16,8 +16,11 @@ class CoopErrors(BaseException):
|
|
16
16
|
This is the parent class for all exceptions raised by the Coop module.
|
17
17
|
It inherits from EDSL's BaseException to maintain consistency with
|
18
18
|
the library's exception hierarchy.
|
19
|
+
|
20
|
+
When catching errors from Coop operations, you can catch this exception
|
21
|
+
to handle all Coop-related errors in a single exception handler.
|
19
22
|
"""
|
20
|
-
|
23
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
21
24
|
|
22
25
|
|
23
26
|
class CoopInvalidURLError(CoopErrors):
|
@@ -27,12 +30,21 @@ class CoopInvalidURLError(CoopErrors):
|
|
27
30
|
This exception is raised when a URL provided to the Coop client
|
28
31
|
does not match the expected format for object or resource URLs.
|
29
32
|
|
33
|
+
To fix this error:
|
34
|
+
1. Ensure the URL follows the correct pattern:
|
35
|
+
- https://expectedparrot.com/content/{uuid}
|
36
|
+
- https://expectedparrot.com/content/{username}/{alias}
|
37
|
+
2. Check for typos in the domain name or path structure
|
38
|
+
3. Verify that you're using a complete URL rather than just a UUID or path
|
39
|
+
|
30
40
|
Example:
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
```python
|
42
|
+
coop = Coop()
|
43
|
+
coop.get("https://wrongdomain.com/content/123") # Raises CoopInvalidURLError
|
44
|
+
coop.get("https://expectedparrot.com/wrong-path/123") # Raises CoopInvalidURLError
|
45
|
+
```
|
34
46
|
"""
|
35
|
-
|
47
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html#accessing-content"
|
36
48
|
|
37
49
|
|
38
50
|
class CoopNoUUIDError(CoopErrors):
|
@@ -42,10 +54,18 @@ class CoopNoUUIDError(CoopErrors):
|
|
42
54
|
This exception is raised when an operation requires a UUID or other
|
43
55
|
identifier, but none was provided.
|
44
56
|
|
57
|
+
To fix this error:
|
58
|
+
1. Ensure you're providing either a valid UUID or a complete URL to the operation
|
59
|
+
2. If using an alias instead of a UUID, make sure the alias exists and is formatted correctly
|
60
|
+
|
45
61
|
Example:
|
46
|
-
|
62
|
+
```python
|
63
|
+
coop = Coop()
|
64
|
+
coop.get() # Raises CoopNoUUIDError - missing required UUID or URL
|
65
|
+
coop.get("") # Raises CoopNoUUIDError - empty string is not a valid UUID
|
66
|
+
```
|
47
67
|
"""
|
48
|
-
|
68
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html#accessing-content"
|
49
69
|
|
50
70
|
|
51
71
|
class CoopServerResponseError(CoopErrors):
|
@@ -56,7 +76,166 @@ class CoopServerResponseError(CoopErrors):
|
|
56
76
|
response, such as authentication failures, rate limits, or server errors.
|
57
77
|
The exception message typically includes the error details from the server.
|
58
78
|
|
79
|
+
To fix this error:
|
80
|
+
1. Check the exception message for specific error details from the server
|
81
|
+
2. For authentication errors (401), verify your API key is correct and not expired
|
82
|
+
3. For rate limit errors (429), reduce the frequency of your requests
|
83
|
+
4. For server errors (500+), the issue may be temporary - wait and try again
|
84
|
+
5. Check your network connection if you're getting connection timeout errors
|
85
|
+
|
86
|
+
Example:
|
87
|
+
```python
|
88
|
+
coop = Coop(api_key="invalid-key")
|
89
|
+
coop.get("valid-uuid") # Raises CoopServerResponseError with 401 Unauthorized
|
90
|
+
```
|
91
|
+
"""
|
92
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/api_keys.html"
|
93
|
+
|
94
|
+
|
95
|
+
class CoopInvalidMethodError(CoopErrors):
|
96
|
+
"""
|
97
|
+
Exception raised when an invalid method is requested.
|
98
|
+
|
99
|
+
This exception is raised when attempting to use an HTTP method that is not
|
100
|
+
supported by the Coop API client or by a specific endpoint.
|
101
|
+
|
102
|
+
To fix this error:
|
103
|
+
1. Check that you're using a valid HTTP method (GET, POST, PUT, DELETE, PATCH)
|
104
|
+
2. Verify that the endpoint you're accessing supports the method you're using
|
105
|
+
3. Consider using a higher-level method in the Coop class rather than direct HTTP methods
|
106
|
+
|
107
|
+
Example:
|
108
|
+
```python
|
109
|
+
coop = Coop()
|
110
|
+
coop._request("INVALID_METHOD", "/endpoint") # Raises CoopInvalidMethodError
|
111
|
+
```
|
112
|
+
"""
|
113
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
114
|
+
|
115
|
+
|
116
|
+
class CoopResponseError(CoopErrors):
|
117
|
+
"""
|
118
|
+
Exception raised when there's an issue with the server response.
|
119
|
+
|
120
|
+
This exception is raised when the server response cannot be processed or
|
121
|
+
is missing expected data, even though the HTTP status code might be successful.
|
122
|
+
|
123
|
+
To fix this error:
|
124
|
+
1. Check the exception message for details about what data was missing
|
125
|
+
2. Verify that your request contains all required parameters
|
126
|
+
3. Ensure you're using the correct endpoint for your intended operation
|
127
|
+
|
128
|
+
Example:
|
129
|
+
```python
|
130
|
+
coop = Coop()
|
131
|
+
# Assuming an endpoint that returns incomplete data
|
132
|
+
coop.get("some-resource") # Might raise CoopResponseError if response is malformed
|
133
|
+
```
|
134
|
+
"""
|
135
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
136
|
+
|
137
|
+
|
138
|
+
class CoopObjectTypeError(CoopErrors):
|
139
|
+
"""
|
140
|
+
Exception raised when an object has an unexpected type.
|
141
|
+
|
142
|
+
This exception is raised when an object retrieved from the server has a type
|
143
|
+
that doesn't match what was expected, particularly when using typed methods.
|
144
|
+
|
145
|
+
To fix this error:
|
146
|
+
1. Make sure you're using the correct method for the object type you want
|
147
|
+
2. Verify that the UUID or URL points to the expected object type
|
148
|
+
3. Use the generic get() method if you're uncertain about the object type
|
149
|
+
|
150
|
+
Example:
|
151
|
+
```python
|
152
|
+
coop = Coop()
|
153
|
+
# Trying to get a Survey object but the UUID points to a Job
|
154
|
+
coop.get_survey("job-uuid") # Raises CoopObjectTypeError
|
155
|
+
```
|
156
|
+
"""
|
157
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html#accessing-content"
|
158
|
+
|
159
|
+
|
160
|
+
class CoopPatchError(CoopErrors):
|
161
|
+
"""
|
162
|
+
Exception raised when a patch operation cannot be performed.
|
163
|
+
|
164
|
+
This exception is raised when attempting to update an object but not
|
165
|
+
providing any fields to update, or if the patch operation fails.
|
166
|
+
|
167
|
+
To fix this error:
|
168
|
+
1. Ensure you're providing at least one field to update
|
169
|
+
2. Verify that you have permission to update the object
|
170
|
+
3. Check that the object still exists and hasn't been deleted
|
171
|
+
|
172
|
+
Example:
|
173
|
+
```python
|
174
|
+
coop = Coop()
|
175
|
+
coop.patch("object-uuid") # Raises CoopPatchError if no update fields provided
|
176
|
+
```
|
177
|
+
"""
|
178
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html#updating-content"
|
179
|
+
|
180
|
+
|
181
|
+
class CoopValueError(CoopErrors):
|
182
|
+
"""
|
183
|
+
Exception raised when invalid parameters are provided to a Coop operation.
|
184
|
+
|
185
|
+
This exception is raised when required parameters are missing or when
|
186
|
+
parameters have invalid values.
|
187
|
+
|
188
|
+
To fix this error:
|
189
|
+
1. Check that all required parameters are provided
|
190
|
+
2. Verify that parameter values meet the expected format or constraints
|
191
|
+
3. Consult the API documentation for the correct parameter usage
|
192
|
+
|
193
|
+
Example:
|
194
|
+
```python
|
195
|
+
coop = Coop()
|
196
|
+
coop.get_job_results() # Raises CoopValueError if job_uuid is not provided
|
197
|
+
```
|
198
|
+
"""
|
199
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
200
|
+
|
201
|
+
|
202
|
+
class CoopTypeError(CoopErrors):
|
203
|
+
"""
|
204
|
+
Exception raised when a parameter has an incorrect type.
|
205
|
+
|
206
|
+
This exception is raised when a parameter provided to a Coop method
|
207
|
+
has a type that doesn't match what's expected.
|
208
|
+
|
209
|
+
To fix this error:
|
210
|
+
1. Check the expected types of method parameters
|
211
|
+
2. Convert parameters to the correct type before passing them
|
212
|
+
3. Ensure you're using EDSL objects where required
|
213
|
+
|
214
|
+
Example:
|
215
|
+
```python
|
216
|
+
coop = Coop()
|
217
|
+
coop.create("not_an_edsl_object") # Raises CoopTypeError
|
218
|
+
```
|
219
|
+
"""
|
220
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
221
|
+
|
222
|
+
|
223
|
+
class CoopTimeoutError(CoopErrors):
|
224
|
+
"""
|
225
|
+
Exception raised when a Coop operation times out.
|
226
|
+
|
227
|
+
This exception is raised when an operation takes longer than the
|
228
|
+
specified timeout period to complete.
|
229
|
+
|
230
|
+
To fix this error:
|
231
|
+
1. Increase the timeout value for long-running operations
|
232
|
+
2. Check your network connection if timeouts occur frequently
|
233
|
+
3. For login operations, try again or use API key authentication instead
|
234
|
+
|
59
235
|
Example:
|
60
|
-
|
236
|
+
```python
|
237
|
+
coop = Coop()
|
238
|
+
coop.login(timeout=1) # Raises CoopTimeoutError if login takes longer than 1 second
|
239
|
+
```
|
61
240
|
"""
|
62
|
-
|
241
|
+
relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
|
edsl/coop/price_fetcher.py
CHANGED
@@ -7,9 +7,8 @@ that price information is only fetched once and then cached for efficiency.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
import requests
|
10
|
-
import
|
11
|
-
from
|
12
|
-
from typing import Dict, Tuple, Optional, Any
|
10
|
+
import os
|
11
|
+
from typing import Dict, Tuple, Any
|
13
12
|
|
14
13
|
|
15
14
|
class PriceFetcher:
|
@@ -84,8 +83,6 @@ class PriceFetcher:
|
|
84
83
|
if self._cached_prices is not None:
|
85
84
|
return self._cached_prices
|
86
85
|
|
87
|
-
import os
|
88
|
-
import requests
|
89
86
|
from ..config import CONFIG
|
90
87
|
|
91
88
|
try:
|
@@ -96,7 +93,7 @@ class PriceFetcher:
|
|
96
93
|
if api_key:
|
97
94
|
headers["Authorization"] = f"Bearer {api_key}"
|
98
95
|
else:
|
99
|
-
headers["Authorization"] =
|
96
|
+
headers["Authorization"] = "Bearer None"
|
100
97
|
|
101
98
|
response = requests.get(url, headers=headers, timeout=20)
|
102
99
|
response.raise_for_status() # Raise an exception for bad responses
|
@@ -120,7 +117,7 @@ class PriceFetcher:
|
|
120
117
|
self._cached_prices = price_lookup
|
121
118
|
return self._cached_prices
|
122
119
|
|
123
|
-
except requests.RequestException
|
120
|
+
except requests.RequestException:
|
124
121
|
# Silently handle errors and return empty dict
|
125
122
|
# print(f"An error occurred: {e}")
|
126
|
-
return {}
|
123
|
+
return {}
|
edsl/coop/utils.py
CHANGED
@@ -7,7 +7,6 @@ from ..notebooks import Notebook
|
|
7
7
|
from ..results import Results
|
8
8
|
from ..scenarios import Scenario, ScenarioList
|
9
9
|
from ..surveys import Survey
|
10
|
-
from ..study import Study
|
11
10
|
|
12
11
|
from ..language_models import LanguageModel
|
13
12
|
from ..questions import QuestionBase
|
@@ -24,7 +23,6 @@ EDSLObject = Union[
|
|
24
23
|
Scenario,
|
25
24
|
ScenarioList,
|
26
25
|
Survey,
|
27
|
-
Study,
|
28
26
|
]
|
29
27
|
|
30
28
|
ObjectType = Literal[
|
@@ -39,7 +37,6 @@ ObjectType = Literal[
|
|
39
37
|
"scenario",
|
40
38
|
"scenario_list",
|
41
39
|
"survey",
|
42
|
-
"study",
|
43
40
|
]
|
44
41
|
|
45
42
|
|
@@ -90,7 +87,6 @@ class ObjectRegistry:
|
|
90
87
|
{"object_type": "scenario", "edsl_class": Scenario},
|
91
88
|
{"object_type": "scenario_list", "edsl_class": ScenarioList},
|
92
89
|
{"object_type": "survey", "edsl_class": Survey},
|
93
|
-
{"object_type": "study", "edsl_class": Study},
|
94
90
|
]
|
95
91
|
|
96
92
|
# Create mappings for efficient lookups
|
@@ -133,7 +129,8 @@ class ObjectRegistry:
|
|
133
129
|
# Look up the object type
|
134
130
|
object_type = cls.edsl_class_to_object_type.get(edsl_class_name)
|
135
131
|
if object_type is None:
|
136
|
-
|
132
|
+
from .exceptions import CoopValueError
|
133
|
+
raise CoopValueError(f"Object type not found for {edsl_object=}")
|
137
134
|
return object_type
|
138
135
|
|
139
136
|
@classmethod
|
@@ -155,7 +152,8 @@ class ObjectRegistry:
|
|
155
152
|
"""
|
156
153
|
EDSL_class = cls.object_type_to_edsl_class.get(object_type)
|
157
154
|
if EDSL_class is None:
|
158
|
-
|
155
|
+
from .exceptions import CoopValueError
|
156
|
+
raise CoopValueError(f"EDSL class not found for {object_type=}")
|
159
157
|
return EDSL_class
|
160
158
|
|
161
159
|
@classmethod
|
edsl/dataset/__init__.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
from .dataset import Dataset
|
2
2
|
|
3
|
-
|
4
|
-
from .dataset_operations_mixin import
|
5
|
-
from .dataset_operations_mixin import
|
6
|
-
from .dataset_operations_mixin import
|
3
|
+
# These imports are used by other packages in the repo
|
4
|
+
from .dataset_operations_mixin import AgentListOperationsMixin # noqa: F401
|
5
|
+
from .dataset_operations_mixin import ScenarioListOperationsMixin # noqa: F401
|
6
|
+
from .dataset_operations_mixin import DatasetOperationsMixin # noqa: F401
|
7
|
+
from .dataset_operations_mixin import ResultsOperationsMixin # noqa: F401
|
7
8
|
|
8
9
|
__all__ = [
|
9
10
|
"Dataset",
|