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.
Files changed (257) hide show
  1. edsl/__init__.py +124 -53
  2. edsl/__version__.py +1 -1
  3. edsl/agents/agent.py +21 -21
  4. edsl/agents/agent_list.py +2 -5
  5. edsl/agents/exceptions.py +119 -5
  6. edsl/base/__init__.py +10 -35
  7. edsl/base/base_class.py +71 -36
  8. edsl/base/base_exception.py +204 -0
  9. edsl/base/data_transfer_models.py +1 -1
  10. edsl/base/exceptions.py +94 -0
  11. edsl/buckets/__init__.py +15 -1
  12. edsl/buckets/bucket_collection.py +3 -4
  13. edsl/buckets/exceptions.py +107 -0
  14. edsl/buckets/model_buckets.py +1 -2
  15. edsl/buckets/token_bucket.py +11 -6
  16. edsl/buckets/token_bucket_api.py +27 -12
  17. edsl/buckets/token_bucket_client.py +9 -7
  18. edsl/caching/cache.py +12 -4
  19. edsl/caching/cache_entry.py +10 -9
  20. edsl/caching/exceptions.py +113 -7
  21. edsl/caching/remote_cache_sync.py +6 -7
  22. edsl/caching/sql_dict.py +20 -14
  23. edsl/cli.py +43 -0
  24. edsl/config/__init__.py +1 -1
  25. edsl/config/config_class.py +32 -6
  26. edsl/conversation/Conversation.py +8 -4
  27. edsl/conversation/car_buying.py +1 -3
  28. edsl/conversation/exceptions.py +58 -0
  29. edsl/conversation/mug_negotiation.py +2 -8
  30. edsl/coop/__init__.py +28 -6
  31. edsl/coop/coop.py +120 -29
  32. edsl/coop/coop_functions.py +1 -1
  33. edsl/coop/ep_key_handling.py +1 -1
  34. edsl/coop/exceptions.py +188 -9
  35. edsl/coop/price_fetcher.py +5 -8
  36. edsl/coop/utils.py +4 -6
  37. edsl/dataset/__init__.py +5 -4
  38. edsl/dataset/dataset.py +177 -86
  39. edsl/dataset/dataset_operations_mixin.py +98 -76
  40. edsl/dataset/dataset_tree.py +11 -7
  41. edsl/dataset/display/table_display.py +0 -2
  42. edsl/dataset/display/table_renderers.py +6 -4
  43. edsl/dataset/exceptions.py +125 -0
  44. edsl/dataset/file_exports.py +18 -11
  45. edsl/dataset/r/ggplot.py +13 -6
  46. edsl/display/__init__.py +27 -0
  47. edsl/display/core.py +147 -0
  48. edsl/display/plugin.py +189 -0
  49. edsl/display/utils.py +52 -0
  50. edsl/inference_services/__init__.py +9 -1
  51. edsl/inference_services/available_model_cache_handler.py +1 -1
  52. edsl/inference_services/available_model_fetcher.py +5 -6
  53. edsl/inference_services/data_structures.py +10 -7
  54. edsl/inference_services/exceptions.py +132 -1
  55. edsl/inference_services/inference_service_abc.py +2 -2
  56. edsl/inference_services/inference_services_collection.py +2 -6
  57. edsl/inference_services/registry.py +4 -3
  58. edsl/inference_services/service_availability.py +4 -3
  59. edsl/inference_services/services/anthropic_service.py +4 -1
  60. edsl/inference_services/services/aws_bedrock.py +13 -12
  61. edsl/inference_services/services/azure_ai.py +12 -10
  62. edsl/inference_services/services/deep_infra_service.py +1 -4
  63. edsl/inference_services/services/deep_seek_service.py +1 -5
  64. edsl/inference_services/services/google_service.py +7 -3
  65. edsl/inference_services/services/groq_service.py +1 -1
  66. edsl/inference_services/services/mistral_ai_service.py +4 -2
  67. edsl/inference_services/services/ollama_service.py +1 -1
  68. edsl/inference_services/services/open_ai_service.py +7 -5
  69. edsl/inference_services/services/perplexity_service.py +6 -2
  70. edsl/inference_services/services/test_service.py +8 -7
  71. edsl/inference_services/services/together_ai_service.py +2 -3
  72. edsl/inference_services/services/xai_service.py +1 -1
  73. edsl/instructions/__init__.py +1 -1
  74. edsl/instructions/change_instruction.py +7 -5
  75. edsl/instructions/exceptions.py +61 -0
  76. edsl/instructions/instruction.py +6 -2
  77. edsl/instructions/instruction_collection.py +6 -4
  78. edsl/instructions/instruction_handler.py +12 -15
  79. edsl/interviews/ReportErrors.py +0 -3
  80. edsl/interviews/__init__.py +9 -2
  81. edsl/interviews/answering_function.py +11 -13
  82. edsl/interviews/exception_tracking.py +15 -8
  83. edsl/interviews/exceptions.py +79 -0
  84. edsl/interviews/interview.py +33 -30
  85. edsl/interviews/interview_status_dictionary.py +4 -2
  86. edsl/interviews/interview_status_log.py +2 -1
  87. edsl/interviews/interview_task_manager.py +5 -5
  88. edsl/interviews/request_token_estimator.py +5 -2
  89. edsl/interviews/statistics.py +3 -4
  90. edsl/invigilators/__init__.py +7 -1
  91. edsl/invigilators/exceptions.py +79 -0
  92. edsl/invigilators/invigilator_base.py +0 -1
  93. edsl/invigilators/invigilators.py +9 -13
  94. edsl/invigilators/prompt_constructor.py +1 -5
  95. edsl/invigilators/prompt_helpers.py +8 -4
  96. edsl/invigilators/question_instructions_prompt_builder.py +1 -1
  97. edsl/invigilators/question_option_processor.py +9 -5
  98. edsl/invigilators/question_template_replacements_builder.py +3 -2
  99. edsl/jobs/__init__.py +42 -5
  100. edsl/jobs/async_interview_runner.py +25 -23
  101. edsl/jobs/check_survey_scenario_compatibility.py +11 -10
  102. edsl/jobs/data_structures.py +8 -5
  103. edsl/jobs/exceptions.py +177 -8
  104. edsl/jobs/fetch_invigilator.py +1 -1
  105. edsl/jobs/jobs.py +74 -69
  106. edsl/jobs/jobs_checks.py +6 -7
  107. edsl/jobs/jobs_component_constructor.py +4 -4
  108. edsl/jobs/jobs_pricing_estimation.py +4 -3
  109. edsl/jobs/jobs_remote_inference_logger.py +5 -4
  110. edsl/jobs/jobs_runner_asyncio.py +3 -4
  111. edsl/jobs/jobs_runner_status.py +8 -9
  112. edsl/jobs/remote_inference.py +27 -24
  113. edsl/jobs/results_exceptions_handler.py +10 -7
  114. edsl/key_management/__init__.py +3 -1
  115. edsl/key_management/exceptions.py +62 -0
  116. edsl/key_management/key_lookup.py +1 -1
  117. edsl/key_management/key_lookup_builder.py +37 -14
  118. edsl/key_management/key_lookup_collection.py +2 -0
  119. edsl/language_models/__init__.py +1 -1
  120. edsl/language_models/exceptions.py +302 -14
  121. edsl/language_models/language_model.py +9 -8
  122. edsl/language_models/model.py +4 -4
  123. edsl/language_models/model_list.py +1 -1
  124. edsl/language_models/price_manager.py +1 -1
  125. edsl/language_models/raw_response_handler.py +14 -9
  126. edsl/language_models/registry.py +17 -21
  127. edsl/language_models/repair.py +0 -6
  128. edsl/language_models/unused/fake_openai_service.py +0 -1
  129. edsl/load_plugins.py +69 -0
  130. edsl/logger.py +146 -0
  131. edsl/notebooks/__init__.py +24 -1
  132. edsl/notebooks/exceptions.py +82 -0
  133. edsl/notebooks/notebook.py +7 -3
  134. edsl/notebooks/notebook_to_latex.py +1 -2
  135. edsl/plugins/__init__.py +63 -0
  136. edsl/plugins/built_in/export_example.py +50 -0
  137. edsl/plugins/built_in/pig_latin.py +67 -0
  138. edsl/plugins/cli.py +372 -0
  139. edsl/plugins/cli_typer.py +283 -0
  140. edsl/plugins/exceptions.py +31 -0
  141. edsl/plugins/hookspec.py +51 -0
  142. edsl/plugins/plugin_host.py +128 -0
  143. edsl/plugins/plugin_manager.py +633 -0
  144. edsl/plugins/plugins_registry.py +168 -0
  145. edsl/prompts/__init__.py +24 -1
  146. edsl/prompts/exceptions.py +107 -5
  147. edsl/prompts/prompt.py +15 -7
  148. edsl/questions/HTMLQuestion.py +5 -11
  149. edsl/questions/Quick.py +0 -1
  150. edsl/questions/__init__.py +6 -4
  151. edsl/questions/answer_validator_mixin.py +318 -323
  152. edsl/questions/compose_questions.py +3 -3
  153. edsl/questions/descriptors.py +11 -50
  154. edsl/questions/exceptions.py +278 -22
  155. edsl/questions/loop_processor.py +7 -5
  156. edsl/questions/prompt_templates/question_list.jinja +3 -0
  157. edsl/questions/question_base.py +46 -19
  158. edsl/questions/question_base_gen_mixin.py +2 -2
  159. edsl/questions/question_base_prompts_mixin.py +13 -7
  160. edsl/questions/question_budget.py +503 -98
  161. edsl/questions/question_check_box.py +660 -160
  162. edsl/questions/question_dict.py +345 -194
  163. edsl/questions/question_extract.py +401 -61
  164. edsl/questions/question_free_text.py +80 -14
  165. edsl/questions/question_functional.py +119 -9
  166. edsl/questions/{derived/question_likert_five.py → question_likert_five.py} +2 -2
  167. edsl/questions/{derived/question_linear_scale.py → question_linear_scale.py} +3 -4
  168. edsl/questions/question_list.py +275 -28
  169. edsl/questions/question_matrix.py +643 -96
  170. edsl/questions/question_multiple_choice.py +219 -51
  171. edsl/questions/question_numerical.py +361 -32
  172. edsl/questions/question_rank.py +401 -124
  173. edsl/questions/question_registry.py +7 -5
  174. edsl/questions/{derived/question_top_k.py → question_top_k.py} +3 -3
  175. edsl/questions/{derived/question_yes_no.py → question_yes_no.py} +3 -4
  176. edsl/questions/register_questions_meta.py +2 -2
  177. edsl/questions/response_validator_abc.py +13 -15
  178. edsl/questions/response_validator_factory.py +10 -12
  179. edsl/questions/templates/dict/answering_instructions.jinja +1 -0
  180. edsl/questions/templates/rank/question_presentation.jinja +1 -1
  181. edsl/results/__init__.py +1 -1
  182. edsl/results/exceptions.py +141 -7
  183. edsl/results/report.py +1 -2
  184. edsl/results/result.py +11 -9
  185. edsl/results/results.py +480 -321
  186. edsl/results/results_selector.py +8 -4
  187. edsl/scenarios/PdfExtractor.py +2 -2
  188. edsl/scenarios/construct_download_link.py +69 -35
  189. edsl/scenarios/directory_scanner.py +33 -14
  190. edsl/scenarios/document_chunker.py +1 -1
  191. edsl/scenarios/exceptions.py +238 -14
  192. edsl/scenarios/file_methods.py +1 -1
  193. edsl/scenarios/file_store.py +7 -3
  194. edsl/scenarios/handlers/__init__.py +17 -0
  195. edsl/scenarios/handlers/docx_file_store.py +0 -5
  196. edsl/scenarios/handlers/pdf_file_store.py +0 -1
  197. edsl/scenarios/handlers/pptx_file_store.py +0 -5
  198. edsl/scenarios/handlers/py_file_store.py +0 -1
  199. edsl/scenarios/handlers/sql_file_store.py +1 -4
  200. edsl/scenarios/handlers/sqlite_file_store.py +0 -1
  201. edsl/scenarios/handlers/txt_file_store.py +1 -1
  202. edsl/scenarios/scenario.py +1 -3
  203. edsl/scenarios/scenario_list.py +179 -27
  204. edsl/scenarios/scenario_list_pdf_tools.py +1 -0
  205. edsl/scenarios/scenario_selector.py +0 -1
  206. edsl/surveys/__init__.py +3 -4
  207. edsl/surveys/dag/__init__.py +4 -2
  208. edsl/surveys/descriptors.py +1 -1
  209. edsl/surveys/edit_survey.py +1 -0
  210. edsl/surveys/exceptions.py +165 -9
  211. edsl/surveys/memory/__init__.py +5 -3
  212. edsl/surveys/memory/memory_management.py +1 -0
  213. edsl/surveys/memory/memory_plan.py +6 -15
  214. edsl/surveys/rules/__init__.py +5 -3
  215. edsl/surveys/rules/rule.py +1 -2
  216. edsl/surveys/rules/rule_collection.py +1 -1
  217. edsl/surveys/survey.py +12 -24
  218. edsl/surveys/survey_css.py +3 -3
  219. edsl/surveys/survey_export.py +6 -3
  220. edsl/surveys/survey_flow_visualization.py +10 -1
  221. edsl/surveys/survey_simulator.py +2 -1
  222. edsl/tasks/__init__.py +23 -1
  223. edsl/tasks/exceptions.py +72 -0
  224. edsl/tasks/question_task_creator.py +3 -3
  225. edsl/tasks/task_creators.py +1 -3
  226. edsl/tasks/task_history.py +8 -10
  227. edsl/tasks/task_status_log.py +1 -2
  228. edsl/tokens/__init__.py +29 -1
  229. edsl/tokens/exceptions.py +37 -0
  230. edsl/tokens/interview_token_usage.py +3 -2
  231. edsl/tokens/token_usage.py +4 -3
  232. edsl/utilities/__init__.py +21 -1
  233. edsl/utilities/decorators.py +1 -2
  234. edsl/utilities/markdown_to_docx.py +2 -2
  235. edsl/utilities/markdown_to_pdf.py +1 -1
  236. edsl/utilities/repair_functions.py +0 -1
  237. edsl/utilities/restricted_python.py +0 -1
  238. edsl/utilities/template_loader.py +2 -3
  239. edsl/utilities/utilities.py +8 -29
  240. {edsl-0.1.49.dist-info → edsl-0.1.51.dist-info}/METADATA +32 -2
  241. edsl-0.1.51.dist-info/RECORD +365 -0
  242. edsl-0.1.51.dist-info/entry_points.txt +3 -0
  243. edsl/dataset/smart_objects.py +0 -96
  244. edsl/exceptions/BaseException.py +0 -21
  245. edsl/exceptions/__init__.py +0 -54
  246. edsl/exceptions/configuration.py +0 -16
  247. edsl/exceptions/general.py +0 -34
  248. edsl/questions/derived/__init__.py +0 -0
  249. edsl/study/ObjectEntry.py +0 -173
  250. edsl/study/ProofOfWork.py +0 -113
  251. edsl/study/SnapShot.py +0 -80
  252. edsl/study/Study.py +0 -520
  253. edsl/study/__init__.py +0 -6
  254. edsl/utilities/interface.py +0 -135
  255. edsl-0.1.49.dist-info/RECORD +0 -347
  256. {edsl-0.1.49.dist-info → edsl-0.1.51.dist-info}/LICENSE +0 -0
  257. {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
- pass
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
- When a URL doesn't follow the pattern:
32
- - https://expectedparrot.com/content/{uuid}
33
- - https://expectedparrot.com/content/{username}/{alias}
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
- pass
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
- When calling get() without providing a UUID or URL
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
- pass
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
- When the server returns a 401 Unauthorized response due to an invalid API key
236
+ ```python
237
+ coop = Coop()
238
+ coop.login(timeout=1) # Raises CoopTimeoutError if login takes longer than 1 second
239
+ ```
61
240
  """
62
- pass
241
+ relevant_doc = "https://docs.expectedparrot.com/en/latest/using_coop.html"
@@ -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 csv
11
- from io import StringIO
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"] = f"Bearer None"
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 as e:
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
- raise ValueError(f"Object type not found for {edsl_object=}")
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
- raise ValueError(f"EDSL class not found for {object_type=}")
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
- from .dataset_operations_mixin import AgentListOperationsMixin
4
- from .dataset_operations_mixin import ScenarioListOperationsMixin
5
- from .dataset_operations_mixin import DatasetOperationsMixin
6
- from .dataset_operations_mixin import ResultsOperationsMixin
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",