edsl 0.1.40__py3-none-any.whl → 0.1.40.dev2__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.
@@ -327,38 +327,6 @@ class FileStore(Scenario):
327
327
 
328
328
  return ConstructDownloadLink(self).create_link(custom_filename, style)
329
329
 
330
- def to_pandas(self):
331
- """
332
- Convert the file content to a pandas DataFrame if supported by the file handler.
333
-
334
- Returns:
335
- pandas.DataFrame: The data from the file as a DataFrame
336
-
337
- Raises:
338
- AttributeError: If the file type's handler doesn't support pandas conversion
339
- """
340
- handler = FileMethods.get_handler(self.suffix)
341
- if handler and hasattr(handler, "to_pandas"):
342
- return handler(self.path).to_pandas()
343
- raise AttributeError(
344
- f"Converting {self.suffix} files to pandas DataFrame is not supported"
345
- )
346
-
347
- def __getattr__(self, name):
348
- """
349
- Delegate pandas DataFrame methods to the underlying DataFrame if this is a CSV file
350
- """
351
- if self.suffix == "csv":
352
- # Get the pandas DataFrame
353
- df = self.to_pandas()
354
- # Check if the requested attribute exists in the DataFrame
355
- if hasattr(df, name):
356
- return getattr(df, name)
357
- # If not a CSV or attribute doesn't exist in DataFrame, raise AttributeError
358
- raise AttributeError(
359
- f"'{self.__class__.__name__}' object has no attribute '{name}'"
360
- )
361
-
362
330
 
363
331
  class CSVFileStore(FileStore):
364
332
  @classmethod
@@ -36,14 +36,3 @@ class CsvMethods(FileMethods):
36
36
  with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as f:
37
37
  df.to_csv(f.name, index=False)
38
38
  return f.name
39
-
40
- def to_pandas(self):
41
- """
42
- Convert the CSV file to a pandas DataFrame.
43
-
44
- Returns:
45
- pandas.DataFrame: The data from the CSV as a DataFrame
46
- """
47
- import pandas as pd
48
-
49
- return pd.read_csv(self.path)
edsl/surveys/Survey.py CHANGED
@@ -391,10 +391,6 @@ class Survey(SurveyExportMixin, Base):
391
391
 
392
392
  if (class_name := pass_dict.get("edsl_class_name")) == "QuestionBase":
393
393
  return QuestionBase
394
- elif pass_dict.get("edsl_class_name") == "QuestionDict":
395
- from edsl.questions.QuestionDict import QuestionDict
396
-
397
- return QuestionDict
398
394
  elif class_name == "Instruction":
399
395
  from edsl.surveys.instructions.Instruction import Instruction
400
396
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edsl
3
- Version: 0.1.40
3
+ Version: 0.1.40.dev2
4
4
  Summary: Create and analyze LLM-based surveys
5
5
  Home-page: https://www.expectedparrot.com/
6
6
  License: MIT
