edsl 0.1.29__py3-none-any.whl → 0.1.29.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.
- edsl/Base.py +18 -18
- edsl/__init__.py +23 -23
- edsl/__version__.py +1 -1
- edsl/agents/Agent.py +41 -77
- edsl/agents/AgentList.py +9 -19
- edsl/agents/Invigilator.py +1 -19
- edsl/agents/InvigilatorBase.py +10 -15
- edsl/agents/PromptConstructionMixin.py +100 -342
- edsl/agents/descriptors.py +1 -2
- edsl/config.py +1 -2
- edsl/conjure/InputData.py +8 -39
- edsl/coop/coop.py +150 -187
- edsl/coop/utils.py +75 -43
- edsl/data/Cache.py +5 -19
- edsl/data/SQLiteDict.py +3 -11
- edsl/jobs/Answers.py +1 -15
- edsl/jobs/Jobs.py +46 -90
- edsl/jobs/buckets/ModelBuckets.py +2 -4
- edsl/jobs/buckets/TokenBucket.py +2 -1
- edsl/jobs/interviews/Interview.py +9 -3
- edsl/jobs/interviews/InterviewStatusMixin.py +3 -3
- edsl/jobs/interviews/InterviewTaskBuildingMixin.py +10 -15
- edsl/jobs/runners/JobsRunnerAsyncio.py +25 -21
- edsl/jobs/tasks/TaskHistory.py +3 -4
- edsl/language_models/LanguageModel.py +11 -5
- edsl/language_models/ModelList.py +1 -1
- edsl/language_models/repair.py +7 -8
- edsl/notebooks/Notebook.py +3 -40
- edsl/prompts/Prompt.py +19 -31
- edsl/questions/QuestionBase.py +13 -38
- edsl/questions/QuestionBudget.py +6 -5
- edsl/questions/QuestionCheckBox.py +3 -7
- edsl/questions/QuestionExtract.py +3 -5
- edsl/questions/QuestionFreeText.py +3 -3
- edsl/questions/QuestionFunctional.py +3 -0
- edsl/questions/QuestionList.py +4 -3
- edsl/questions/QuestionMultipleChoice.py +8 -16
- edsl/questions/QuestionNumerical.py +3 -4
- edsl/questions/QuestionRank.py +3 -5
- edsl/questions/__init__.py +3 -4
- edsl/questions/descriptors.py +2 -4
- edsl/questions/question_registry.py +31 -20
- edsl/questions/settings.py +1 -1
- edsl/results/Dataset.py +0 -31
- edsl/results/Result.py +74 -22
- edsl/results/Results.py +47 -97
- edsl/results/ResultsDBMixin.py +3 -7
- edsl/results/ResultsExportMixin.py +537 -22
- edsl/results/ResultsGGMixin.py +3 -3
- edsl/results/ResultsToolsMixin.py +5 -5
- edsl/scenarios/Scenario.py +6 -5
- edsl/scenarios/ScenarioList.py +11 -34
- edsl/scenarios/ScenarioListPdfMixin.py +1 -2
- edsl/scenarios/__init__.py +0 -1
- edsl/study/Study.py +9 -3
- edsl/surveys/MemoryPlan.py +4 -11
- edsl/surveys/Survey.py +7 -46
- edsl/surveys/SurveyExportMixin.py +2 -4
- edsl/surveys/SurveyFlowVisualizationMixin.py +4 -6
- edsl/tools/plotting.py +2 -4
- edsl/utilities/__init__.py +21 -21
- edsl/utilities/interface.py +45 -66
- edsl/utilities/utilities.py +13 -11
- {edsl-0.1.29.dist-info → edsl-0.1.29.dev2.dist-info}/METADATA +10 -11
- {edsl-0.1.29.dist-info → edsl-0.1.29.dev2.dist-info}/RECORD +68 -71
- edsl-0.1.29.dev2.dist-info/entry_points.txt +3 -0
- edsl/base/Base.py +0 -289
- edsl/results/DatasetExportMixin.py +0 -493
- edsl/scenarios/FileStore.py +0 -140
- edsl/scenarios/ScenarioListExportMixin.py +0 -32
- {edsl-0.1.29.dist-info → edsl-0.1.29.dev2.dist-info}/LICENSE +0 -0
- {edsl-0.1.29.dist-info → edsl-0.1.29.dev2.dist-info}/WHEEL +0 -0
edsl/utilities/utilities.py
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
"""Utility functions for working with strings, dictionaries, and files."""
|
2
2
|
|
3
|
-
from functools import wraps
|
4
|
-
import types
|
5
|
-
import time
|
6
|
-
|
7
3
|
import hashlib
|
8
4
|
import json
|
9
5
|
import keyword
|
@@ -15,10 +11,18 @@ import tempfile
|
|
15
11
|
import gzip
|
16
12
|
import webbrowser
|
17
13
|
import json
|
18
|
-
|
19
14
|
from html import escape
|
20
15
|
from typing import Callable, Union
|
21
16
|
|
17
|
+
from pygments import highlight
|
18
|
+
from pygments.lexers import JsonLexer
|
19
|
+
from pygments.formatters import HtmlFormatter
|
20
|
+
from IPython.display import HTML
|
21
|
+
|
22
|
+
from functools import wraps
|
23
|
+
import types
|
24
|
+
import time
|
25
|
+
|
22
26
|
|
23
27
|
def time_it(func):
|
24
28
|
@wraps(func)
|
@@ -48,6 +52,10 @@ def dict_hash(data: dict):
|
|
48
52
|
)
|
49
53
|
|
50
54
|
|
55
|
+
import re
|
56
|
+
import json
|
57
|
+
|
58
|
+
|
51
59
|
def extract_json_from_string(text):
|
52
60
|
pattern = re.compile(r"\{.*?\}")
|
53
61
|
match = pattern.search(text)
|
@@ -88,11 +96,6 @@ def data_to_html(data, replace_new_lines=False):
|
|
88
96
|
if "edsl_class_name" in data:
|
89
97
|
_ = data.pop("edsl_class_name")
|
90
98
|
|
91
|
-
from pygments import highlight
|
92
|
-
from pygments.lexers import JsonLexer
|
93
|
-
from pygments.formatters import HtmlFormatter
|
94
|
-
from IPython.display import HTML
|
95
|
-
|
96
99
|
json_str = json.dumps(data, indent=4)
|
97
100
|
formatted_json = highlight(
|
98
101
|
json_str,
|
@@ -101,7 +104,6 @@ def data_to_html(data, replace_new_lines=False):
|
|
101
104
|
)
|
102
105
|
if replace_new_lines:
|
103
106
|
formatted_json = formatted_json.replace("\\n", "<br>")
|
104
|
-
|
105
107
|
return HTML(formatted_json).data
|
106
108
|
|
107
109
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: edsl
|
3
|
-
Version: 0.1.29
|
3
|
+
Version: 0.1.29.dev2
|
4
4
|
Summary: Create and analyze LLM-based surveys
|
5
5
|
Home-page: https://www.expectedparrot.com/
|
6
6
|
License: MIT
|
@@ -57,6 +57,15 @@ The Expected Parrot Domain-Specific Language (EDSL) package lets you conduct com
|
|
57
57
|
- [LinkedIn](https://www.linkedin.com/company/expectedparrot/)
|
58
58
|
- [Blog](https://blog.expectedparrot.com)
|
59
59
|
|
60
|
+
## 💡 Contributions, feature requests & bugs
|
61
|
+
Interested in contributing? Want us to add a new feature? Found a bug for us to squash?
|
62
|
+
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).
|
63
|
+
|
64
|
+
## 💻 Requirements
|
65
|
+
* EDSL is compatible with Python 3.9 - 3.12.
|
66
|
+
* API keys for large language models that you want to use, stored in a `.env` file.
|
67
|
+
See instructions on [storing API keys](https://docs.expectedparrot.com/en/latest/api_keys.html).
|
68
|
+
|
60
69
|
## 🌎 Hello, World!
|
61
70
|
A quick example:
|
62
71
|
|
@@ -87,13 +96,3 @@ Output:
|
|
87
96
|
│ Good │
|
88
97
|
└───────────────────┘
|
89
98
|
```
|
90
|
-
|
91
|
-
## 💻 Requirements
|
92
|
-
* EDSL is compatible with Python 3.9 - 3.12.
|
93
|
-
* API keys for large language models that you want to use, stored in a `.env` file.
|
94
|
-
See instructions on [storing API keys](https://docs.expectedparrot.com/en/latest/api_keys.html).
|
95
|
-
|
96
|
-
## 💡 Contributions, feature requests & bugs
|
97
|
-
Interested in contributing? Want us to add a new feature? Found a bug for us to squash?
|
98
|
-
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).
|
99
|
-
|
@@ -1,19 +1,18 @@
|
|
1
|
-
edsl/Base.py,sha256=
|
1
|
+
edsl/Base.py,sha256=7xc-2fmIGVx-yofU54w5eDU6WSl1AwgrNP2YncDd93M,8847
|
2
2
|
edsl/BaseDiff.py,sha256=RoVEh52UJs22yMa7k7jv8se01G62jJNWnBzaZngo-Ug,8260
|
3
|
-
edsl/__init__.py,sha256=
|
4
|
-
edsl/__version__.py,sha256=
|
5
|
-
edsl/agents/Agent.py,sha256=
|
6
|
-
edsl/agents/AgentList.py,sha256=
|
7
|
-
edsl/agents/Invigilator.py,sha256=
|
8
|
-
edsl/agents/InvigilatorBase.py,sha256=
|
9
|
-
edsl/agents/PromptConstructionMixin.py,sha256=
|
3
|
+
edsl/__init__.py,sha256=k_qOASWIvMoJTJI9m3t-v-VxFlEvp8Ks8ZtO97vrZ5g,1347
|
4
|
+
edsl/__version__.py,sha256=S0WX3UBuFsLEGfsZlPSBBFzqIC3YdwfL_kPxx6z_zNY,28
|
5
|
+
edsl/agents/Agent.py,sha256=_PvcQIjeJpyn-ZLOPl3d8f0UZ2AmW-PuHjl9nuhzOEY,25955
|
6
|
+
edsl/agents/AgentList.py,sha256=GK4AeQ7u9_1bR29UqiJOVnq7lqL_4JuUxGEHuM3ZQF0,9099
|
7
|
+
edsl/agents/Invigilator.py,sha256=vUjNsQrE724Cepr1XvOp2CTER7GBGZ8XoVl6yzfbeP0,10061
|
8
|
+
edsl/agents/InvigilatorBase.py,sha256=IRk2aVSJM3cTXgyuuoc7Dc9oBs311UK0mjkTDmgCjbU,7282
|
9
|
+
edsl/agents/PromptConstructionMixin.py,sha256=Yovq-7wZG8i95QLEee90Xi3AFp3TpbzGhM-kdKNLZNg,5129
|
10
10
|
edsl/agents/__init__.py,sha256=a3H1lxDwu9HR8fwh79C5DgxPSFv_bE2rzQ6y1D8Ba5c,80
|
11
|
-
edsl/agents/descriptors.py,sha256=
|
12
|
-
edsl/
|
13
|
-
edsl/config.py,sha256=--CQg-zL3-Jm8g5OUWsdWHxI-tEs_EDKCKFREcegYOI,5618
|
11
|
+
edsl/agents/descriptors.py,sha256=T2OY6JvbPUC7GVBUKeLELcwPgjztTSi2bnbLfZqbaXY,2925
|
12
|
+
edsl/config.py,sha256=0-do1zGqRF9VpvW---qlzkBvB70IHSQe2OH44ZdXOf8,5617
|
14
13
|
edsl/conjure/AgentConstructionMixin.py,sha256=qLLYJH02HotVwBUYzaHs4QW0t5nsC3NX15qxQLzEwLI,5702
|
15
14
|
edsl/conjure/Conjure.py,sha256=KBmF3d6EjzTI5f-j_cZBowxWQx7jZqezHgfPMkh-h8M,1884
|
16
|
-
edsl/conjure/InputData.py,sha256=
|
15
|
+
edsl/conjure/InputData.py,sha256=y2MOf0smzgG-KtDyL8PLygivspIXZuAaAJW_yzpTqHQ,20750
|
17
16
|
edsl/conjure/InputDataCSV.py,sha256=m4hHSQogxt7LNcGNxcGRkrbdGy8pIQu5KvXhIEt9i6k,1684
|
18
17
|
edsl/conjure/InputDataMixinQuestionStats.py,sha256=Jav5pqYCLSQ1pAbGV8O9VCBu0vL8Q6pteSEhRKrONuw,6256
|
19
18
|
edsl/conjure/InputDataPyRead.py,sha256=phGmzVi06jdbcxgngAp_lEawGkJr5dAC2B4ho5IrAy4,3064
|
@@ -32,12 +31,12 @@ edsl/conversation/car_buying.py,sha256=70nCXQNCc2kR-NBY6YOPHfkuZ5g7nww2r4GwlYosV
|
|
32
31
|
edsl/conversation/mug_negotiation.py,sha256=mjvAqErD4AjN3G2za2c-X-3axOShW-zAJUeiJqTxVPA,2616
|
33
32
|
edsl/conversation/next_speaker_utilities.py,sha256=bqr5JglCd6bdLc9IZ5zGOAsmN2F4ERiubSMYvZIG7qk,3629
|
34
33
|
edsl/coop/__init__.py,sha256=4iZCwJSzJVyjBYk8ggGxY2kZjq9dXVT1jhyPDNyew4I,115
|
35
|
-
edsl/coop/coop.py,sha256=
|
36
|
-
edsl/coop/utils.py,sha256=
|
37
|
-
edsl/data/Cache.py,sha256=
|
34
|
+
edsl/coop/coop.py,sha256=JvRgnZqQfuO-2idiW3etAk2RNZ9yaAzmLMYt8KZ0qhU,24840
|
35
|
+
edsl/coop/utils.py,sha256=OVfVUIBCH5ATj0yFLe0Ui0_KYGwwzWsVHqyavVVaN_w,3773
|
36
|
+
edsl/data/Cache.py,sha256=f7tuzuA7T4C9qp8BP45UamcmJbvH8RGClr9lbf7PS1s,14880
|
38
37
|
edsl/data/CacheEntry.py,sha256=AnZBUautQc19KhE6NkI87U_P9wDZI2eu-8B1XopPTOI,7235
|
39
38
|
edsl/data/CacheHandler.py,sha256=DTr8nJnbl_SidhsDetqbshu1DV-njPFiPPosUWTIBok,4789
|
40
|
-
edsl/data/SQLiteDict.py,sha256=
|
39
|
+
edsl/data/SQLiteDict.py,sha256=2asiSJyQxWmIhbWuuPzWWOr3PZBRSKsJubNN7nrCdq4,8803
|
41
40
|
edsl/data/__init__.py,sha256=KBNGGEuGHq--D-TlpAQmvv_If906dJc1Gsy028zOx78,170
|
42
41
|
edsl/data/orm.py,sha256=Jz6rvw5SrlxwysTL0QI9r68EflKxeEBmf6j6himHDS8,238
|
43
42
|
edsl/data_transfer_models.py,sha256=17A3vpxTkJ2DnV8ggTPxwPzwlQAEYn94U4qiBv8hV3o,1026
|
@@ -65,44 +64,44 @@ edsl/inference_services/models_available_cache.py,sha256=ZT2pBGxJqTgwynthu-SqBjv
|
|
65
64
|
edsl/inference_services/rate_limits_cache.py,sha256=HYslviz7mxF9U4CUTPAkoyBsiXjSju-YCp4HHir6e34,1398
|
66
65
|
edsl/inference_services/registry.py,sha256=-Yz86do-KZraunIrziVs9b95EbY-__JUnQb5Ulni7KI,483
|
67
66
|
edsl/inference_services/write_available.py,sha256=NNwhATlaMp8IYY635MSx-oYxt5X15acjAfaqYCo_I1Y,285
|
68
|
-
edsl/jobs/Answers.py,sha256=
|
69
|
-
edsl/jobs/Jobs.py,sha256=
|
67
|
+
edsl/jobs/Answers.py,sha256=mtSjlRbVJbqZKA6DBngEwDxIfloRAKkrsTRriMTPRD4,1493
|
68
|
+
edsl/jobs/Jobs.py,sha256=zRJMeqeOSrkZrVvoc3KUw1dXW6C30imtVCWKTglpxZw,27061
|
70
69
|
edsl/jobs/__init__.py,sha256=aKuAyd_GoalGj-k7djOoVwEbFUE2XLPlikXaA1_8yAg,32
|
71
70
|
edsl/jobs/buckets/BucketCollection.py,sha256=LA8DBVwMdeTFCbSDI0S2cDzfi_Qo6kRizwrG64tE8S4,1844
|
72
|
-
edsl/jobs/buckets/ModelBuckets.py,sha256=
|
73
|
-
edsl/jobs/buckets/TokenBucket.py,sha256=
|
74
|
-
edsl/jobs/interviews/Interview.py,sha256=
|
71
|
+
edsl/jobs/buckets/ModelBuckets.py,sha256=1_WPi1wV5k8kO9TuLEA7tDt9rF_myaC5XKyf4T0EmQ8,1969
|
72
|
+
edsl/jobs/buckets/TokenBucket.py,sha256=IfzhtrQ6i3LlJ_PHmFN-OLIWEqr9n-2_FLbE5-fethU,5213
|
73
|
+
edsl/jobs/interviews/Interview.py,sha256=3gsNjM761lUsM7GT8b64psSzjyWgko1cSuR89e7mZz4,9855
|
75
74
|
edsl/jobs/interviews/InterviewStatistic.py,sha256=hY5d2EkIJ96NilPpZAvZZzZoxLXM7ss3xx5MIcKtTPs,1856
|
76
75
|
edsl/jobs/interviews/InterviewStatisticsCollection.py,sha256=_ZZ0fnZBQiIywP9Q_wWjpWhlfcPe2cn32GKut10t5RI,788
|
77
76
|
edsl/jobs/interviews/InterviewStatusDictionary.py,sha256=MSyys4hOWe1d8gfsUvAPbcKrs8YiPnz8jpufBSJL7SU,2485
|
78
77
|
edsl/jobs/interviews/InterviewStatusLog.py,sha256=6u0F8gf5tha39VQL-IK_QPkCsQAYVOx_IesX7TDDX_A,3252
|
79
|
-
edsl/jobs/interviews/InterviewStatusMixin.py,sha256=
|
80
|
-
edsl/jobs/interviews/InterviewTaskBuildingMixin.py,sha256=
|
78
|
+
edsl/jobs/interviews/InterviewStatusMixin.py,sha256=VV0Pel-crUsLoGpTifeIIkXsLGj0bfuO--UtpRnH-dU,1251
|
79
|
+
edsl/jobs/interviews/InterviewTaskBuildingMixin.py,sha256=0RabzKbMwc5Calr94bHDtzFqi8xQ1l2-DYHApEo5kEw,11606
|
81
80
|
edsl/jobs/interviews/ReportErrors.py,sha256=RSzDU2rWwtjfztj7sqaMab0quCiY-X2bG3AEOxhTim8,1745
|
82
81
|
edsl/jobs/interviews/interview_exception_tracking.py,sha256=tIcX92udnkE5fcM5_WXjRF9xgTq2P0uaDXxZf3NQGG0,3271
|
83
82
|
edsl/jobs/interviews/interview_status_enum.py,sha256=KJ-1yLAHdX-p8TiFnM0M3v1tnBwkq4aMCuBX6-ytrI8,229
|
84
83
|
edsl/jobs/interviews/retry_management.py,sha256=9Efn4B3aV45vbocnF6J5WQt88i2FgFjoi5ALzGUukEE,1375
|
85
|
-
edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=
|
84
|
+
edsl/jobs/runners/JobsRunnerAsyncio.py,sha256=hAsi7UJ8hV5K2a96RNIVzhjsYqYqAQp8uySYIzy6eBk,11843
|
86
85
|
edsl/jobs/runners/JobsRunnerStatusData.py,sha256=-mxcmX0a38GGO9DQ-ItTmj6mvCUk5uC-UudT77lXTG4,10327
|
87
86
|
edsl/jobs/runners/JobsRunnerStatusMixin.py,sha256=yxnXuOovwHgfDokNuluH_qulBcM0gCcbpCQibqVKXFI,3137
|
88
87
|
edsl/jobs/tasks/QuestionTaskCreator.py,sha256=SXO_ITNPAXh9oBvCh8rcbH9ln0VjOyuM_i2IrRDHnIo,10231
|
89
88
|
edsl/jobs/tasks/TaskCreators.py,sha256=DbCt5BzJ0CsMSquqLyLdk8el031Wst7vCszVW5EltX8,2418
|
90
|
-
edsl/jobs/tasks/TaskHistory.py,sha256=
|
89
|
+
edsl/jobs/tasks/TaskHistory.py,sha256=Dqzk-IQUMvf0U5TJQFXw7SxJbwPEkKtrB7QaU5HaF_k,10927
|
91
90
|
edsl/jobs/tasks/TaskStatusLog.py,sha256=bqH36a32F12fjX-M-4lNOhHaK2-WLFzKE-r0PxZPRjI,546
|
92
91
|
edsl/jobs/tasks/task_management.py,sha256=KMToZuXzMlnHRHUF_VHL0-lHMTGhklf2GHVuwEEHtzA,301
|
93
92
|
edsl/jobs/tasks/task_status_enum.py,sha256=DOyrz61YlIS8R1W7izJNphcLrJ7I_ReUlfdRmk23h0Q,5333
|
94
93
|
edsl/jobs/tokens/InterviewTokenUsage.py,sha256=u_6-IHpGFwZ6qMEXr24-jyLVUSSp4dSs_4iAZsBv7O4,1100
|
95
94
|
edsl/jobs/tokens/TokenUsage.py,sha256=odj2-wDNEbHl9noyFAQ0DSKV0D9cv3aDOpmXufKZ8O4,1323
|
96
|
-
edsl/language_models/LanguageModel.py,sha256=
|
97
|
-
edsl/language_models/ModelList.py,sha256=
|
95
|
+
edsl/language_models/LanguageModel.py,sha256=QoltKz6IEK59jKPG3dEI1Si5_9UgqzIAmdTLz5q54nU,19039
|
96
|
+
edsl/language_models/ModelList.py,sha256=NAGDfr2bV52y3ITE0_5PbyJYrh-fp7dOu2IWiVawhGQ,2677
|
98
97
|
edsl/language_models/RegisterLanguageModelsMeta.py,sha256=2bvWrVau2BRo-Bb1aO-QATH8xxuW_tF7NmqBMGDOfSg,8191
|
99
98
|
edsl/language_models/__init__.py,sha256=bvY7Gy6VkX1gSbNkRbGPS-M1kUnb0EohL0FSagaEaTs,109
|
100
99
|
edsl/language_models/registry.py,sha256=J7blAbRFHxr2nWSoe61G4p-6kOgzUlKclJ55xVldKWc,3191
|
101
|
-
edsl/language_models/repair.py,sha256=
|
100
|
+
edsl/language_models/repair.py,sha256=6KenPSbbQuS7YAhwQPECX1gD6o5E4eqEmIlrUi9UmuM,5926
|
102
101
|
edsl/language_models/unused/ReplicateBase.py,sha256=J1oqf7mEyyKhRwNUomnptVqAsVFYCbS3iTW0EXpKtXo,3331
|
103
|
-
edsl/notebooks/Notebook.py,sha256=
|
102
|
+
edsl/notebooks/Notebook.py,sha256=ozsSfmmfVSF3-2CwpK51i8cARSjOOOEGvZ_gGhqIAzE,6045
|
104
103
|
edsl/notebooks/__init__.py,sha256=VNUA3nNq04slWNbYaNrzOhQJu3AZANpvBniyCJSzJ7U,45
|
105
|
-
edsl/prompts/Prompt.py,sha256=
|
104
|
+
edsl/prompts/Prompt.py,sha256=LIfM5RwnhyJFOAmVdd5GlgMtJNWcMjG0TszMTJfidFc,9554
|
106
105
|
edsl/prompts/QuestionInstructionsBase.py,sha256=xico6ob4cqWsHl-txj2RbY_4Ny5u9UqvIjmoTVgjUhk,348
|
107
106
|
edsl/prompts/__init__.py,sha256=Z0ywyJfnV0i-sR1SCdK4mHhgECT5cXpHVA-pKuBTifc,85
|
108
107
|
edsl/prompts/library/agent_instructions.py,sha256=_2kCDYvh3ZOF72VvcIH5jhmHjM6AAgQdkWrHvR52Yhg,1100
|
@@ -119,61 +118,58 @@ edsl/prompts/library/question_rank.py,sha256=WDgXyph0EKWJrSgsW2eqcx3xdU-WA1LEvB2
|
|
119
118
|
edsl/prompts/prompt_config.py,sha256=O3Y5EvBsCeKs9m9IjXiRXOcHWlWvQV0yqsNb2oSR1ow,974
|
120
119
|
edsl/prompts/registry.py,sha256=XOsqGsvNOmIG83jqoszqI72yNZkkszKR4FrEhwSzj_Q,8093
|
121
120
|
edsl/questions/AnswerValidatorMixin.py,sha256=U5i79HoEHpSoevgtx68TSg8a9tELq3R8xMtYyK1L7DQ,12106
|
122
|
-
edsl/questions/QuestionBase.py,sha256=
|
123
|
-
edsl/questions/QuestionBudget.py,sha256=
|
124
|
-
edsl/questions/QuestionCheckBox.py,sha256=
|
125
|
-
edsl/questions/QuestionExtract.py,sha256=
|
126
|
-
edsl/questions/QuestionFreeText.py,sha256=
|
127
|
-
edsl/questions/QuestionFunctional.py,sha256=
|
128
|
-
edsl/questions/QuestionList.py,sha256=
|
129
|
-
edsl/questions/QuestionMultipleChoice.py,sha256=
|
130
|
-
edsl/questions/QuestionNumerical.py,sha256=
|
131
|
-
edsl/questions/QuestionRank.py,sha256=
|
121
|
+
edsl/questions/QuestionBase.py,sha256=5EbRKXnQIt0TYSHzQcyAP2VV5OV5rrxPYTnDImNg37o,17928
|
122
|
+
edsl/questions/QuestionBudget.py,sha256=JLp_vsdrJO7j6e9oztYvgZzrI-MzXNeWkYp5-H2S-gQ,6170
|
123
|
+
edsl/questions/QuestionCheckBox.py,sha256=8myLLvSz7jNYuuarUnscGYAUVYOhLLo-XwGUv_YfTSk,6076
|
124
|
+
edsl/questions/QuestionExtract.py,sha256=F3_gzXAYYSNOOA-SMwmWYLEZB3rxAVS9Er4GoS9B_zs,3975
|
125
|
+
edsl/questions/QuestionFreeText.py,sha256=_F-KY84LNQDX4zF9HPysr6ZwPWITdAXWdgYJTQ_AyKI,3188
|
126
|
+
edsl/questions/QuestionFunctional.py,sha256=zm1g3SAL6dt2NMq2QN6nYAsa8HH2RcjbrL6FW5-J3WE,4130
|
127
|
+
edsl/questions/QuestionList.py,sha256=ZWPxXIL78LqBp-wW7rFDxzrfCYKL8PctiLj7X2qBI9o,4067
|
128
|
+
edsl/questions/QuestionMultipleChoice.py,sha256=YTyhFf90qQvfSibj8rasiBo5bZ__A8vCcZtw-DaobyI,4408
|
129
|
+
edsl/questions/QuestionNumerical.py,sha256=yCIL0-3lTj1ofZt1Owtj0mgOIKabsQOwkAZ-G_4uevs,3645
|
130
|
+
edsl/questions/QuestionRank.py,sha256=TAteKtclhvr4fYCWebMDR3DbBU6uFPOFhr2t-wq9AJU,5873
|
132
131
|
edsl/questions/RegisterQuestionsMeta.py,sha256=unON0CKpW-mveyhg9V3_BF_GYYwytMYP9h2ZZPetVNM,1994
|
133
132
|
edsl/questions/SimpleAskMixin.py,sha256=YRLiHA6TPMKyLWvdAi7Mfnxcqtw7Kem6tH28YNb8n4U,2227
|
134
|
-
edsl/questions/__init__.py,sha256=
|
133
|
+
edsl/questions/__init__.py,sha256=FiHC6mKS6YPcXeuJqW6ixb78dMI8dzrvuH1cEMOIOlc,1153
|
135
134
|
edsl/questions/compose_questions.py,sha256=ZcLkwNaofk-o0-skGXEDGZAj6DumOhVhyIUjqEnKrbg,3380
|
136
135
|
edsl/questions/derived/QuestionLikertFive.py,sha256=zKkjKI3HSt9ZGyBBNgXNsfXZ7gOoOknidLDPgMN_PcI,2475
|
137
136
|
edsl/questions/derived/QuestionLinearScale.py,sha256=7tybIaMaDTMkTFC6CymusW69so-zf5jUn8Aqf5pw__Y,2673
|
138
137
|
edsl/questions/derived/QuestionTopK.py,sha256=TouXKZt_h6Jd-2rAjkEOCJOzzei4Wa-3hjYq9CLxWws,2744
|
139
138
|
edsl/questions/derived/QuestionYesNo.py,sha256=KtMGuAPYWv-7-9WGa0fIS2UBxf6KKjFpuTk_h8FPZbg,2076
|
140
139
|
edsl/questions/derived/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
141
|
-
edsl/questions/descriptors.py,sha256=
|
142
|
-
edsl/questions/question_registry.py,sha256=
|
143
|
-
edsl/questions/settings.py,sha256=
|
144
|
-
edsl/results/Dataset.py,sha256=
|
145
|
-
edsl/results/
|
146
|
-
edsl/results/
|
147
|
-
edsl/results/
|
148
|
-
edsl/results/
|
149
|
-
edsl/results/ResultsExportMixin.py,sha256=XizBsPNxziyffirMA4kS7UHpYM1WIE4s1K-B7TqTfDw,1266
|
140
|
+
edsl/questions/descriptors.py,sha256=Fjaz8Kz-jMJ4B3VJ9yet9ixFQynLAYkjcXIRsmTVCG4,13283
|
141
|
+
edsl/questions/question_registry.py,sha256=7JvkwFzItwNTXjMwbdfpbZQT_WAXOBxjlSJGCIJ-c1c,5546
|
142
|
+
edsl/questions/settings.py,sha256=Qk2imv_7N8uFGLoTEr163lbaKPbD2Begd17Hbh4GZKA,290
|
143
|
+
edsl/results/Dataset.py,sha256=v_6e1khpfs5Ft-b7GgTKhitr4l9sys4rb_4z-dOdj68,7737
|
144
|
+
edsl/results/Result.py,sha256=IvUFq23LwlBP7JN1QDap1fPTTIPUC0QlYEE4lsiKRqI,13913
|
145
|
+
edsl/results/Results.py,sha256=r13Rog0bNwHbV5Uat6YKTf-6zH2_sBqLbdsbfnV9zAE,34575
|
146
|
+
edsl/results/ResultsDBMixin.py,sha256=Dv34yBuF5tkeoYnzbN1YwuBwKh1T-Y77YOYcWlu-GLY,7883
|
147
|
+
edsl/results/ResultsExportMixin.py,sha256=KQ1GE2JDzrnl4XkyAGnCdgiFtF_mZrhFNDfkNPg_8C8,20501
|
150
148
|
edsl/results/ResultsFetchMixin.py,sha256=VEa0TKDcXbnTinSKs9YaE4WjOSLmlp9Po1_9kklFvSo,848
|
151
|
-
edsl/results/ResultsGGMixin.py,sha256=
|
152
|
-
edsl/results/ResultsToolsMixin.py,sha256=
|
149
|
+
edsl/results/ResultsGGMixin.py,sha256=h5OBPdgUeNg6I_GizOvUvBe7CPz8wrZV9N7dk8W3gkU,4347
|
150
|
+
edsl/results/ResultsToolsMixin.py,sha256=EMfbhw4CuYVEJZ2xPJcCcaW0Dr-r9wpNJ0X-uF8UgS4,2939
|
153
151
|
edsl/results/__init__.py,sha256=2YcyiVtXi-3vIV0ZzOy1PqBLm2gaziufJVi4fdNrAt8,80
|
154
|
-
edsl/scenarios/
|
155
|
-
edsl/scenarios/Scenario.py,sha256=KCMze1PL0uxLMrqaneEXZBDc65q7AUV71zZIEmeGSVo,14766
|
152
|
+
edsl/scenarios/Scenario.py,sha256=C2HPOcP8YypcWffay6AA4cSPlD35xeMywiDomLCRHcY,14768
|
156
153
|
edsl/scenarios/ScenarioHtmlMixin.py,sha256=EmugmbPJYW5eZS30rM6pDMDQD9yrrvHjmgZWB1qBfq4,1882
|
157
154
|
edsl/scenarios/ScenarioImageMixin.py,sha256=VJ5FqyPrL5-ieORlWMpnjmOAFIau8QFZCIZyEBKgb6I,3530
|
158
|
-
edsl/scenarios/ScenarioList.py,sha256=
|
159
|
-
edsl/scenarios/
|
160
|
-
edsl/scenarios/
|
161
|
-
edsl/scenarios/__init__.py,sha256=KRwZCLf2R0qyJvv1NGbd8M51Bt6Ia6Iylg-Xq_2Fa6M,98
|
155
|
+
edsl/scenarios/ScenarioList.py,sha256=0yH58tbcKJxflsQVcOwh98uU_pzW3w3AGQdKHzftdZk,17895
|
156
|
+
edsl/scenarios/ScenarioListPdfMixin.py,sha256=0xV033SMygr_ObamXwjbzfxEQ0zFEwAJ1w7Wq1ejjUY,3719
|
157
|
+
edsl/scenarios/__init__.py,sha256=a2CIYQWh9bLeYY4qBJBz7ui7RfxpVd0WlYDf8TaT2D0,45
|
162
158
|
edsl/shared.py,sha256=lgLa-mCk2flIhxXarXLtfXZjXG_6XHhC2A3O8yRTjXc,20
|
163
159
|
edsl/study/ObjectEntry.py,sha256=e3xRPH8wCN8Pum5HZsQRYgnSoauSvjXunIEH79wu5A8,5788
|
164
160
|
edsl/study/ProofOfWork.py,sha256=FaqYtLgeiTEQXWKukPgPUTWMcIN5t1FR7h7Re8QEtgc,3433
|
165
161
|
edsl/study/SnapShot.py,sha256=-5zoP4uTvnqtu3zRNMD-fKsNAVYX9psoKRADfotsF9E,2439
|
166
|
-
edsl/study/Study.py,sha256=
|
162
|
+
edsl/study/Study.py,sha256=vbivUuESbK4_myMsLdW02hK9BmFXTMrdg-bUyAy1V8I,17080
|
167
163
|
edsl/study/__init__.py,sha256=YAvPLTPG3hK_eN9Ar3d1_d-E3laXpSya879A25-JAxU,170
|
168
164
|
edsl/surveys/DAG.py,sha256=ozQuHo9ZQ8Eet5nDXtp7rFpiSocvvfxIHtyTnztvodg,2380
|
169
165
|
edsl/surveys/Memory.py,sha256=-ikOtkkQldGB_BkPCW3o7AYwV5B_pIwlREw7aVCSHaQ,1113
|
170
|
-
edsl/surveys/MemoryPlan.py,sha256=
|
166
|
+
edsl/surveys/MemoryPlan.py,sha256=k65OP2oozG_d99OpkBqXXWH5iXxS-ois3hTf8_1iuj8,7786
|
171
167
|
edsl/surveys/Rule.py,sha256=ddZyZSObs4gsKtFSmcXkPigXDX8rrh1NFvAplP02TcA,11092
|
172
168
|
edsl/surveys/RuleCollection.py,sha256=sN7aYDQJG3HmE-WxohgpctcQbHewjwE6NAqEVTxvFP8,13359
|
173
|
-
edsl/surveys/Survey.py,sha256=
|
169
|
+
edsl/surveys/Survey.py,sha256=Ao1AJpUCebmx30vLpNvUf524ENrmUzddiyfOiypbkV4,45526
|
174
170
|
edsl/surveys/SurveyCSS.py,sha256=NjJezs2sTlgFprN6IukjGKwNYmNdXnLjzV2w5K4z4RI,8415
|
175
|
-
edsl/surveys/SurveyExportMixin.py,sha256=
|
176
|
-
edsl/surveys/SurveyFlowVisualizationMixin.py,sha256=
|
171
|
+
edsl/surveys/SurveyExportMixin.py,sha256=jVdHVrsXZrKLX9rNsZkWU61kXiUUjlonK_CGqJ7rhbI,6537
|
172
|
+
edsl/surveys/SurveyFlowVisualizationMixin.py,sha256=iPjtGeoVK9ObMVDxrLf4EMgbPl95LZ_IzVxgkk9B-WQ,3918
|
177
173
|
edsl/surveys/__init__.py,sha256=vjMYVlP95fHVqqw2FfKXRuYbTArZkZr1nK4FnXzZWzs,129
|
178
174
|
edsl/surveys/base.py,sha256=n5PBx0BF0powzBXCsufpUekfNK_9huf3rohtU1mMCq0,1001
|
179
175
|
edsl/surveys/descriptors.py,sha256=3B-hBVvGpLlVBCyOnPuxkLjesvpr0QIuATbggp_MJ7o,2076
|
@@ -181,10 +177,10 @@ edsl/tools/__init__.py,sha256=4iRiX1K0Yh8RGwlUBuzipvFfRrofKqCRQ0SzNK_2oiQ,41
|
|
181
177
|
edsl/tools/clusters.py,sha256=uvDN76bfHIHS-ykB2iioXu0gKeP_UyD7Q9ee67w_fV4,6132
|
182
178
|
edsl/tools/embeddings.py,sha256=-mHqApiFbGzj_2Cr_VVl_7XiBBDyPB5-6ZO7IsXvaig,677
|
183
179
|
edsl/tools/embeddings_plotting.py,sha256=fznAqLnjF_K8PkJy1C4hBRObm3f8ebDIxQzrqRXlEJM,3564
|
184
|
-
edsl/tools/plotting.py,sha256=
|
180
|
+
edsl/tools/plotting.py,sha256=fzDw5IebaKeYH70qMkoirPx8rRah_49WO9RQpl_It5c,3093
|
185
181
|
edsl/tools/summarize.py,sha256=YcdB0IjZn92qv2zVJuxsHfXou810APWYKeaHknsATqM,656
|
186
182
|
edsl/utilities/SystemInfo.py,sha256=qTP_aKwECPxtTnbEjJ7F1QqKU9U3rcEEbppg2ilQGuY,792
|
187
|
-
edsl/utilities/__init__.py,sha256=
|
183
|
+
edsl/utilities/__init__.py,sha256=2AlIXF-iMS-vZyF8lUY7eGO671ONE4YCvX7iUfi2RPA,502
|
188
184
|
edsl/utilities/ast_utilities.py,sha256=49KDDu-PHYpzDN5cCaDf-ReQH-1dzjT5EG3WVSa8THk,868
|
189
185
|
edsl/utilities/data/Registry.py,sha256=q2DKc7CpG_7l47MxxsSi6DJOs4p1Z3qNx7PV-v8CUOE,176
|
190
186
|
edsl/utilities/data/__init__.py,sha256=pDjGnzC11q4Za8qX5zcg6plcQ_8Qjpb-sAKPwOlKmCY,62
|
@@ -193,11 +189,12 @@ edsl/utilities/decorators.py,sha256=rlTSMItwmWUxHQBIEUDxX3lFzgtiT8PnfNavakuf-2M,
|
|
193
189
|
edsl/utilities/gcp_bucket/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
194
190
|
edsl/utilities/gcp_bucket/cloud_storage.py,sha256=dStHsG181YP9ALW-bkyO-sgMWuLV5aaLsnsCOVD8jJw,3472
|
195
191
|
edsl/utilities/gcp_bucket/simple_example.py,sha256=pR_IH_Y640_-YnEyNpE7V_1MtBFC9nD3dg2NdSVcuXY,251
|
196
|
-
edsl/utilities/interface.py,sha256=
|
192
|
+
edsl/utilities/interface.py,sha256=U8iScZb4jB1npPwbndpjCove59ow2cbAST4fl-46FdI,19160
|
197
193
|
edsl/utilities/repair_functions.py,sha256=tftmklAqam6LOQQu_-9U44N-llycffhW8LfO63vBmNw,929
|
198
194
|
edsl/utilities/restricted_python.py,sha256=5-_zUhrNbos7pLhDl9nr8d24auRlquR6w-vKkmNjPiA,2060
|
199
|
-
edsl/utilities/utilities.py,sha256=
|
200
|
-
edsl-0.1.29.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
|
201
|
-
edsl-0.1.29.dist-info/METADATA,sha256
|
202
|
-
edsl-0.1.29.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
203
|
-
edsl-0.1.29.dist-info/
|
195
|
+
edsl/utilities/utilities.py,sha256=7LOMa1ahhi2t3SRwEs3VjroAj0A-5Q-Cn83v0HESADQ,10113
|
196
|
+
edsl-0.1.29.dev2.dist-info/LICENSE,sha256=_qszBDs8KHShVYcYzdMz3HNMtH-fKN_p5zjoVAVumFc,1111
|
197
|
+
edsl-0.1.29.dev2.dist-info/METADATA,sha256=75dWNrJWJsMHhLyd_k0dyMrjUiDVwGT4krm9iXdnzGM,4102
|
198
|
+
edsl-0.1.29.dev2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
199
|
+
edsl-0.1.29.dev2.dist-info/entry_points.txt,sha256=yqJs04hJLRusoLzIYXGv8tl4TH__0D5SDRwLKV9IJCg,56
|
200
|
+
edsl-0.1.29.dev2.dist-info/RECORD,,
|
edsl/base/Base.py
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
"""Base class for all classes in the package. It provides rich printing and persistence of objects."""
|
2
|
-
|
3
|
-
from abc import ABC, abstractmethod, ABCMeta
|
4
|
-
import gzip
|
5
|
-
import io
|
6
|
-
import json
|
7
|
-
from typing import Any, Optional, Union
|
8
|
-
from uuid import UUID
|
9
|
-
from IPython.display import display
|
10
|
-
from rich.console import Console
|
11
|
-
|
12
|
-
|
13
|
-
class RichPrintingMixin:
|
14
|
-
"""Mixin for rich printing and persistence of objects."""
|
15
|
-
|
16
|
-
def _for_console(self):
|
17
|
-
"""Return a string representation of the object for console printing."""
|
18
|
-
with io.StringIO() as buf:
|
19
|
-
console = Console(file=buf, record=True)
|
20
|
-
table = self.rich_print()
|
21
|
-
console.print(table)
|
22
|
-
return console.export_text()
|
23
|
-
|
24
|
-
def __str__(self):
|
25
|
-
"""Return a string representation of the object for console printing."""
|
26
|
-
return self._for_console()
|
27
|
-
|
28
|
-
def print(self):
|
29
|
-
"""Print the object to the console."""
|
30
|
-
from edsl.utilities.utilities import is_notebook
|
31
|
-
|
32
|
-
if is_notebook():
|
33
|
-
display(self.rich_print())
|
34
|
-
else:
|
35
|
-
from rich.console import Console
|
36
|
-
|
37
|
-
console = Console()
|
38
|
-
console.print(self.rich_print())
|
39
|
-
|
40
|
-
|
41
|
-
class PersistenceMixin:
|
42
|
-
"""Mixin for saving and loading objects to and from files."""
|
43
|
-
|
44
|
-
def push(
|
45
|
-
self,
|
46
|
-
description: Optional[str] = None,
|
47
|
-
visibility: Optional[str] = "unlisted",
|
48
|
-
):
|
49
|
-
"""Post the object to coop."""
|
50
|
-
from edsl.coop import Coop
|
51
|
-
|
52
|
-
c = Coop()
|
53
|
-
return c.create(self, description, visibility)
|
54
|
-
|
55
|
-
@classmethod
|
56
|
-
def pull(cls, id_or_url: Union[str, UUID], exec_profile=None):
|
57
|
-
"""Pull the object from coop."""
|
58
|
-
from edsl.coop import Coop
|
59
|
-
|
60
|
-
if id_or_url.startswith("http"):
|
61
|
-
uuid_value = id_or_url.split("/")[-1]
|
62
|
-
else:
|
63
|
-
uuid_value = id_or_url
|
64
|
-
|
65
|
-
c = Coop()
|
66
|
-
|
67
|
-
return c._get_base(cls, uuid_value, exec_profile=exec_profile)
|
68
|
-
|
69
|
-
@classmethod
|
70
|
-
def delete(cls, id_or_url: Union[str, UUID]):
|
71
|
-
"""Delete the object from coop."""
|
72
|
-
from edsl.coop import Coop
|
73
|
-
|
74
|
-
c = Coop()
|
75
|
-
return c._delete_base(cls, id_or_url)
|
76
|
-
|
77
|
-
@classmethod
|
78
|
-
def patch(
|
79
|
-
cls,
|
80
|
-
id_or_url: Union[str, UUID],
|
81
|
-
description: Optional[str] = None,
|
82
|
-
value: Optional[Any] = None,
|
83
|
-
visibility: Optional[str] = None,
|
84
|
-
):
|
85
|
-
"""
|
86
|
-
Patch an uploaded objects attributes.
|
87
|
-
- `description` changes the description of the object on Coop
|
88
|
-
- `value` changes the value of the object on Coop. **has to be an EDSL object**
|
89
|
-
- `visibility` changes the visibility of the object on Coop
|
90
|
-
"""
|
91
|
-
from edsl.coop import Coop
|
92
|
-
|
93
|
-
c = Coop()
|
94
|
-
return c._patch_base(cls, id_or_url, description, value, visibility)
|
95
|
-
|
96
|
-
@classmethod
|
97
|
-
def search(cls, query):
|
98
|
-
"""Search for objects on coop."""
|
99
|
-
from edsl.coop import Coop
|
100
|
-
|
101
|
-
c = Coop()
|
102
|
-
return c.search(cls, query)
|
103
|
-
|
104
|
-
def save(self, filename, compress=True):
|
105
|
-
"""Save the object to a file as zippped JSON.
|
106
|
-
|
107
|
-
>>> obj.save("obj.json.gz")
|
108
|
-
|
109
|
-
"""
|
110
|
-
if filename.endswith("json.gz"):
|
111
|
-
import warnings
|
112
|
-
|
113
|
-
warnings.warn(
|
114
|
-
"Do not apply the file extensions. The filename should not end with 'json.gz'."
|
115
|
-
)
|
116
|
-
filename = filename[:-7]
|
117
|
-
if filename.endswith("json"):
|
118
|
-
filename = filename[:-4]
|
119
|
-
warnings.warn(
|
120
|
-
"Do not apply the file extensions. The filename should not end with 'json'."
|
121
|
-
)
|
122
|
-
|
123
|
-
if compress:
|
124
|
-
with gzip.open(filename + ".json.gz", "wb") as f:
|
125
|
-
f.write(json.dumps(self.to_dict()).encode("utf-8"))
|
126
|
-
else:
|
127
|
-
with open(filename + ".json", "w") as f:
|
128
|
-
f.write(json.dumps(self.to_dict()))
|
129
|
-
|
130
|
-
@staticmethod
|
131
|
-
def open_compressed_file(filename):
|
132
|
-
with gzip.open(filename, "rb") as f:
|
133
|
-
file_contents = f.read()
|
134
|
-
file_contents_decoded = file_contents.decode("utf-8")
|
135
|
-
d = json.loads(file_contents_decoded)
|
136
|
-
return d
|
137
|
-
|
138
|
-
@staticmethod
|
139
|
-
def open_regular_file(filename):
|
140
|
-
with open(filename, "r") as f:
|
141
|
-
d = json.loads(f.read())
|
142
|
-
return d
|
143
|
-
|
144
|
-
@classmethod
|
145
|
-
def load(cls, filename):
|
146
|
-
"""Load the object from a file.
|
147
|
-
|
148
|
-
>>> obj = cls.load("obj.json.gz")
|
149
|
-
|
150
|
-
"""
|
151
|
-
|
152
|
-
if filename.endswith("json.gz"):
|
153
|
-
d = cls.open_compressed_file(filename)
|
154
|
-
elif filename.endswith("json"):
|
155
|
-
d = cls.open_regular_file(filename)
|
156
|
-
else:
|
157
|
-
try:
|
158
|
-
d = cls.open_compressed_file(filename)
|
159
|
-
except:
|
160
|
-
d = cls.open_regular_file(filename)
|
161
|
-
finally:
|
162
|
-
raise ValueError("File must be a json or json.gz file")
|
163
|
-
|
164
|
-
return cls.from_dict(d)
|
165
|
-
|
166
|
-
|
167
|
-
class RegisterSubclassesMeta(ABCMeta):
|
168
|
-
"""Metaclass for registering subclasses."""
|
169
|
-
|
170
|
-
_registry = {}
|
171
|
-
|
172
|
-
def __init__(cls, name, bases, nmspc):
|
173
|
-
"""Register the class in the registry upon creation."""
|
174
|
-
super(RegisterSubclassesMeta, cls).__init__(name, bases, nmspc)
|
175
|
-
if cls.__name__ != "Base":
|
176
|
-
RegisterSubclassesMeta._registry[cls.__name__] = cls
|
177
|
-
|
178
|
-
@staticmethod
|
179
|
-
def get_registry():
|
180
|
-
"""Return the registry of subclasses."""
|
181
|
-
return dict(RegisterSubclassesMeta._registry)
|
182
|
-
|
183
|
-
|
184
|
-
class DiffMethodsMixin:
|
185
|
-
def __sub__(self, other):
|
186
|
-
"""Return the difference between two objects."""
|
187
|
-
from edsl.BaseDiff import BaseDiff
|
188
|
-
|
189
|
-
return BaseDiff(self, other)
|
190
|
-
|
191
|
-
|
192
|
-
class Base(
|
193
|
-
RichPrintingMixin,
|
194
|
-
PersistenceMixin,
|
195
|
-
DiffMethodsMixin,
|
196
|
-
ABC,
|
197
|
-
metaclass=RegisterSubclassesMeta,
|
198
|
-
):
|
199
|
-
"""Base class for all classes in the package."""
|
200
|
-
|
201
|
-
# def __getitem__(self, key):
|
202
|
-
# return getattr(self, key)
|
203
|
-
|
204
|
-
# @abstractmethod
|
205
|
-
# def _repr_html_(self) -> str:
|
206
|
-
# raise NotImplementedError("This method is not implemented yet.")
|
207
|
-
|
208
|
-
# @abstractmethod
|
209
|
-
# def _repr_(self) -> str:
|
210
|
-
# raise NotImplementedError("This method is not implemented yet.")
|
211
|
-
|
212
|
-
def keys(self):
|
213
|
-
"""Return the keys of the object."""
|
214
|
-
_keys = list(self.to_dict().keys())
|
215
|
-
if "edsl_version" in _keys:
|
216
|
-
_keys.remove("edsl_version")
|
217
|
-
if "edsl_class_name" in _keys:
|
218
|
-
_keys.remove("edsl_class_name")
|
219
|
-
return _keys
|
220
|
-
|
221
|
-
def values(self):
|
222
|
-
"""Return the values of the object."""
|
223
|
-
data = self.to_dict()
|
224
|
-
keys = self.keys()
|
225
|
-
return {data[key] for key in keys}
|
226
|
-
|
227
|
-
def _repr_html_(self):
|
228
|
-
from edsl.utilities.utilities import data_to_html
|
229
|
-
|
230
|
-
return data_to_html(self.to_dict())
|
231
|
-
|
232
|
-
# def html(self):
|
233
|
-
# html_string = self._repr_html_()
|
234
|
-
# import tempfile
|
235
|
-
# import webbrowser
|
236
|
-
|
237
|
-
# with tempfile.NamedTemporaryFile("w", delete=False, suffix=".html") as f:
|
238
|
-
# # print("Writing HTML to", f.name)
|
239
|
-
# f.write(html_string)
|
240
|
-
# webbrowser.open(f.name)
|
241
|
-
|
242
|
-
def __eq__(self, other):
|
243
|
-
"""Return whether two objects are equal."""
|
244
|
-
import inspect
|
245
|
-
|
246
|
-
if not isinstance(other, self.__class__):
|
247
|
-
return False
|
248
|
-
if "sort" in inspect.signature(self._to_dict).parameters:
|
249
|
-
return self._to_dict(sort=True) == other._to_dict(sort=True)
|
250
|
-
else:
|
251
|
-
return self._to_dict() == other._to_dict()
|
252
|
-
|
253
|
-
@abstractmethod
|
254
|
-
def example():
|
255
|
-
"""This method should be implemented by subclasses."""
|
256
|
-
raise NotImplementedError("This method is not implemented yet.")
|
257
|
-
|
258
|
-
@abstractmethod
|
259
|
-
def rich_print():
|
260
|
-
"""This method should be implemented by subclasses."""
|
261
|
-
raise NotImplementedError("This method is not implemented yet.")
|
262
|
-
|
263
|
-
@abstractmethod
|
264
|
-
def to_dict():
|
265
|
-
"""This method should be implemented by subclasses."""
|
266
|
-
raise NotImplementedError("This method is not implemented yet.")
|
267
|
-
|
268
|
-
@abstractmethod
|
269
|
-
def from_dict():
|
270
|
-
"""This method should be implemented by subclasses."""
|
271
|
-
raise NotImplementedError("This method is not implemented yet.")
|
272
|
-
|
273
|
-
@abstractmethod
|
274
|
-
def code():
|
275
|
-
"""This method should be implemented by subclasses."""
|
276
|
-
raise NotImplementedError("This method is not implemented yet.")
|
277
|
-
|
278
|
-
def show_methods(self, show_docstrings=True):
|
279
|
-
"""Show the methods of the object."""
|
280
|
-
public_methods_with_docstrings = [
|
281
|
-
(method, getattr(self, method).__doc__)
|
282
|
-
for method in dir(self)
|
283
|
-
if callable(getattr(self, method)) and not method.startswith("_")
|
284
|
-
]
|
285
|
-
if show_docstrings:
|
286
|
-
for method, documentation in public_methods_with_docstrings:
|
287
|
-
print(f"{method}: {documentation}")
|
288
|
-
else:
|
289
|
-
return [x[0] for x in public_methods_with_docstrings]
|