edsl 0.1.39.dev1__py3-none-any.whl → 0.1.39.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 +169 -116
- edsl/__init__.py +14 -6
- edsl/__version__.py +1 -1
- edsl/agents/Agent.py +358 -146
- edsl/agents/AgentList.py +211 -73
- edsl/agents/Invigilator.py +88 -36
- edsl/agents/InvigilatorBase.py +59 -70
- edsl/agents/PromptConstructor.py +117 -219
- edsl/agents/QuestionInstructionPromptBuilder.py +128 -0
- edsl/agents/QuestionOptionProcessor.py +172 -0
- edsl/agents/QuestionTemplateReplacementsBuilder.py +137 -0
- edsl/agents/__init__.py +0 -1
- edsl/agents/prompt_helpers.py +3 -3
- edsl/config.py +22 -2
- edsl/conversation/car_buying.py +2 -1
- edsl/coop/CoopFunctionsMixin.py +15 -0
- edsl/coop/ExpectedParrotKeyHandler.py +125 -0
- edsl/coop/PriceFetcher.py +1 -1
- edsl/coop/coop.py +104 -42
- edsl/coop/utils.py +14 -14
- edsl/data/Cache.py +21 -14
- edsl/data/CacheEntry.py +12 -15
- edsl/data/CacheHandler.py +33 -12
- edsl/data/__init__.py +4 -3
- edsl/data_transfer_models.py +2 -1
- edsl/enums.py +20 -0
- edsl/exceptions/__init__.py +50 -50
- edsl/exceptions/agents.py +12 -0
- edsl/exceptions/inference_services.py +5 -0
- edsl/exceptions/questions.py +24 -6
- edsl/exceptions/scenarios.py +7 -0
- edsl/inference_services/AnthropicService.py +0 -3
- edsl/inference_services/AvailableModelCacheHandler.py +184 -0
- edsl/inference_services/AvailableModelFetcher.py +209 -0
- edsl/inference_services/AwsBedrock.py +0 -2
- edsl/inference_services/AzureAI.py +0 -2
- edsl/inference_services/GoogleService.py +2 -11
- edsl/inference_services/InferenceServiceABC.py +18 -85
- edsl/inference_services/InferenceServicesCollection.py +105 -80
- edsl/inference_services/MistralAIService.py +0 -3
- edsl/inference_services/OpenAIService.py +1 -4
- edsl/inference_services/PerplexityService.py +0 -3
- edsl/inference_services/ServiceAvailability.py +135 -0
- edsl/inference_services/TestService.py +11 -8
- edsl/inference_services/data_structures.py +62 -0
- edsl/jobs/AnswerQuestionFunctionConstructor.py +188 -0
- edsl/jobs/Answers.py +1 -14
- edsl/jobs/FetchInvigilator.py +40 -0
- edsl/jobs/InterviewTaskManager.py +98 -0
- edsl/jobs/InterviewsConstructor.py +48 -0
- edsl/jobs/Jobs.py +102 -243
- edsl/jobs/JobsChecks.py +35 -10
- edsl/jobs/JobsComponentConstructor.py +189 -0
- edsl/jobs/JobsPrompts.py +5 -3
- edsl/jobs/JobsRemoteInferenceHandler.py +128 -80
- edsl/jobs/JobsRemoteInferenceLogger.py +239 -0
- edsl/jobs/RequestTokenEstimator.py +30 -0
- edsl/jobs/buckets/BucketCollection.py +44 -3
- edsl/jobs/buckets/TokenBucket.py +53 -21
- edsl/jobs/buckets/TokenBucketAPI.py +211 -0
- edsl/jobs/buckets/TokenBucketClient.py +191 -0
- edsl/jobs/decorators.py +35 -0
- edsl/jobs/interviews/Interview.py +77 -380
- edsl/jobs/jobs_status_enums.py +9 -0
- edsl/jobs/loggers/HTMLTableJobLogger.py +304 -0
- edsl/jobs/runners/JobsRunnerAsyncio.py +4 -49
- edsl/jobs/tasks/QuestionTaskCreator.py +21 -19
- edsl/jobs/tasks/TaskHistory.py +14 -15
- edsl/jobs/tasks/task_status_enum.py +0 -2
- edsl/language_models/ComputeCost.py +63 -0
- edsl/language_models/LanguageModel.py +137 -234
- edsl/language_models/ModelList.py +11 -13
- edsl/language_models/PriceManager.py +127 -0
- edsl/language_models/RawResponseHandler.py +106 -0
- edsl/language_models/ServiceDataSources.py +0 -0
- edsl/language_models/__init__.py +0 -1
- edsl/language_models/key_management/KeyLookup.py +63 -0
- edsl/language_models/key_management/KeyLookupBuilder.py +273 -0
- edsl/language_models/key_management/KeyLookupCollection.py +38 -0
- edsl/language_models/key_management/__init__.py +0 -0
- edsl/language_models/key_management/models.py +131 -0
- edsl/language_models/registry.py +49 -59
- edsl/language_models/repair.py +2 -2
- edsl/language_models/utilities.py +5 -4
- edsl/notebooks/Notebook.py +19 -14
- edsl/notebooks/NotebookToLaTeX.py +142 -0
- edsl/prompts/Prompt.py +29 -39
- edsl/questions/AnswerValidatorMixin.py +47 -2
- edsl/questions/ExceptionExplainer.py +77 -0
- edsl/questions/HTMLQuestion.py +103 -0
- edsl/questions/LoopProcessor.py +149 -0
- edsl/questions/QuestionBase.py +37 -192
- edsl/questions/QuestionBaseGenMixin.py +52 -48
- edsl/questions/QuestionBasePromptsMixin.py +7 -3
- edsl/questions/QuestionCheckBox.py +1 -1
- edsl/questions/QuestionExtract.py +1 -1
- edsl/questions/QuestionFreeText.py +1 -2
- edsl/questions/QuestionList.py +3 -5
- edsl/questions/QuestionMatrix.py +265 -0
- edsl/questions/QuestionMultipleChoice.py +66 -22
- edsl/questions/QuestionNumerical.py +1 -3
- edsl/questions/QuestionRank.py +6 -16
- edsl/questions/ResponseValidatorABC.py +37 -11
- edsl/questions/ResponseValidatorFactory.py +28 -0
- edsl/questions/SimpleAskMixin.py +4 -3
- edsl/questions/__init__.py +1 -0
- edsl/questions/derived/QuestionLinearScale.py +6 -3
- edsl/questions/derived/QuestionTopK.py +1 -1
- edsl/questions/descriptors.py +17 -3
- edsl/questions/question_registry.py +1 -1
- edsl/questions/templates/matrix/__init__.py +1 -0
- edsl/questions/templates/matrix/answering_instructions.jinja +5 -0
- edsl/questions/templates/matrix/question_presentation.jinja +20 -0
- edsl/results/CSSParameterizer.py +1 -1
- edsl/results/Dataset.py +170 -7
- edsl/results/DatasetExportMixin.py +224 -302
- edsl/results/DatasetTree.py +28 -8
- edsl/results/MarkdownToDocx.py +122 -0
- edsl/results/MarkdownToPDF.py +111 -0
- edsl/results/Result.py +192 -206
- edsl/results/Results.py +120 -113
- edsl/results/ResultsExportMixin.py +2 -0
- edsl/results/Selector.py +23 -13
- edsl/results/TableDisplay.py +98 -171
- edsl/results/TextEditor.py +50 -0
- edsl/results/__init__.py +1 -1
- edsl/results/smart_objects.py +96 -0
- edsl/results/table_data_class.py +12 -0
- edsl/results/table_renderers.py +118 -0
- edsl/scenarios/ConstructDownloadLink.py +109 -0
- edsl/scenarios/DirectoryScanner.py +96 -0
- edsl/scenarios/DocumentChunker.py +102 -0
- edsl/scenarios/DocxScenario.py +16 -0
- edsl/scenarios/FileStore.py +118 -239
- edsl/scenarios/PdfExtractor.py +40 -0
- edsl/scenarios/Scenario.py +90 -193
- edsl/scenarios/ScenarioHtmlMixin.py +4 -3
- edsl/scenarios/ScenarioJoin.py +10 -6
- edsl/scenarios/ScenarioList.py +383 -240
- edsl/scenarios/ScenarioListExportMixin.py +0 -7
- edsl/scenarios/ScenarioListPdfMixin.py +15 -37
- edsl/scenarios/ScenarioSelector.py +156 -0
- edsl/scenarios/__init__.py +1 -2
- edsl/scenarios/file_methods.py +85 -0
- edsl/scenarios/handlers/__init__.py +13 -0
- edsl/scenarios/handlers/csv.py +38 -0
- edsl/scenarios/handlers/docx.py +76 -0
- edsl/scenarios/handlers/html.py +37 -0
- edsl/scenarios/handlers/json.py +111 -0
- edsl/scenarios/handlers/latex.py +5 -0
- edsl/scenarios/handlers/md.py +51 -0
- edsl/scenarios/handlers/pdf.py +68 -0
- edsl/scenarios/handlers/png.py +39 -0
- edsl/scenarios/handlers/pptx.py +105 -0
- edsl/scenarios/handlers/py.py +294 -0
- edsl/scenarios/handlers/sql.py +313 -0
- edsl/scenarios/handlers/sqlite.py +149 -0
- edsl/scenarios/handlers/txt.py +33 -0
- edsl/study/ObjectEntry.py +1 -1
- edsl/study/SnapShot.py +1 -1
- edsl/study/Study.py +5 -12
- edsl/surveys/ConstructDAG.py +92 -0
- edsl/surveys/EditSurvey.py +221 -0
- edsl/surveys/InstructionHandler.py +100 -0
- edsl/surveys/MemoryManagement.py +72 -0
- edsl/surveys/Rule.py +5 -4
- edsl/surveys/RuleCollection.py +25 -27
- edsl/surveys/RuleManager.py +172 -0
- edsl/surveys/Simulator.py +75 -0
- edsl/surveys/Survey.py +199 -771
- edsl/surveys/SurveyCSS.py +20 -8
- edsl/surveys/{SurveyFlowVisualizationMixin.py → SurveyFlowVisualization.py} +11 -9
- edsl/surveys/SurveyToApp.py +141 -0
- edsl/surveys/__init__.py +4 -2
- edsl/surveys/descriptors.py +6 -2
- edsl/surveys/instructions/ChangeInstruction.py +1 -2
- edsl/surveys/instructions/Instruction.py +4 -13
- edsl/surveys/instructions/InstructionCollection.py +11 -6
- edsl/templates/error_reporting/interview_details.html +1 -1
- edsl/templates/error_reporting/report.html +1 -1
- edsl/tools/plotting.py +1 -1
- edsl/utilities/PrettyList.py +56 -0
- edsl/utilities/is_notebook.py +18 -0
- edsl/utilities/is_valid_variable_name.py +11 -0
- edsl/utilities/remove_edsl_version.py +24 -0
- edsl/utilities/utilities.py +35 -23
- {edsl-0.1.39.dev1.dist-info → edsl-0.1.39.dev2.dist-info}/METADATA +12 -10
- edsl-0.1.39.dev2.dist-info/RECORD +352 -0
- edsl/language_models/KeyLookup.py +0 -30
- edsl/language_models/unused/ReplicateBase.py +0 -83
- edsl/results/ResultsDBMixin.py +0 -238
- edsl-0.1.39.dev1.dist-info/RECORD +0 -277
- {edsl-0.1.39.dev1.dist-info → edsl-0.1.39.dev2.dist-info}/LICENSE +0 -0
- {edsl-0.1.39.dev1.dist-info → edsl-0.1.39.dev2.dist-info}/WHEEL +0 -0
edsl/Base.py
CHANGED
@@ -2,54 +2,10 @@
|
|
2
2
|
|
3
3
|
from abc import ABC, abstractmethod, ABCMeta
|
4
4
|
import gzip
|
5
|
-
import io
|
6
5
|
import json
|
7
6
|
from typing import Any, Optional, Union
|
8
7
|
from uuid import UUID
|
9
8
|
|
10
|
-
# from edsl.utilities.MethodSuggesterMixin import MethodSuggesterMixin
|
11
|
-
|
12
|
-
from edsl.utilities.utilities import is_notebook
|
13
|
-
|
14
|
-
|
15
|
-
class RichPrintingMixin:
|
16
|
-
pass
|
17
|
-
|
18
|
-
# def print(self):
|
19
|
-
# print(self)
|
20
|
-
|
21
|
-
|
22
|
-
# """Mixin for rich printing and persistence of objects."""
|
23
|
-
|
24
|
-
# def _for_console(self):
|
25
|
-
# """Return a string representation of the object for console printing."""
|
26
|
-
# from rich.console import Console
|
27
|
-
|
28
|
-
# with io.StringIO() as buf:
|
29
|
-
# console = Console(file=buf, record=True)
|
30
|
-
# table = self.rich_print()
|
31
|
-
# console.print(table)
|
32
|
-
# return console.export_text()
|
33
|
-
|
34
|
-
# def __str__(self):
|
35
|
-
# """Return a string representation of the object for console printing."""
|
36
|
-
# # return self._for_console()
|
37
|
-
# return self.__repr__()
|
38
|
-
|
39
|
-
# def print(self):
|
40
|
-
# """Print the object to the console."""
|
41
|
-
# from edsl.utilities.utilities import is_notebook
|
42
|
-
|
43
|
-
# if is_notebook():
|
44
|
-
# from IPython.display import display
|
45
|
-
|
46
|
-
# display(self.rich_print())
|
47
|
-
# else:
|
48
|
-
# from rich.console import Console
|
49
|
-
|
50
|
-
# console = Console()
|
51
|
-
# console.print(self.rich_print())
|
52
|
-
|
53
9
|
|
54
10
|
class PersistenceMixin:
|
55
11
|
"""Mixin for saving and loading objects to and from files."""
|
@@ -57,6 +13,7 @@ class PersistenceMixin:
|
|
57
13
|
def push(
|
58
14
|
self,
|
59
15
|
description: Optional[str] = None,
|
16
|
+
alias: Optional[str] = None,
|
60
17
|
visibility: Optional[str] = "unlisted",
|
61
18
|
expected_parrot_url: Optional[str] = None,
|
62
19
|
):
|
@@ -64,7 +21,17 @@ class PersistenceMixin:
|
|
64
21
|
from edsl.coop import Coop
|
65
22
|
|
66
23
|
c = Coop(url=expected_parrot_url)
|
67
|
-
return c.create(self, description, visibility)
|
24
|
+
return c.create(self, description, alias, visibility)
|
25
|
+
|
26
|
+
def create_download_link(self):
|
27
|
+
from tempfile import NamedTemporaryFile
|
28
|
+
from edsl.scenarios.FileStore import FileStore
|
29
|
+
|
30
|
+
with NamedTemporaryFile(suffix=".json.gz") as f:
|
31
|
+
self.save(f.name)
|
32
|
+
print(f.name)
|
33
|
+
fs = FileStore(path=f.name)
|
34
|
+
return fs.create_link()
|
68
35
|
|
69
36
|
@classmethod
|
70
37
|
def pull(
|
@@ -95,6 +62,7 @@ class PersistenceMixin:
|
|
95
62
|
uuid: Optional[Union[str, UUID]] = None,
|
96
63
|
url: Optional[str] = None,
|
97
64
|
description: Optional[str] = None,
|
65
|
+
alias: Optional[str] = None,
|
98
66
|
value: Optional[Any] = None,
|
99
67
|
visibility: Optional[str] = None,
|
100
68
|
):
|
@@ -107,7 +75,7 @@ class PersistenceMixin:
|
|
107
75
|
from edsl.coop import Coop
|
108
76
|
|
109
77
|
coop = Coop()
|
110
|
-
return coop.patch(uuid, url, description, value, visibility)
|
78
|
+
return coop.patch(uuid, url, description, alias, value, visibility)
|
111
79
|
|
112
80
|
@classmethod
|
113
81
|
def search(cls, query):
|
@@ -117,6 +85,13 @@ class PersistenceMixin:
|
|
117
85
|
c = Coop()
|
118
86
|
return c.search(cls, query)
|
119
87
|
|
88
|
+
def store(self, d: dict, key_name: Optional[str] = None):
|
89
|
+
if key_name is None:
|
90
|
+
index = len(d)
|
91
|
+
else:
|
92
|
+
index = key_name
|
93
|
+
d[index] = self
|
94
|
+
|
120
95
|
def save(self, filename, compress=True):
|
121
96
|
"""Save the object to a file as zippped JSON.
|
122
97
|
|
@@ -126,15 +101,9 @@ class PersistenceMixin:
|
|
126
101
|
if filename.endswith("json.gz"):
|
127
102
|
import warnings
|
128
103
|
|
129
|
-
|
130
|
-
# "Do not apply the file extensions. The filename should not end with 'json.gz'."
|
131
|
-
# )
|
132
|
-
filename = filename[:-7]
|
104
|
+
filename = filename[:-8]
|
133
105
|
if filename.endswith("json"):
|
134
|
-
filename = filename[:-
|
135
|
-
# warnings.warn(
|
136
|
-
# "Do not apply the file extensions. The filename should not end with 'json'."
|
137
|
-
# )
|
106
|
+
filename = filename[:-5]
|
138
107
|
|
139
108
|
if compress:
|
140
109
|
full_file_name = filename + ".json.gz"
|
@@ -196,9 +165,15 @@ class RegisterSubclassesMeta(ABCMeta):
|
|
196
165
|
RegisterSubclassesMeta._registry[cls.__name__] = cls
|
197
166
|
|
198
167
|
@staticmethod
|
199
|
-
def get_registry():
|
168
|
+
def get_registry(exclude_classes: Optional[list] = None):
|
200
169
|
"""Return the registry of subclasses."""
|
201
|
-
|
170
|
+
if exclude_classes is None:
|
171
|
+
exclude_classes = []
|
172
|
+
return {
|
173
|
+
k: v
|
174
|
+
for k, v in dict(RegisterSubclassesMeta._registry).items()
|
175
|
+
if k not in exclude_classes
|
176
|
+
}
|
202
177
|
|
203
178
|
|
204
179
|
class DiffMethodsMixin:
|
@@ -209,45 +184,147 @@ class DiffMethodsMixin:
|
|
209
184
|
return BaseDiff(self, other)
|
210
185
|
|
211
186
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
):
|
219
|
-
"""Base class for all classes in the package."""
|
187
|
+
def is_iterable(obj):
|
188
|
+
try:
|
189
|
+
iter(obj)
|
190
|
+
except TypeError:
|
191
|
+
return False
|
192
|
+
return True
|
220
193
|
|
194
|
+
|
195
|
+
class RepresentationMixin:
|
221
196
|
def json(self):
|
222
197
|
return json.loads(json.dumps(self.to_dict(add_edsl_version=False)))
|
223
198
|
|
224
|
-
def
|
225
|
-
|
226
|
-
|
227
|
-
|
199
|
+
def to_dataset(self):
|
200
|
+
from edsl.results.Dataset import Dataset
|
201
|
+
|
202
|
+
return Dataset.from_edsl_object(self)
|
203
|
+
|
204
|
+
def view(self):
|
205
|
+
"Displays an interactive / perspective view of the object"
|
206
|
+
return self.to_dataset().view()
|
207
|
+
|
208
|
+
# def print(self, format="rich"):
|
209
|
+
# return self.to_dataset().table()
|
210
|
+
|
211
|
+
def display_dict(self):
|
212
|
+
display_dict = {}
|
213
|
+
d = self.to_dict(add_edsl_version=False)
|
214
|
+
for key, value in d.items():
|
215
|
+
if isinstance(value, dict):
|
216
|
+
for k, v in value.items():
|
217
|
+
display_dict[f"{key}:{k}"] = v
|
218
|
+
elif isinstance(value, list):
|
219
|
+
for i, v in enumerate(value):
|
220
|
+
display_dict[f"{key}:{i}"] = v
|
221
|
+
else:
|
222
|
+
display_dict[key] = value
|
223
|
+
return display_dict
|
224
|
+
|
225
|
+
def print(self, format="rich"):
|
226
|
+
from rich.table import Table
|
227
|
+
from rich.console import Console
|
228
|
+
|
229
|
+
table = Table(title=self.__class__.__name__)
|
230
|
+
table.add_column("Key", style="bold")
|
231
|
+
table.add_column("Value", style="bold")
|
232
|
+
|
233
|
+
for key, value in self.display_dict().items():
|
234
|
+
table.add_row(key, str(value))
|
235
|
+
|
236
|
+
console = Console(record=True)
|
237
|
+
console.print(table)
|
238
|
+
|
239
|
+
def help(obj):
|
240
|
+
"""
|
241
|
+
Extract all public instance methods and their docstrings from a class instance.
|
242
|
+
|
243
|
+
Args:
|
244
|
+
obj: The instance to inspect
|
245
|
+
|
246
|
+
Returns:
|
247
|
+
dict: A dictionary where keys are method names and values are their docstrings
|
248
|
+
"""
|
249
|
+
import inspect
|
228
250
|
|
229
|
-
if
|
230
|
-
|
251
|
+
if inspect.isclass(obj):
|
252
|
+
raise TypeError("Please provide a class instance, not a class")
|
253
|
+
|
254
|
+
methods = {}
|
255
|
+
|
256
|
+
# Get all members of the instance
|
257
|
+
for name, member in inspect.getmembers(obj):
|
258
|
+
# Skip private and special methods (those starting with underscore)
|
259
|
+
if name.startswith("_"):
|
260
|
+
continue
|
261
|
+
|
262
|
+
# Check if it's specifically an instance method
|
263
|
+
if inspect.ismethod(member):
|
264
|
+
# Get the docstring (or empty string if none exists)
|
265
|
+
docstring = inspect.getdoc(member) or ""
|
266
|
+
methods[name] = docstring
|
267
|
+
|
268
|
+
from edsl.results.Dataset import Dataset
|
269
|
+
|
270
|
+
d = Dataset(
|
271
|
+
[
|
272
|
+
{"method": list(methods.keys())},
|
273
|
+
{"documentation": list(methods.values())},
|
274
|
+
]
|
275
|
+
)
|
276
|
+
return d
|
277
|
+
|
278
|
+
def _repr_html_(self):
|
279
|
+
from edsl.results.TableDisplay import TableDisplay
|
280
|
+
|
281
|
+
if hasattr(self, "_summary"):
|
282
|
+
summary_dict = self._summary()
|
283
|
+
summary_line = "".join([f" {k}: {v};" for k, v in summary_dict.items()])
|
284
|
+
class_name = self.__class__.__name__
|
285
|
+
docs = getattr(self, "__documentation__", "")
|
286
|
+
return (
|
287
|
+
"<p>"
|
288
|
+
+ f"<a href='{docs}'>{class_name}</a>"
|
289
|
+
+ summary_line
|
290
|
+
+ "</p>"
|
291
|
+
+ self.table()._repr_html_()
|
292
|
+
)
|
231
293
|
else:
|
232
|
-
|
294
|
+
class_name = self.__class__.__name__
|
295
|
+
documenation = getattr(self, "__documentation__", "")
|
296
|
+
summary_line = "<p>" + f"<a href='{documenation}'>{class_name}</a>" + "</p>"
|
297
|
+
display_dict = self.display_dict()
|
298
|
+
return (
|
299
|
+
summary_line
|
300
|
+
+ TableDisplay.from_dictionary_wide(display_dict)._repr_html_()
|
301
|
+
)
|
233
302
|
|
234
303
|
def __str__(self):
|
235
304
|
return self.__repr__()
|
236
305
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
306
|
+
|
307
|
+
class HashingMixin:
|
308
|
+
def __hash__(self) -> int:
|
309
|
+
"""Return a hash of the question."""
|
310
|
+
from edsl.utilities.utilities import dict_hash
|
311
|
+
|
312
|
+
return dict_hash(self.to_dict(add_edsl_version=False))
|
313
|
+
|
314
|
+
def __eq__(self, other):
|
315
|
+
"""Return whether two objects are equal."""
|
316
|
+
return hash(self) == hash(other)
|
317
|
+
|
318
|
+
|
319
|
+
class Base(
|
320
|
+
RepresentationMixin,
|
321
|
+
PersistenceMixin,
|
322
|
+
DiffMethodsMixin,
|
323
|
+
HashingMixin,
|
324
|
+
ABC,
|
325
|
+
metaclass=RegisterSubclassesMeta,
|
326
|
+
):
|
327
|
+
"""Base class for all classes in the package."""
|
251
328
|
|
252
329
|
def keys(self):
|
253
330
|
"""Return the keys of the object."""
|
@@ -264,42 +341,11 @@ class Base(
|
|
264
341
|
keys = self.keys()
|
265
342
|
return {data[key] for key in keys}
|
266
343
|
|
267
|
-
def _repr_html_(self):
|
268
|
-
from edsl.utilities.utilities import data_to_html
|
269
|
-
|
270
|
-
return data_to_html(self.to_dict())
|
271
|
-
|
272
|
-
# def html(self):
|
273
|
-
# html_string = self._repr_html_()
|
274
|
-
# import tempfile
|
275
|
-
# import webbrowser
|
276
|
-
|
277
|
-
# with tempfile.NamedTemporaryFile("w", delete=False, suffix=".html") as f:
|
278
|
-
# # print("Writing HTML to", f.name)
|
279
|
-
# f.write(html_string)
|
280
|
-
# webbrowser.open(f.name)
|
281
|
-
|
282
|
-
def __eq__(self, other):
|
283
|
-
"""Return whether two objects are equal."""
|
284
|
-
import inspect
|
285
|
-
|
286
|
-
if not isinstance(other, self.__class__):
|
287
|
-
return False
|
288
|
-
if "sort" in inspect.signature(self.to_dict).parameters:
|
289
|
-
return self.to_dict(sort=True) == other.to_dict(sort=True)
|
290
|
-
else:
|
291
|
-
return self.to_dict() == other.to_dict()
|
292
|
-
|
293
344
|
@abstractmethod
|
294
345
|
def example():
|
295
346
|
"""This method should be implemented by subclasses."""
|
296
347
|
raise NotImplementedError("This method is not implemented yet.")
|
297
348
|
|
298
|
-
@abstractmethod
|
299
|
-
def rich_print():
|
300
|
-
"""This method should be implemented by subclasses."""
|
301
|
-
raise NotImplementedError("This method is not implemented yet.")
|
302
|
-
|
303
349
|
@abstractmethod
|
304
350
|
def to_dict():
|
305
351
|
"""This method should be implemented by subclasses."""
|
@@ -308,6 +354,13 @@ class Base(
|
|
308
354
|
def to_json(self):
|
309
355
|
return json.dumps(self.to_dict())
|
310
356
|
|
357
|
+
def store(self, d: dict, key_name: Optional[str] = None):
|
358
|
+
if key_name is None:
|
359
|
+
index = len(d)
|
360
|
+
else:
|
361
|
+
index = key_name
|
362
|
+
d[index] = self
|
363
|
+
|
311
364
|
@abstractmethod
|
312
365
|
def from_dict():
|
313
366
|
"""This method should be implemented by subclasses."""
|
edsl/__init__.py
CHANGED
@@ -5,7 +5,9 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
5
5
|
ROOT_DIR = os.path.dirname(BASE_DIR)
|
6
6
|
|
7
7
|
from edsl.__version__ import __version__
|
8
|
-
|
8
|
+
|
9
|
+
# from edsl.config import Config, CONFIG
|
10
|
+
|
9
11
|
from edsl.agents.Agent import Agent
|
10
12
|
from edsl.agents.AgentList import AgentList
|
11
13
|
|
@@ -18,6 +20,7 @@ from edsl.questions import QuestionFreeText
|
|
18
20
|
from edsl.questions import QuestionFunctional
|
19
21
|
from edsl.questions import QuestionLikertFive
|
20
22
|
from edsl.questions import QuestionList
|
23
|
+
from edsl.questions import QuestionMatrix
|
21
24
|
from edsl.questions import QuestionLinearScale
|
22
25
|
from edsl.questions import QuestionNumerical
|
23
26
|
from edsl.questions import QuestionYesNo
|
@@ -25,22 +28,27 @@ from edsl.questions import QuestionBudget
|
|
25
28
|
from edsl.questions import QuestionRank
|
26
29
|
from edsl.questions import QuestionTopK
|
27
30
|
|
28
|
-
from edsl.scenarios import Scenario
|
29
|
-
from edsl.scenarios import ScenarioList
|
31
|
+
from edsl.scenarios.Scenario import Scenario
|
32
|
+
from edsl.scenarios.ScenarioList import ScenarioList
|
30
33
|
from edsl.scenarios.FileStore import FileStore
|
31
34
|
|
32
35
|
# from edsl.utilities.interface import print_dict_with_rich
|
33
36
|
from edsl.surveys.Survey import Survey
|
34
37
|
from edsl.language_models.registry import Model
|
35
38
|
from edsl.language_models.ModelList import ModelList
|
39
|
+
|
36
40
|
from edsl.results.Results import Results
|
37
41
|
from edsl.data.Cache import Cache
|
38
|
-
|
42
|
+
|
43
|
+
# from edsl.data.CacheEntry import CacheEntry
|
39
44
|
from edsl.data.CacheHandler import set_session_cache, unset_session_cache
|
40
|
-
|
45
|
+
|
46
|
+
# from edsl.shared import shared_globals
|
47
|
+
|
41
48
|
from edsl.jobs.Jobs import Jobs
|
42
49
|
from edsl.notebooks.Notebook import Notebook
|
43
|
-
|
50
|
+
|
51
|
+
# from edsl.study.Study import Study
|
44
52
|
|
45
53
|
# from edsl.conjure.Conjure import Conjure
|
46
54
|
from edsl.coop.coop import Coop
|
edsl/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.39.
|
1
|
+
__version__ = "0.1.39.dev2"
|