@@ -107,5 +107,5 @@ See instructions on [storing API keys](https://docs.expectedparrot.com/en/latest
107
107
 
108
108
  ## 💡 Contributions, feature requests & bugs
109
109
  Interested in contributing? Want us to add a new feature? Found a bug for us to squash?
110
- Please send us an email at [info@expectedparrot.com](mailto:info@expectedparrot.com) or message us at our [Discord channel](https://discord.com/invite/mxAYkjfy9m).
110
+ Please send us an email at [info@expectedparrot.com](mailto:info@expectedparrot.com) or message us at our [Discord channel](https://discord.com/invite/mxAYkjfy9m)..
111
111
 
@@ -1,11 +1,11 @@
1
1
  edsl/Base.py,sha256=-U6ngLZJDqImrAwF-TSmYzMESre0CG5rq9ZFxFh31sY,12864
2
2
  edsl/BaseDiff.py,sha256=92BirXj2u3TEGHJWni9TBsvZjvq8wpb4wDL2vxX9Lb0,8253
3
3
  edsl/TemplateLoader.py,sha256=sDBlSMt7EfOduM7w3h6v03gvh_Rzn9hVrlS-iLSQdZA,849
4
- edsl/__init__.py,sha256=iB5q_P2pXDV6Wb5oHKsFDhi_rJXID0aaqio1I98dwXA,1936
5
- edsl/__version__.py,sha256=bRKE9C91TYGzTq0wxI4905SCxXVaXJVP1EuahhGjfCQ,23
6
- edsl/agents/Agent.py,sha256=lF7GD_bCvRLP4hrtm3w451AUfuJln5jZHGYBH84CMVE,40741
4
+ edsl/__init__.py,sha256=It2k2drMyde7O-xh0yesod2OxZ3W0yW21zZKRVifv6g,1896
5
+ edsl/__version__.py,sha256=_gR5xyqmw7ERGVJXAViiOprIWYbHw6O-k82fz9ALi1Q,28
6
+ edsl/agents/Agent.py,sha256=VLIe9gMnLcZkRCQpz8VofEIAbCWj7jNpWxDw5k3KiXI,40734
7
7
  edsl/agents/AgentList.py,sha256=iRfQfyUYtaJbJ3sRubPqPKRr77nKQgzhFEeZ0wcAEk0,18955
8
- edsl/agents/Invigilator.py,sha256=ITQtYsbqFL1DTBZZJ68ij5AZkKH4-Ib9tHjiIoLojDg,11954
8
+ edsl/agents/Invigilator.py,sha256=v9KkQ7yQfhwsrZB-7Bu4ZQ-zl_9Hwaxe0uQyxB-Wvss,11862
9
9
  edsl/agents/InvigilatorBase.py,sha256=JIRy7uogI8Hsv8nx8J2zMnd4XK-WQETlSAzkU6uIYNw,8967
10
10
  edsl/agents/PromptConstructor.py,sha256=orYFJI5Teh47cVJSJ63R8lfcAKSaDclSVX_OVTiqEgw,10752
11
11
  edsl/agents/QuestionInstructionPromptBuilder.py,sha256=t7Yuhvzq0cYbcRxzSOv_bvT3ihlmlyAOsScDMWg9A2M,4526
@@ -36,12 +36,12 @@ edsl/coop/CoopFunctionsMixin.py,sha256=RS79ADEbYUK-frf_WY-YnozVbM3ZaBufv1jxjF96G
36
36
  edsl/coop/ExpectedParrotKeyHandler.py,sha256=1lriainznM1FfQ7GEvTiI1EW8uNi8Sms3Vt5UDxso3U,4456
37
37
  edsl/coop/PriceFetcher.py,sha256=J5EaM-bPqnd2B0ZBVVqXJ-UQK-D4SdjmddYepnN7jz4,1777
38
38
  edsl/coop/__init__.py,sha256=4iZCwJSzJVyjBYk8ggGxY2kZjq9dXVT1jhyPDNyew4I,115
39
- edsl/coop/coop.py,sha256=j5tfzPfQdBW_CcDDpAD5HaqJQNYPPWUCPkEz5wr3vk4,39750
39
+ edsl/coop/coop.py,sha256=9aJod721k_BOPHV_257YsFLxFKRgTbUqmi9ludvYGPc,39678
40
40
  edsl/coop/utils.py,sha256=SBV76sk5_2rhP3RKGkJsOkrx9Qr-jD0puqYhVR_MgSY,3900
41
- edsl/data/Cache.py,sha256=ryMWLowyXa8VwWKru-0pF43JHh2UVyL5Zezst-26J6c,18510
41
+ edsl/data/Cache.py,sha256=EEzfpAyYKeBuCZ4iryUsktVmuk95uu_L047Lr3yWEyE,18270
42
42
  edsl/data/CacheEntry.py,sha256=mTc-WG_dWc4s9s3MrOl3yUqao2Q_igCerNcluM4XCSQ,7376
43
43
  edsl/data/CacheHandler.py,sha256=wy2AdKkk_pmwP71htdmLV9UzXM4AuHm5pn1qscJlX9s,5150
44
- edsl/data/RemoteCacheSync.py,sha256=QVTVjpcGVZz1VxYXZPP7kBGsU9fXOS6EHALHOnQLfRU,6094
44
+ edsl/data/RemoteCacheSync.py,sha256=qgvh2w0c-Ak7poGNucWRd4ze8ncMQYh36a9yp3ib0IU,6062
45
45
  edsl/data/SQLiteDict.py,sha256=V5Nfnxctgh4Iblqcw1KmbnkjtfmWrrombROSQ3mvg6A,8979
46
46
  edsl/data/__init__.py,sha256=i_bbYBc-vrdASBpDMcpIcfhbLKYOkvqA57R3ysBcQ6o,177
47
47
  edsl/data/orm.py,sha256=Jz6rvw5SrlxwysTL0QI9r68EflKxeEBmf6j6himHDS8,238
@@ -86,12 +86,12 @@ edsl/inference_services/models_available_cache.py,sha256=bOvevfRn2HlmBcHalaDkjFL
86
86
  edsl/inference_services/rate_limits_cache.py,sha256=HYslviz7mxF9U4CUTPAkoyBsiXjSju-YCp4HHir6e34,1398
87
87
  edsl/inference_services/registry.py,sha256=Rkjfe4iABQc7aiY73bGnbRAgLXY0osni22hYnmMEI2c,1335
88
88
  edsl/inference_services/write_available.py,sha256=NNwhATlaMp8IYY635MSx-oYxt5X15acjAfaqYCo_I1Y,285
89
- edsl/jobs/AnswerQuestionFunctionConstructor.py,sha256=wNM2HNhEQLYO8BRCfzqPGpJrqmtw0FBkGPa_VUe9emQ,7977
89
+ edsl/jobs/AnswerQuestionFunctionConstructor.py,sha256=NZk9_9d2u8f_bK-qFFCJyM3KNMYNiedW4Ju7uQyPQxc,7973
90
90
  edsl/jobs/Answers.py,sha256=lZpbGAqYqMQw7MUsmpivqMZkHjHHOmCY32s9Km284pQ,1445
91
91
  edsl/jobs/FetchInvigilator.py,sha256=83tbrqY_1qK0biNF1x51N0sFx49FFmuOi3o5HmFuCIY,1785
92
92
  edsl/jobs/InterviewTaskManager.py,sha256=I1GShC2CrBFnGOcWn3q2YUU0SJbesmeLrrM2_nkuhZo,3748
93
93
  edsl/jobs/InterviewsConstructor.py,sha256=MyRgygmi4318PgERjhhZZXlNUju2lB1CBu8LJJjYNSs,1853
94
- edsl/jobs/Jobs.py,sha256=GHyTwD0bL9p5YIMtrJJbShbE0dtAn14oNTdySugVTNU,29694
94
+ edsl/jobs/Jobs.py,sha256=NeHSyzLRXDp3elct9U0DngVwVt6o3JK_aNrOAYDN15E,29570
95
95
  edsl/jobs/JobsChecks.py,sha256=v1sgdjKQTYMoZu-uobM9USn1KaF6QBoOfNSGH7ueZjU,5403
96
96
  edsl/jobs/JobsComponentConstructor.py,sha256=yzjBFQx1oK8CN2taniB82kpXo6W712dIG1E9ouwkujg,6969
97
97
  edsl/jobs/JobsPrompts.py,sha256=OtLWuTPs6dncNyrXXVskpSCoKOUav4msxoa9uDtP2LM,9755
@@ -108,7 +108,7 @@ edsl/jobs/buckets/TokenBucketClient.py,sha256=Jx20nDAdUSh3USUX9B4PHd1uAFMdyOHtRa
108
108
  edsl/jobs/check_survey_scenario_compatibility.py,sha256=dU1IUPb1FFm0P1ievzTmtgcRxH2soCdPaG5GZ1Zd4fA,3816
109
109
  edsl/jobs/data_structures.py,sha256=1kLN6goMLcOIT20vrDW2Wq-sA-cfygb_qgplW4-o090,3727
110
110
  edsl/jobs/decorators.py,sha256=vpeSgI3EP4RFz5V_OclFdnhiSrswihavAN8C9ygRhGE,1135
111
- edsl/jobs/interviews/Interview.py,sha256=hsMyKJFftalQqwZXdAAcT9V1aW7w-ZSvjAc45aqaIRw,15051
111
+ edsl/jobs/interviews/Interview.py,sha256=Zmi0_gNkpMWaho2fvSoCNITrJDfSEmfw7yqKCW3JeK0,15255
112
112
  edsl/jobs/interviews/InterviewExceptionCollection.py,sha256=ZIe9nnI8pznxp1D0K2Ii9SHorc9-f0k_lQV-Giq41P8,3666
113
113
  edsl/jobs/interviews/InterviewExceptionEntry.py,sha256=JMLcftRItQRCo8cOWH5S2H02wa-157l1TCFGVDXfViY,5685
114
114
  edsl/jobs/interviews/InterviewStatistic.py,sha256=hY5d2EkIJ96NilPpZAvZZzZoxLXM7ss3xx5MIcKtTPs,1856
@@ -120,8 +120,8 @@ edsl/jobs/interviews/interview_status_enum.py,sha256=KJ-1yLAHdX-p8TiFnM0M3v1tnBw
120
120
  edsl/jobs/jobs_status_enums.py,sha256=li94KU-DHNEq7ksR2ikQxms6W-J7sfiRlmlgGQX3F-E,172
121
121
  edsl/jobs/loggers/HTMLTableJobLogger.py,sha256=0s47WYqT9JK7dF22U_fVDke6_cDjUKxn-KW6JJTwvYg,11717
122
122
  edsl/jobs/results_exceptions_handler.py,sha256=5meG_S2SXehcMbmBks6QC2RRaR79eHAclDwMCbl_6Rs,3258
123
- edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=j_wrU0CdeCSIRdUno9g-R9UL83z_p6HIrFP_twE9td8,5837
124
- edsl/jobs/runners/JobsRunnerStatus.py,sha256=1aySPXQ0ijCvv6Bqvddqe6Hlr-wAlTvxBV6D3Gvveqw,10466
123
+ edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=isYhNeuNlabvjks5whGVzQKn2t1yJXGCyd2Jg_DACeI,5471
124
+ edsl/jobs/runners/JobsRunnerStatus.py,sha256=DBXohyKcQJ4bkNzQYHm-lT3BaCbrO5Fi6GKr1Vu4Hfc,10379
125
125
  edsl/jobs/runners/JobsRunnerStatusData.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
126
  edsl/jobs/tasks/QuestionTaskCreator.py,sha256=Bx7x2_Tc6hQvaAQNtnxvoF52bTCZH7AhiVWg_gSajmo,9934
127
127
  edsl/jobs/tasks/TaskCreators.py,sha256=XqAbNU33378Z4PQncokbfJwnKt3KHR9aqa5fKYRDpfg,2694
@@ -157,10 +157,9 @@ edsl/questions/ExceptionExplainer.py,sha256=BgM80FRPJjS_TrY6XaVmlT666MzY9DEagviG
157
157
  edsl/questions/HTMLQuestion.py,sha256=mRzVpfFLZ2RYBSDbLHeXTyAXbUHorpiwhNf-nuUSC5M,3431
158
158
  edsl/questions/QuestionBase.py,sha256=vyMOvEfMtka-k9Lkx07e36Ui00wM0sjBLUMxI6mi82c,18504
159
159
  edsl/questions/QuestionBasePromptsMixin.py,sha256=PFzqZKyLhtwKebzakFnbCIN1_GzSzxsHxsRfttsSSEA,7949
160
- edsl/questions/QuestionBudget.py,sha256=fBxDRfPJ3HctSCNTzqGLPuRCACySb3NHugXCNE7pXH8,8133
160
+ edsl/questions/QuestionBudget.py,sha256=Q5jMspdN0sm85bmwoX83KvtgNtogR6nnNgPcLoDlE3I,8133
161
161
  edsl/questions/QuestionCheckBox.py,sha256=ho_tyr3a6gHcA2kWlfz0dSW_-2yd6ifdC3niPPPQJAY,12847
162
- edsl/questions/QuestionDict.py,sha256=uk2X3WWKYuPY_uOoNsj5l9xiPVKk_wRoXBmz70PKBbI,13647
163
- edsl/questions/QuestionExtract.py,sha256=Gix35u_RMHN2-paKJ8pc0h5c7HaMoLD6MOPVZVxVHkY,6055
162
+ edsl/questions/QuestionExtract.py,sha256=42gz1nghFybqrmI3sUHUXB2wKtZtYM5NNFrWOU36fEI,6052
164
163
  edsl/questions/QuestionFreeText.py,sha256=yxs9H8y4RHUcmEjV02-_Pu_DjA2FizG9B3gd_hZQD2I,3377
165
164
  edsl/questions/QuestionFunctional.py,sha256=APuTZ5QNBTLvwv_iNcgFFV81qImiUL3qHMMHjArREf0,5581
166
165
  edsl/questions/QuestionList.py,sha256=YWCtqzo0JnYhNH0yOfU_iheL_3xQLiZm2L8i744B6Vo,7093
@@ -170,17 +169,17 @@ edsl/questions/QuestionNumerical.py,sha256=IBA8X3BuJ0q2sXrhcG1Px1FF1Hz7NOB9jvvtH
170
169
  edsl/questions/QuestionRank.py,sha256=Fqs7Zwv5fzRV5UdBsC7xBR6qzOINJftaCjAtKneSh8w,11283
171
170
  edsl/questions/Quick.py,sha256=h6h4fEvIkLIFJX2JiqfOUEXzku9azWxEpI5o2A4RmVs,1731
172
171
  edsl/questions/SimpleAskMixin.py,sha256=rbiKvNiH0-Fe5-hWSRqi1Yz0RbmwJ5bgU17z8Zf8oXc,2258
173
- edsl/questions/__init__.py,sha256=zW51pm47yGEPElTfUBMZVzA-JPXC5CEw_X8xEt0nAIA,1273
174
- edsl/questions/answer_validator_mixin.py,sha256=JDeWSa6YyZh6wAnnJuVrXxJNPaEou-EDI4X7voqreH4,14332
172
+ edsl/questions/__init__.py,sha256=TasdJQxi0hPlR_icXqkMG6fJMwPi0peOzZMIEyB5ljg,1220
173
+ edsl/questions/answer_validator_mixin.py,sha256=kJQ7lePSt8vIDtZpS0-5NDf_APA7GAR1ufgUulovLvk,13306
175
174
  edsl/questions/compose_questions.py,sha256=ZcLkwNaofk-o0-skGXEDGZAj6DumOhVhyIUjqEnKrbg,3380
176
175
  edsl/questions/data_structures.py,sha256=PbIML8388sHogUHGamz21DXKEpfU8zwyiGflc1y0cHE,432
177
176
  edsl/questions/decorators.py,sha256=ZijaRYUntAcg0JEztCiOEpcDvvVie___85Zx5ogBQXY,596
178
177
  edsl/questions/derived/QuestionLikertFive.py,sha256=XCpmwlk2qyCxEkiG3UwPqVpS5-k4d4uWyMaxfJg5wkw,2585
179
- edsl/questions/derived/QuestionLinearScale.py,sha256=oGxTOFITNrFofV468Gow9rtnBMWBBS6HR2sdw6nenqE,3419
178
+ edsl/questions/derived/QuestionLinearScale.py,sha256=7A1VQc_ECIX8UgkH_usySEMMDThFiqKtrGJakL8mPdY,3420
180
179
  edsl/questions/derived/QuestionTopK.py,sha256=IAmW1kUA1rvW_NH3yxroLfarhl6_QyTEwWZ54gbi6fg,3294
181
180
  edsl/questions/derived/QuestionYesNo.py,sha256=KWJyaXSNPNxELtK0nWvIqNtpAF05MMAC0ILUjxXkVwo,2735
182
181
  edsl/questions/derived/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
- edsl/questions/descriptors.py,sha256=aZXserK3kKpR_VaxZUhnUZtQd2n4HP4sBxKBGOB9ChY,18374
182
+ edsl/questions/descriptors.py,sha256=tPWOseUxmHUrL0rPcBcYmg-0gyzwvxGLAo3Jh3-apCQ,16606
184
183
  edsl/questions/loop_processor.py,sha256=h2t8Sn71JBBpim3MaVcZtPTcUsPCBR2aJIpzDFzam5k,4553
185
184
  edsl/questions/prompt_templates/question_budget.jinja,sha256=-ekZYCa_KRc-xLcpf3j-YmXV0WSyIK_laOp2x3li-tA,737
186
185
  edsl/questions/prompt_templates/question_checkbox.jinja,sha256=V-Dn2VJhfXyIILWIhMviTfQ5WuXh1YZerwicaA6Okzc,1136
@@ -191,7 +190,7 @@ edsl/questions/prompt_templates/question_list.jinja,sha256=MAkNv88E79jXK9TxKdnf5
191
190
  edsl/questions/prompt_templates/question_multiple_choice.jinja,sha256=sSyAhnexZF6oWqHL-45r7o69vrFcCbbYXLZ3zu7q76U,761
192
191
  edsl/questions/prompt_templates/question_numerical.jinja,sha256=c20sp3HfFonfaRwwmnF7HjAEugU15QlgpNAIkNHasl0,1218
193
192
  edsl/questions/question_base_gen_mixin.py,sha256=UNgYVmQvX_adD9FxQEd0peTzhW6-lf9iDocmkNplZhY,6182
194
- edsl/questions/question_registry.py,sha256=H4Q4JYMHn7-_5rU7Ap26N6Ruzz9WSZqOf1b89MScIDI,6352
193
+ edsl/questions/question_registry.py,sha256=zfXrHu8nJGLgp-ExIVy9whMwvCEcobSgxw7hvwEawEk,6344
195
194
  edsl/questions/register_questions_meta.py,sha256=2h_9iZt3cjr_7JRmveTqbmEBBCvjtefMDfhM7Pgd_zg,2598
196
195
  edsl/questions/response_validator_abc.py,sha256=410DIb8Z5uF_xu1lG32OF6X7aoOtL6gG3UIMY83kfeo,6838
197
196
  edsl/questions/response_validator_factory.py,sha256=IzRHHcr2CjWFLgCHXHojwWa5Erc6E8pilTLys1M-5zE,1301
@@ -203,9 +202,6 @@ edsl/questions/templates/budget/question_presentation.jinja,sha256=wrZnM5ZbNhPZs
203
202
  edsl/questions/templates/checkbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
204
203
  edsl/questions/templates/checkbox/answering_instructions.jinja,sha256=UCPWWsnaAW3oB05IZDLQtofHXBesbqQxguXMfykUTQU,441
205
204
  edsl/questions/templates/checkbox/question_presentation.jinja,sha256=2u8XIkFPWzOuhbeoIvYBm6zUWnTHF66cGJXIznxVobw,807
206
- edsl/questions/templates/dict/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
207
- edsl/questions/templates/dict/answering_instructions.jinja,sha256=4TJnVLM2PSZbob8fuzrUAS-oaZrU6y8osKTIyxzAtRY,676
208
- edsl/questions/templates/dict/question_presentation.jinja,sha256=OLDuxUc6BjT4InCtAkK_e-D5qbsDmtxw1Spp9pWFYhU,17
209
205
  edsl/questions/templates/extract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
210
206
  edsl/questions/templates/extract/answering_instructions.jinja,sha256=sjHH4mBdoi6fdpHtRNWG0q3E4ZihvBpVUf08TNnwad4,253
211
207
  edsl/questions/templates/extract/question_presentation.jinja,sha256=OLDuxUc6BjT4InCtAkK_e-D5qbsDmtxw1Spp9pWFYhU,17
@@ -246,8 +242,8 @@ edsl/results/DatasetExportMixin.py,sha256=6U1IN1Nb_bwgDZtQx9mhUV63Topkvv3ssxyqBE
246
242
  edsl/results/DatasetTree.py,sha256=nvNCF9psLcQ65qsxze7qkrhLn-U-N8OJ327Nf-sFskQ,10178
247
243
  edsl/results/MarkdownToDocx.py,sha256=e8kdDPoqS6Zvd8OTldP9AXbjtmr8BZnro7f0-g1ENi4,4123
248
244
  edsl/results/MarkdownToPDF.py,sha256=RgQ8V86AD_h0HlohUiTWcbL8zOpI8xFC4FK-aOh26HE,3608
249
- edsl/results/Result.py,sha256=6uNvV7G3mysZbIU5EFhDDtG0xdedXG1p3RYnLhRMfuM,21181
250
- edsl/results/Results.py,sha256=yc4zx4aNuk1nzXYQljzT024r5bB3V1tSTheOeVzix0I,41859
245
+ edsl/results/Result.py,sha256=B3rlgryviGkLiXYNRmT1F2HnYYZo-9cyC_UYIIWDu6A,20548
246
+ edsl/results/Results.py,sha256=uQbmwPCyb027iZSY_9SYLD5M2NhbZkKpl3U_I9Tc4Ao,41490
251
247
  edsl/results/ResultsExportMixin.py,sha256=v9N4pUMrycmKIDzdWn1grmx7F8lxIPAOjfV6OScYSwc,1379
252
248
  edsl/results/ResultsGGMixin.py,sha256=SAYz8p4wb1g8x6KhBVz9NHOGib2c2XsqtTclpADrFeM,4344
253
249
  edsl/results/TableDisplay.py,sha256=xGJcotgUqWrmCkQLeD9YIwLrNv7su4VDce3EnllfrLQ,3725
@@ -265,7 +261,7 @@ edsl/results/tree_explore.py,sha256=hQjiO4E71rIOPDgEHgK8T8ukxqoNdgX_tvyiDlG4_9U,
265
261
  edsl/scenarios/ConstructDownloadLink.py,sha256=DGfF6hoCUovpTQ_GWiEndc--fXe9St6UdiaPhj7ZJZw,3529
266
262
  edsl/scenarios/DocumentChunker.py,sha256=LZXh_yx507LMNQ-i2VnSHZiPpRI0XQUECO8e3xAKAjI,3545
267
263
  edsl/scenarios/DocxScenario.py,sha256=ul3nkX826m_T6LFptswqtnH5czP_yxMlLWgbTmFIZI4,482
268
- edsl/scenarios/FileStore.py,sha256=onFZAqkdqzyQeQ9_2zn1qGY40SqmRG9X8DvtcbXW39o,17418
264
+ edsl/scenarios/FileStore.py,sha256=c4Mzco_xpcyVGywHHAyPuu53OzRQD_9W9fyyPsYQKtc,16202
269
265
  edsl/scenarios/PdfExtractor.py,sha256=ATJ_QOJ3yE7SkdAu3nQdQ-Z9dSjkBZyrEgeuDNtU_ZQ,1310
270
266
  edsl/scenarios/Scenario.py,sha256=670xmH15K0YZovouw4EQc1fdGerY96gtfgfAOOjSxno,17021
271
267
  edsl/scenarios/ScenarioHtmlMixin.py,sha256=5H8MnPPWqlGZ0_Ojv1WjkFaNNRrr-JpCRwlABDBfPXs,2111
@@ -276,7 +272,7 @@ edsl/scenarios/__init__.py,sha256=CQXwTNTIG9jg_pLkDPZgapUFY0_LwZFVQ8HaYvof0Nc,14
276
272
  edsl/scenarios/directory_scanner.py,sha256=eJHPx6pc_No-I-old0vwrNRwNxmgnn3Fr6mht5mp8Fw,3312
277
273
  edsl/scenarios/file_methods.py,sha256=HeusyoXOi2Bb0Bfp8MVDWKMFpe_ipP-cxENiRrSKZQU,2621
278
274
  edsl/scenarios/handlers/__init__.py,sha256=4GdEfrAk5a7mUfbwnf0TCcrvp1_aAYZPAnd433NmiGM,384
279
- edsl/scenarios/handlers/csv.py,sha256=5W2fWa6FAL_QGTYTVLFaiEr28f6W7FaF-a9drsklSfc,1383
275
+ edsl/scenarios/handlers/csv.py,sha256=6wKJwTWqMbVOX5ZgjKmo6fh3P1Y-2QJJ79KJ18hRAnk,1129
280
276
  edsl/scenarios/handlers/docx.py,sha256=e6POWp3Xs-XCVr8TKMtDka1ZRySXZf17TcSimvw6owY,2203
281
277
  edsl/scenarios/handlers/html.py,sha256=zXipNAYcQE4LRBrKZC9L_tkY1snxQe8ciJ2S1diyMcM,927
282
278
  edsl/scenarios/handlers/json.py,sha256=hlZMHYwwuFrV9bGdbn8MNAjgBFue6l5W2TwCfyxSjZ0,3682
@@ -308,7 +304,7 @@ edsl/surveys/Rule.py,sha256=Hou5_sSpvIfBdZNQk8tHFf-q4JT0wrV_kPMGbmLBfgA,12403
308
304
  edsl/surveys/RuleCollection.py,sha256=UC300EOPhjrMc-88eWt5kKBg1pVvKzzwgda2hjHW_sk,14790
309
305
  edsl/surveys/RuleManager.py,sha256=8k1XfTWaJbgjLLJsryBxVSiZ2_YuJPqE750jZEEtVwI,6216
310
306
  edsl/surveys/Simulator.py,sha256=I4_vHNnwe43SAbw7CK1xa45tahAKHfNRbRxGTRXdHuA,2586
311
- edsl/surveys/Survey.py,sha256=goK0WmA0DyCgqh9hYt3qnJwp2ZY-RUpwoLUXbFDc28s,47993
307
+ edsl/surveys/Survey.py,sha256=DyJGHUftEybU70WKYu891mJEcjVKETxw6fmFnJ7d3zg,47818
312
308
  edsl/surveys/SurveyCSS.py,sha256=fIdiLuXTUq6KuoXXAU_LTHTTe6RchnCmZpj3j7qnt5Y,8796
313
309
  edsl/surveys/SurveyExportMixin.py,sha256=Kvkd2ku2Kemsn2Nw-Yt8GTnGFcUqfEiKznmisAeO7ck,8339
314
310
  edsl/surveys/SurveyFlowVisualization.py,sha256=OLdVZstVuzR_DFulTosRBhpUa9wQ6XJjKbOpvTUCgJw,6467
@@ -356,7 +352,7 @@ edsl/utilities/remove_edsl_version.py,sha256=3n2RoXvZ4pH3k-_lc7B-vkeUyHXHX6vKHQS
356
352
  edsl/utilities/repair_functions.py,sha256=tftmklAqam6LOQQu_-9U44N-llycffhW8LfO63vBmNw,929
357
353
  edsl/utilities/restricted_python.py,sha256=5-_zUhrNbos7pLhDl9nr8d24auRlquR6w-vKkmNjPiA,2060
358
354
  edsl/utilities/utilities.py,sha256=FbI9QYGD4eaHrwZ6ePx51jjpatZqwSPHJhimx-h6HyA,12660
359
- edsl-0.1.40.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
360
- edsl-0.1.40.dist-info/METADATA,sha256=b_Qbp0IFIJsaj0QHf0_ppCaCoZaiTyV8F-yn5FeP3KU,4760
361
- edsl-0.1.40.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
362
- edsl-0.1.40.dist-info/RECORD,,
355
+ edsl-0.1.40.dev2.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
356
+ edsl-0.1.40.dev2.dist-info/METADATA,sha256=HLmgd08kBzvGc3Rxufmpw0NMMk20FMgzD-4Nk7J2E6E,4766
357
+ edsl-0.1.40.dev2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
358
+ edsl-0.1.40.dev2.dist-info/RECORD,,
@@ -1,343 +0,0 @@
1
- from __future__ import annotations
2
- from typing import Union, Optional, Dict, List, Any, Type
3
- from pydantic import BaseModel, Field, field_validator
4
- from jinja2 import Environment, FileSystemLoader, TemplateNotFound
5
- from pathlib import Path
6
-
7
- from edsl.questions.QuestionBase import QuestionBase
8
- from edsl.questions.descriptors import (
9
- AnswerKeysDescriptor,
10
- ValueTypesDescriptor,
11
- ValueDescriptionsDescriptor,
12
- QuestionTextDescriptor,
13
- )
14
- from edsl.questions.response_validator_abc import ResponseValidatorABC
15
- from edsl.exceptions.questions import QuestionCreationValidationError
16
- from edsl.questions.decorators import inject_exception
17
-
18
-
19
- class DictResponseValidator(ResponseValidatorABC):
20
- required_params = ["answer_keys", "permissive"]
21
-
22
- valid_examples = [
23
- (
24
- {
25
- "answer": {
26
- "name": "Hot Chocolate",
27
- "num_ingredients": 5,
28
- "ingredients": ["milk", "cocoa", "sugar"]
29
- }
30
- },
31
- {
32
- "answer_keys": ["name", "num_ingredients", "ingredients"],
33
- "value_types": ["str", "int", "list[str]"]
34
- },
35
- )
36
- ]
37
- invalid_examples = [
38
- (
39
- {"answer": {"name": 123}}, # Name should be a string
40
- {"answer_keys": ["name"], "value_types": ["str"]},
41
- "Key 'name' has value of type int, expected str",
42
- ),
43
- (
44
- {"answer": {"ingredients": "milk"}}, # Should be a list
45
- {"answer_keys": ["ingredients"], "value_types": ["list"]},
46
- "Key 'ingredients' should be a list, got str",
47
- )
48
- ]
49
-
50
-
51
- class QuestionDict(QuestionBase):
52
- question_type = "dict"
53
- question_text: str = QuestionTextDescriptor()
54
- answer_keys: List[str] = AnswerKeysDescriptor()
55
- value_types: Optional[List[str]] = ValueTypesDescriptor()
56
- value_descriptions: Optional[List[str]] = ValueDescriptionsDescriptor()
57
-
58
- _response_model = None
59
- response_validator_class = DictResponseValidator
60
-
61
- def _get_default_answer(self) -> Dict[str, Any]:
62
- """Get default answer based on types."""
63
- answer = {}
64
- if not self.value_types:
65
- return {
66
- "title": "Sample Recipe",
67
- "ingredients": ["ingredient1", "ingredient2"],
68
- "num_ingredients": 2,
69
- "instructions": "Sample instructions"
70
- }
71
-
72
- for key, type_str in zip(self.answer_keys, self.value_types):
73
- if type_str.startswith(('list[', 'list')):
74
- if '[' in type_str:
75
- element_type = type_str[type_str.index('[') + 1:type_str.rindex(']')].lower()
76
- if element_type == 'str':
77
- answer[key] = ["sample_string"]
78
- elif element_type == 'int':
79
- answer[key] = [1]
80
- elif element_type == 'float':
81
- answer[key] = [1.0]
82
- else:
83
- answer[key] = []
84
- else:
85
- answer[key] = []
86
- else:
87
- if type_str == 'str':
88
- answer[key] = "sample_string"
89
- elif type_str == 'int':
90
- answer[key] = 1
91
- elif type_str == 'float':
92
- answer[key] = 1.0
93
- else:
94
- answer[key] = None
95
-
96
- return answer
97
-
98
- def create_response_model(
99
- self,
100
- ) -> Type[BaseModel]:
101
- """Create a response model for dict questions."""
102
- default_answer = self._get_default_answer()
103
-
104
- class DictResponse(BaseModel):
105
- answer: Dict[str, Any] = Field(
106
- default_factory=lambda: default_answer.copy()
107
- )
108
- comment: Optional[str] = None
109
-
110
- @field_validator("answer")
111
- def validate_answer(cls, v, values, **kwargs):
112
- # Ensure all keys exist
113
- missing_keys = set(self.answer_keys) - set(v.keys())
114
- if missing_keys:
115
- raise ValueError(f"Missing required keys: {missing_keys}")
116
-
117
- # Validate value types if not permissive
118
- if not self.permissive and self.value_types:
119
- for key, type_str in zip(self.answer_keys, self.value_types):
120
- if key not in v:
121
- continue
122
-
123
- value = v[key]
124
- type_str = type_str.lower() # Normalize to lowercase
125
-
126
- # Handle list types
127
- if type_str.startswith(('list[', 'list')):
128
- if not isinstance(value, list):
129
- raise ValueError(f"Key '{key}' should be a list, got {type(value).__name__}")
130
-
131
- # If it's a parameterized list, check element types
132
- if '[' in type_str:
133
- element_type = type_str[type_str.index('[') + 1:type_str.rindex(']')]
134
- element_type = element_type.lower().strip()
135
-
136
- for i, elem in enumerate(value):
137
- expected_type = {
138
- 'str': str,
139
- 'int': int,
140
- 'float': float,
141
- 'list': list
142
- }.get(element_type)
143
-
144
- if expected_type and not isinstance(elem, expected_type):
145
- raise ValueError(
146
- f"List element at index {i} for key '{key}' "
147
- f"has type {type(elem).__name__}, expected {element_type}"
148
- )
149
- else:
150
- # Handle basic types
151
- expected_type = {
152
- 'str': str,
153
- 'int': int,
154
- 'float': float,
155
- 'list': list,
156
- }.get(type_str)
157
-
158
- if expected_type and not isinstance(value, expected_type):
159
- raise ValueError(
160
- f"Key '{key}' has value of type {type(value).__name__}, expected {type_str}"
161
- )
162
- return v
163
-
164
- model_config = {
165
- "json_schema_extra": {
166
- "examples": [{
167
- "answer": default_answer,
168
- "comment": None
169
- }]
170
- }
171
- }
172
-
173
- DictResponse.__name__ = "DictResponse"
174
- return DictResponse
175
-
176
- def __init__(
177
- self,
178
- question_name: str,
179
- question_text: str,
180
- answer_keys: List[str],
181
- value_types: Optional[List[Union[str, type]]] = None,
182
- value_descriptions: Optional[List[str]] = None,
183
- include_comment: bool = True,
184
- question_presentation: Optional[str] = None,
185
- answering_instructions: Optional[str] = None,
186
- permissive: bool = False,
187
- ):
188
- self.question_name = question_name
189
- self.question_text = question_text
190
- self.answer_keys = answer_keys
191
- self.value_types = self._normalize_value_types(value_types)
192
- self.value_descriptions = value_descriptions
193
- self.include_comment = include_comment
194
- self.question_presentation = question_presentation or self._render_template(
195
- "question_presentation.jinja"
196
- )
197
- self.answering_instructions = answering_instructions or self._render_template(
198
- "answering_instructions.jinja"
199
- )
200
- self.permissive = permissive
201
-
202
- # Validation
203
- if self.value_types and len(self.value_types) != len(self.answer_keys):
204
- raise QuestionCreationValidationError(
205
- "Length of value_types must match length of answer_keys."
206
- )
207
- if self.value_descriptions and len(self.value_descriptions) != len(self.answer_keys):
208
- raise QuestionCreationValidationError(
209
- "Length of value_descriptions must match length of answer_keys."
210
- )
211
-
212
- @staticmethod
213
- def _normalize_value_types(value_types: Optional[List[Union[str, type]]]) -> Optional[List[str]]:
214
- """Convert all value_types to string representations, including type hints."""
215
- if not value_types:
216
- return None
217
-
218
- def normalize_type(t) -> str:
219
- # Handle string representations of List
220
- t_str = str(t)
221
- if t_str == 'List':
222
- return 'list'
223
-
224
- # Handle string inputs
225
- if isinstance(t, str):
226
- t = t.lower()
227
- # Handle list types
228
- if t.startswith(('list[', 'list')):
229
- if '[' in t:
230
- # Normalize the inner type
231
- inner_type = t[t.index('[') + 1:t.rindex(']')].strip().lower()
232
- return f"list[{inner_type}]"
233
- return "list"
234
- return t
235
-
236
- # Handle List the same as list
237
- if t_str == "<class 'List'>":
238
- return "list"
239
-
240
- # If it's list type
241
- if t is list:
242
- return "list"
243
-
244
- # If it's a basic type
245
- if hasattr(t, "__name__"):
246
- return t.__name__.lower()
247
-
248
- # If it's a typing.List
249
- if t_str.startswith(('list[', 'list')):
250
- return t_str.replace('typing.', '').lower()
251
-
252
- # Handle generic types
253
- if hasattr(t, "__origin__"):
254
- origin = t.__origin__.__name__.lower()
255
- args = [
256
- arg.__name__.lower() if hasattr(arg, "__name__") else str(arg).lower()
257
- for arg in t.__args__
258
- ]
259
- return f"{origin}[{', '.join(args)}]"
260
-
261
- raise QuestionCreationValidationError(
262
- f"Invalid type in value_types: {t}. Must be a type or string."
263
- )
264
-
265
- normalized = []
266
- for t in value_types:
267
- try:
268
- normalized.append(normalize_type(t))
269
- except Exception as e:
270
- raise QuestionCreationValidationError(f"Error normalizing type {t}: {str(e)}")
271
-
272
- return normalized
273
-
274
- def _render_template(self, template_name: str) -> str:
275
- """Render a template using Jinja."""
276
- try:
277
- template_dir = Path(__file__).parent / "templates" / "dict"
278
- env = Environment(loader=FileSystemLoader(template_dir))
279
- template = env.get_template(template_name)
280
- return template.render(
281
- question_name=self.question_name,
282
- question_text=self.question_text,
283
- answer_keys=self.answer_keys,
284
- value_types=self.value_types,
285
- value_descriptions=self.value_descriptions,
286
- include_comment=self.include_comment,
287
- )
288
- except TemplateNotFound:
289
- return f"Template {template_name} not found in {template_dir}."
290
-
291
- def to_dict(self, add_edsl_version: bool = True) -> dict:
292
- """Serialize to JSON-compatible dictionary."""
293
- return {
294
- "question_type": self.question_type,
295
- "question_name": self.question_name,
296
- "question_text": self.question_text,
297
- "answer_keys": self.answer_keys,
298
- "value_types": self.value_types or [],
299
- "value_descriptions": self.value_descriptions or [],
300
- "include_comment": self.include_comment,
301
- "permissive": self.permissive,
302
- }
303
-
304
- @classmethod
305
- def from_dict(cls, data: dict) -> 'QuestionDict':
306
- """Recreate from a dictionary."""
307
- return cls(
308
- question_name=data["question_name"],
309
- question_text=data["question_text"],
310
- answer_keys=data["answer_keys"],
311
- value_types=data.get("value_types"),
312
- value_descriptions=data.get("value_descriptions"),
313
- include_comment=data.get("include_comment", True),
314
- permissive=data.get("permissive", False),
315
- )
316
-
317
- @classmethod
318
- @inject_exception
319
- def example(cls) -> 'QuestionDict':
320
- """Return an example question."""
321
- return cls(
322
- question_name="example",
323
- question_text="Please provide a simple recipe for hot chocolate.",
324
- answer_keys=["title", "ingredients", "num_ingredients", "instructions"],
325
- value_types=["str", "list[str]", "int", "str"],
326
- value_descriptions=[
327
- "The title of the recipe.",
328
- "A list of ingredients.",
329
- "The number of ingredients.",
330
- "The instructions for making the recipe."
331
- ],
332
- )
333
-
334
- def _simulate_answer(self) -> dict:
335
- """Simulate an answer for the question."""
336
- return {
337
- "answer": self._get_default_answer(),
338
- "comment": None
339
- }
340
-
341
- if __name__ == "__main__":
342
- q = QuestionDict.example()
343
- print(q.to_dict())
File without changes
@@ -1,21 +0,0 @@
1
- Please respond with a dictionary using the following keys: {{ answer_keys | join(', ') }}.
2
-
3
- {% if value_descriptions %}
4
- Here are descriptions of the values to provide:
5
- {% for idx in range(answer_keys | length) %}
6
- - "{{ answer_keys[idx] }}": "{{ value_descriptions[idx] }}"
7
- {% endfor %}
8
- {% endif %}
9
-
10
- {% if value_types %}
11
- The values should be formatted in the following types:
12
- {% for idx in range(answer_keys | length) %}
13
- - "{{ answer_keys[idx] }}": "{{ value_types[idx] }}"
14
- {% endfor %}
15
- {% endif %}
16
-
17
- If you do not have a value for a given key, use "null".
18
-
19
- {% if include_comment %}
20
- After the answer, you can put a comment explaining your response on the next line.
21
- {% endif %}
@@ -1 +0,0 @@
1
- {{question_text}}