edsl 0.1.27.dev2__py3-none-any.whl → 0.1.29__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 (119) hide show
  1. edsl/Base.py +107 -30
  2. edsl/BaseDiff.py +260 -0
  3. edsl/__init__.py +25 -21
  4. edsl/__version__.py +1 -1
  5. edsl/agents/Agent.py +103 -46
  6. edsl/agents/AgentList.py +97 -13
  7. edsl/agents/Invigilator.py +23 -10
  8. edsl/agents/InvigilatorBase.py +19 -14
  9. edsl/agents/PromptConstructionMixin.py +342 -100
  10. edsl/agents/descriptors.py +5 -2
  11. edsl/base/Base.py +289 -0
  12. edsl/config.py +2 -1
  13. edsl/conjure/AgentConstructionMixin.py +152 -0
  14. edsl/conjure/Conjure.py +56 -0
  15. edsl/conjure/InputData.py +659 -0
  16. edsl/conjure/InputDataCSV.py +48 -0
  17. edsl/conjure/InputDataMixinQuestionStats.py +182 -0
  18. edsl/conjure/InputDataPyRead.py +91 -0
  19. edsl/conjure/InputDataSPSS.py +8 -0
  20. edsl/conjure/InputDataStata.py +8 -0
  21. edsl/conjure/QuestionOptionMixin.py +76 -0
  22. edsl/conjure/QuestionTypeMixin.py +23 -0
  23. edsl/conjure/RawQuestion.py +65 -0
  24. edsl/conjure/SurveyResponses.py +7 -0
  25. edsl/conjure/__init__.py +9 -4
  26. edsl/conjure/examples/placeholder.txt +0 -0
  27. edsl/conjure/naming_utilities.py +263 -0
  28. edsl/conjure/utilities.py +165 -28
  29. edsl/conversation/Conversation.py +238 -0
  30. edsl/conversation/car_buying.py +58 -0
  31. edsl/conversation/mug_negotiation.py +81 -0
  32. edsl/conversation/next_speaker_utilities.py +93 -0
  33. edsl/coop/coop.py +337 -121
  34. edsl/coop/utils.py +56 -70
  35. edsl/data/Cache.py +74 -22
  36. edsl/data/CacheHandler.py +10 -9
  37. edsl/data/SQLiteDict.py +11 -3
  38. edsl/inference_services/AnthropicService.py +1 -0
  39. edsl/inference_services/DeepInfraService.py +20 -13
  40. edsl/inference_services/GoogleService.py +7 -1
  41. edsl/inference_services/InferenceServicesCollection.py +33 -7
  42. edsl/inference_services/OpenAIService.py +17 -10
  43. edsl/inference_services/models_available_cache.py +69 -0
  44. edsl/inference_services/rate_limits_cache.py +25 -0
  45. edsl/inference_services/write_available.py +10 -0
  46. edsl/jobs/Answers.py +15 -1
  47. edsl/jobs/Jobs.py +322 -73
  48. edsl/jobs/buckets/BucketCollection.py +9 -3
  49. edsl/jobs/buckets/ModelBuckets.py +4 -2
  50. edsl/jobs/buckets/TokenBucket.py +1 -2
  51. edsl/jobs/interviews/Interview.py +7 -10
  52. edsl/jobs/interviews/InterviewStatusMixin.py +3 -3
  53. edsl/jobs/interviews/InterviewTaskBuildingMixin.py +39 -20
  54. edsl/jobs/interviews/retry_management.py +4 -4
  55. edsl/jobs/runners/JobsRunnerAsyncio.py +103 -65
  56. edsl/jobs/runners/JobsRunnerStatusData.py +3 -3
  57. edsl/jobs/tasks/QuestionTaskCreator.py +4 -2
  58. edsl/jobs/tasks/TaskHistory.py +4 -3
  59. edsl/language_models/LanguageModel.py +42 -55
  60. edsl/language_models/ModelList.py +96 -0
  61. edsl/language_models/registry.py +14 -0
  62. edsl/language_models/repair.py +97 -25
  63. edsl/notebooks/Notebook.py +157 -32
  64. edsl/prompts/Prompt.py +31 -19
  65. edsl/questions/QuestionBase.py +145 -23
  66. edsl/questions/QuestionBudget.py +5 -6
  67. edsl/questions/QuestionCheckBox.py +7 -3
  68. edsl/questions/QuestionExtract.py +5 -3
  69. edsl/questions/QuestionFreeText.py +3 -3
  70. edsl/questions/QuestionFunctional.py +0 -3
  71. edsl/questions/QuestionList.py +3 -4
  72. edsl/questions/QuestionMultipleChoice.py +16 -8
  73. edsl/questions/QuestionNumerical.py +4 -3
  74. edsl/questions/QuestionRank.py +5 -3
  75. edsl/questions/__init__.py +4 -3
  76. edsl/questions/descriptors.py +9 -4
  77. edsl/questions/question_registry.py +27 -31
  78. edsl/questions/settings.py +1 -1
  79. edsl/results/Dataset.py +31 -0
  80. edsl/results/DatasetExportMixin.py +493 -0
  81. edsl/results/Result.py +42 -82
  82. edsl/results/Results.py +178 -66
  83. edsl/results/ResultsDBMixin.py +10 -9
  84. edsl/results/ResultsExportMixin.py +23 -507
  85. edsl/results/ResultsGGMixin.py +3 -3
  86. edsl/results/ResultsToolsMixin.py +9 -9
  87. edsl/scenarios/FileStore.py +140 -0
  88. edsl/scenarios/Scenario.py +59 -6
  89. edsl/scenarios/ScenarioList.py +138 -52
  90. edsl/scenarios/ScenarioListExportMixin.py +32 -0
  91. edsl/scenarios/ScenarioListPdfMixin.py +2 -1
  92. edsl/scenarios/__init__.py +1 -0
  93. edsl/study/ObjectEntry.py +173 -0
  94. edsl/study/ProofOfWork.py +113 -0
  95. edsl/study/SnapShot.py +73 -0
  96. edsl/study/Study.py +498 -0
  97. edsl/study/__init__.py +4 -0
  98. edsl/surveys/MemoryPlan.py +11 -4
  99. edsl/surveys/Survey.py +124 -37
  100. edsl/surveys/SurveyExportMixin.py +25 -5
  101. edsl/surveys/SurveyFlowVisualizationMixin.py +6 -4
  102. edsl/tools/plotting.py +4 -2
  103. edsl/utilities/__init__.py +21 -20
  104. edsl/utilities/gcp_bucket/__init__.py +0 -0
  105. edsl/utilities/gcp_bucket/cloud_storage.py +96 -0
  106. edsl/utilities/gcp_bucket/simple_example.py +9 -0
  107. edsl/utilities/interface.py +90 -73
  108. edsl/utilities/repair_functions.py +28 -0
  109. edsl/utilities/utilities.py +59 -6
  110. {edsl-0.1.27.dev2.dist-info → edsl-0.1.29.dist-info}/METADATA +42 -15
  111. edsl-0.1.29.dist-info/RECORD +203 -0
  112. edsl/conjure/RawResponseColumn.py +0 -327
  113. edsl/conjure/SurveyBuilder.py +0 -308
  114. edsl/conjure/SurveyBuilderCSV.py +0 -78
  115. edsl/conjure/SurveyBuilderSPSS.py +0 -118
  116. edsl/data/RemoteDict.py +0 -103
  117. edsl-0.1.27.dev2.dist-info/RECORD +0 -172
  118. {edsl-0.1.27.dev2.dist-info → edsl-0.1.29.dist-info}/LICENSE +0 -0
  119. {edsl-0.1.27.dev2.dist-info → edsl-0.1.29.dist-info}/WHEEL +0 -0
edsl/Base.py CHANGED
@@ -4,11 +4,8 @@ from abc import ABC, abstractmethod, ABCMeta
4
4
  import gzip
5
5
  import io
6
6
  import json
7
- from typing import Union
7
+ from typing import Any, Optional, Union
8
8
  from uuid import UUID
9
- from IPython.display import display
10
- from rich.console import Console
11
- from edsl.utilities import is_notebook
12
9
 
13
10
 
14
11
  class RichPrintingMixin:
@@ -16,6 +13,8 @@ class RichPrintingMixin:
16
13
 
17
14
  def _for_console(self):
18
15
  """Return a string representation of the object for console printing."""
16
+ from rich.console import Console
17
+
19
18
  with io.StringIO() as buf:
20
19
  console = Console(file=buf, record=True)
21
20
  table = self.rich_print()
@@ -28,7 +27,11 @@ class RichPrintingMixin:
28
27
 
29
28
  def print(self):
30
29
  """Print the object to the console."""
30
+ from edsl.utilities.utilities import is_notebook
31
+
31
32
  if is_notebook():
33
+ from IPython.display import display
34
+
32
35
  display(self.rich_print())
33
36
  else:
34
37
  from rich.console import Console
@@ -40,44 +43,54 @@ class RichPrintingMixin:
40
43
  class PersistenceMixin:
41
44
  """Mixin for saving and loading objects to and from files."""
42
45
 
43
- def push(self, visibility="unlisted"):
46
+ def push(
47
+ self,
48
+ description: Optional[str] = None,
49
+ visibility: Optional[str] = "unlisted",
50
+ ):
44
51
  """Post the object to coop."""
45
52
  from edsl.coop import Coop
46
53
 
47
54
  c = Coop()
48
- return c.create(self, visibility)
55
+ return c.create(self, description, visibility)
49
56
 
50
57
  @classmethod
51
- def pull(cls, id_or_url: Union[str, UUID]):
58
+ def pull(cls, uuid: Optional[Union[str, UUID]] = None, url: Optional[str] = None):
52
59
  """Pull the object from coop."""
53
60
  from edsl.coop import Coop
61
+ from edsl.coop.utils import ObjectRegistry
54
62
 
55
- c = Coop()
56
- return c._get_base(cls, id_or_url)
57
- # if isinstance(id_or_url, str) and c.url in id_or_url:
58
- # return c.get(url=id_or_url)
59
- # else:
60
- # _, object_type = c._resolve_edsl_object(cls)
61
- # return c.get(object_type, id_or_url)
63
+ object_type = ObjectRegistry.get_object_type_by_edsl_class(cls)
64
+ coop = Coop()
65
+ return coop.get(uuid, url, object_type)
62
66
 
63
67
  @classmethod
64
- def delete(cls, id_or_url: Union[str, UUID]):
68
+ def delete(cls, uuid: Optional[Union[str, UUID]] = None, url: Optional[str] = None):
65
69
  """Delete the object from coop."""
66
70
  from edsl.coop import Coop
67
71
 
68
- c = Coop()
69
- return c._delete_base(cls, id_or_url)
72
+ coop = Coop()
73
+ return coop.delete(uuid, url)
70
74
 
71
75
  @classmethod
72
- def patch(cls, id_or_url: Union[str, UUID], visibility: str):
76
+ def patch(
77
+ cls,
78
+ uuid: Optional[Union[str, UUID]] = None,
79
+ url: Optional[str] = None,
80
+ description: Optional[str] = None,
81
+ value: Optional[Any] = None,
82
+ visibility: Optional[str] = None,
83
+ ):
73
84
  """
74
85
  Patch an uploaded objects attributes.
75
- - Only supports changing visibility for now.
86
+ - `description` changes the description of the object on Coop
87
+ - `value` changes the value of the object on Coop. **has to be an EDSL object**
88
+ - `visibility` changes the visibility of the object on Coop
76
89
  """
77
90
  from edsl.coop import Coop
78
91
 
79
- c = Coop()
80
- return c._patch_base(cls, id_or_url, visibility)
92
+ coop = Coop()
93
+ return coop.patch(uuid, url, description, value, visibility)
81
94
 
82
95
  @classmethod
83
96
  def search(cls, query):
@@ -87,14 +100,45 @@ class PersistenceMixin:
87
100
  c = Coop()
88
101
  return c.search(cls, query)
89
102
 
90
- def save(self, filename):
103
+ def save(self, filename, compress=True):
91
104
  """Save the object to a file as zippped JSON.
92
105
 
93
106
  >>> obj.save("obj.json.gz")
94
107
 
95
108
  """
96
- with gzip.open(filename, "wb") as f:
97
- f.write(json.dumps(self.to_dict()).encode("utf-8"))
109
+ if filename.endswith("json.gz"):
110
+ import warnings
111
+
112
+ warnings.warn(
113
+ "Do not apply the file extensions. The filename should not end with 'json.gz'."
114
+ )
115
+ filename = filename[:-7]
116
+ if filename.endswith("json"):
117
+ filename = filename[:-4]
118
+ warnings.warn(
119
+ "Do not apply the file extensions. The filename should not end with 'json'."
120
+ )
121
+
122
+ if compress:
123
+ with gzip.open(filename + ".json.gz", "wb") as f:
124
+ f.write(json.dumps(self.to_dict()).encode("utf-8"))
125
+ else:
126
+ with open(filename + ".json", "w") as f:
127
+ f.write(json.dumps(self.to_dict()))
128
+
129
+ @staticmethod
130
+ def open_compressed_file(filename):
131
+ with gzip.open(filename, "rb") as f:
132
+ file_contents = f.read()
133
+ file_contents_decoded = file_contents.decode("utf-8")
134
+ d = json.loads(file_contents_decoded)
135
+ return d
136
+
137
+ @staticmethod
138
+ def open_regular_file(filename):
139
+ with open(filename, "r") as f:
140
+ d = json.loads(f.read())
141
+ return d
98
142
 
99
143
  @classmethod
100
144
  def load(cls, filename):
@@ -103,11 +147,19 @@ class PersistenceMixin:
103
147
  >>> obj = cls.load("obj.json.gz")
104
148
 
105
149
  """
106
- with gzip.open(filename, "rb") as f:
107
- file_contents = f.read()
108
- file_contents_decoded = file_contents.decode("utf-8")
109
- d = json.loads(file_contents_decoded)
110
- # d = json.loads(f.read().decode("utf-8"))
150
+
151
+ if filename.endswith("json.gz"):
152
+ d = cls.open_compressed_file(filename)
153
+ elif filename.endswith("json"):
154
+ d = cls.open_regular_file(filename)
155
+ else:
156
+ try:
157
+ d = cls.open_compressed_file(filename)
158
+ except:
159
+ d = cls.open_regular_file(filename)
160
+ finally:
161
+ raise ValueError("File must be a json or json.gz file")
162
+
111
163
  return cls.from_dict(d)
112
164
 
113
165
 
@@ -128,7 +180,21 @@ class RegisterSubclassesMeta(ABCMeta):
128
180
  return dict(RegisterSubclassesMeta._registry)
129
181
 
130
182
 
131
- class Base(RichPrintingMixin, PersistenceMixin, ABC, metaclass=RegisterSubclassesMeta):
183
+ class DiffMethodsMixin:
184
+ def __sub__(self, other):
185
+ """Return the difference between two objects."""
186
+ from edsl.BaseDiff import BaseDiff
187
+
188
+ return BaseDiff(self, other)
189
+
190
+
191
+ class Base(
192
+ RichPrintingMixin,
193
+ PersistenceMixin,
194
+ DiffMethodsMixin,
195
+ ABC,
196
+ metaclass=RegisterSubclassesMeta,
197
+ ):
132
198
  """Base class for all classes in the package."""
133
199
 
134
200
  # def __getitem__(self, key):
@@ -172,6 +238,17 @@ class Base(RichPrintingMixin, PersistenceMixin, ABC, metaclass=RegisterSubclasse
172
238
  # f.write(html_string)
173
239
  # webbrowser.open(f.name)
174
240
 
241
+ def __eq__(self, other):
242
+ """Return whether two objects are equal."""
243
+ import inspect
244
+
245
+ if not isinstance(other, self.__class__):
246
+ return False
247
+ if "sort" in inspect.signature(self._to_dict).parameters:
248
+ return self._to_dict(sort=True) == other._to_dict(sort=True)
249
+ else:
250
+ return self._to_dict() == other._to_dict()
251
+
175
252
  @abstractmethod
176
253
  def example():
177
254
  """This method should be implemented by subclasses."""
edsl/BaseDiff.py ADDED
@@ -0,0 +1,260 @@
1
+ import difflib
2
+ import json
3
+ from typing import Any, Dict, Tuple
4
+ from collections import UserList
5
+ import inspect
6
+
7
+
8
+ class BaseDiffCollection(UserList):
9
+ def __init__(self, diffs=None):
10
+ if diffs is None:
11
+ diffs = []
12
+ super().__init__(diffs)
13
+
14
+ def apply(self, obj: Any):
15
+ for diff in self:
16
+ obj = diff.apply(obj)
17
+ return obj
18
+
19
+ def add_diff(self, diff) -> "BaseDiffCollection":
20
+ self.append(diff)
21
+ return self
22
+
23
+
24
+ class DummyObject:
25
+ def __init__(self, object_dict):
26
+ self.object_dict = object_dict
27
+
28
+ def _to_dict(self):
29
+ return self.object_dict
30
+
31
+
32
+ class BaseDiff:
33
+ def __init__(
34
+ self, obj1: Any, obj2: Any, added=None, removed=None, modified=None, level=0
35
+ ):
36
+ self.level = level
37
+
38
+ self.obj1 = obj1
39
+ self.obj2 = obj2
40
+
41
+ if "sort" in inspect.signature(obj1._to_dict).parameters:
42
+ self._dict1 = obj1._to_dict(sort=True)
43
+ self._dict2 = obj2._to_dict(sort=True)
44
+ else:
45
+ self._dict1 = obj1._to_dict()
46
+ self._dict2 = obj2._to_dict()
47
+ self._obj_class = type(obj1)
48
+
49
+ self.added = added
50
+ self.removed = removed
51
+ self.modified = modified
52
+
53
+ def __bool__(self):
54
+ return bool(self.added or self.removed or self.modified)
55
+
56
+ @property
57
+ def added(self):
58
+ if self._added is None:
59
+ self._added = self._find_added()
60
+ return self._added
61
+
62
+ def __add__(self, other):
63
+ return self.apply(other)
64
+
65
+ @added.setter
66
+ def added(self, value):
67
+ self._added = value if value is not None else self._find_added()
68
+
69
+ @property
70
+ def removed(self):
71
+ if self._removed is None:
72
+ self._removed = self._find_removed()
73
+ return self._removed
74
+
75
+ @removed.setter
76
+ def removed(self, value):
77
+ self._removed = value if value is not None else self._find_removed()
78
+
79
+ @property
80
+ def modified(self):
81
+ if self._modified is None:
82
+ self._modified = self._find_modified()
83
+ return self._modified
84
+
85
+ @modified.setter
86
+ def modified(self, value):
87
+ self._modified = value if value is not None else self._find_modified()
88
+
89
+ def _find_added(self) -> Dict[Any, Any]:
90
+ return {k: self._dict2[k] for k in self._dict2 if k not in self._dict1}
91
+
92
+ def _find_removed(self) -> Dict[Any, Any]:
93
+ return {k: self._dict1[k] for k in self._dict1 if k not in self._dict2}
94
+
95
+ def _find_modified(self) -> Dict[Any, Tuple[Any, Any, str]]:
96
+ modified = {}
97
+ for k in self._dict1:
98
+ if k in self._dict2 and self._dict1[k] != self._dict2[k]:
99
+ if isinstance(self._dict1[k], str) and isinstance(self._dict2[k], str):
100
+ diff = self._diff_strings(self._dict1[k], self._dict2[k])
101
+ modified[k] = (self._dict1[k], self._dict2[k], diff)
102
+ elif isinstance(self._dict1[k], dict) and isinstance(
103
+ self._dict2[k], dict
104
+ ):
105
+ diff = self._diff_dicts(self._dict1[k], self._dict2[k])
106
+ modified[k] = (self._dict1[k], self._dict2[k], diff)
107
+ elif isinstance(self._dict1[k], list) and isinstance(
108
+ self._dict2[k], list
109
+ ):
110
+ d1 = dict(zip(range(len(self._dict1[k])), self._dict1[k]))
111
+ d2 = dict(zip(range(len(self._dict2[k])), self._dict2[k]))
112
+ diff = BaseDiff(
113
+ DummyObject(d1), DummyObject(d2), level=self.level + 1
114
+ )
115
+ modified[k] = (self._dict1[k], self._dict2[k], diff)
116
+ else:
117
+ modified[k] = (self._dict1[k], self._dict2[k], "")
118
+ return modified
119
+
120
+ @staticmethod
121
+ def is_json(string_that_could_be_json: str) -> bool:
122
+ try:
123
+ json.loads(string_that_could_be_json)
124
+ return True
125
+ except json.JSONDecodeError:
126
+ return False
127
+
128
+ def _diff_dicts(self, dict1: Dict[str, Any], dict2: Dict[str, Any]) -> str:
129
+ diff = BaseDiff(DummyObject(dict1), DummyObject(dict2), level=self.level + 1)
130
+ return diff
131
+
132
+ def _diff_strings(self, str1: str, str2: str) -> str:
133
+ if self.is_json(str1) and self.is_json(str2):
134
+ diff = self._diff_dicts(json.loads(str1), json.loads(str2))
135
+ return diff
136
+ diff = difflib.ndiff(str1.splitlines(), str2.splitlines())
137
+ return diff
138
+
139
+ def apply(self, obj: Any):
140
+ """Apply the diff to the object."""
141
+
142
+ new_obj_dict = obj._to_dict()
143
+ for k, v in self.added.items():
144
+ new_obj_dict[k] = v
145
+ for k in self.removed.keys():
146
+ del new_obj_dict[k]
147
+ for k, (v1, v2, diff) in self.modified.items():
148
+ new_obj_dict[k] = v2
149
+
150
+ return obj.from_dict(new_obj_dict)
151
+
152
+ def to_dict(self) -> Dict[str, Any]:
153
+ return {
154
+ "added": self.added,
155
+ "removed": self.removed,
156
+ "modified": self.modified,
157
+ "obj1": self._dict1,
158
+ "obj2": self._dict2,
159
+ "obj_class": self._obj_class.__name__,
160
+ "level": self.level,
161
+ }
162
+
163
+ @classmethod
164
+ def from_dict(cls, diff_dict: Dict[str, Any], obj1: Any, obj2: Any):
165
+ return cls(
166
+ obj1=obj1,
167
+ obj2=obj2,
168
+ added=diff_dict["added"],
169
+ removed=diff_dict["removed"],
170
+ modified=diff_dict["modified"],
171
+ level=diff_dict["level"],
172
+ )
173
+
174
+ class Results(UserList):
175
+ def __init__(self, prepend=" ", level=0):
176
+ super().__init__()
177
+ self.prepend = prepend
178
+ self.level = level
179
+
180
+ def append(self, item):
181
+ super().append(self.prepend * self.level + item)
182
+
183
+ def __str__(self):
184
+ prepend = " "
185
+ result = self.Results(level=self.level, prepend="\t")
186
+ if self.added:
187
+ result.append("Added keys and values:")
188
+ for k, v in self.added.items():
189
+ result.append(prepend + f" {k}: {v}")
190
+ if self.removed:
191
+ result.append("Removed keys and values:")
192
+ for k, v in self.removed.items():
193
+ result.append(f" {k}: {v}")
194
+ if self.modified:
195
+ result.append("Modified keys and values:")
196
+ for k, (v1, v2, diff) in self.modified.items():
197
+ result.append(f"Key: {k}:")
198
+ result.append(f" Old value: {v1}")
199
+ result.append(f" New value: {v2}")
200
+ if diff:
201
+ result.append(f" Diff:")
202
+ try:
203
+ for line in diff:
204
+ result.append(f" {line}")
205
+ except:
206
+ result.append(f" {diff}")
207
+ return "\n".join(result)
208
+
209
+ def __repr__(self):
210
+ return (
211
+ f"BaseDiff(obj1={self.obj1!r}, obj2={self.obj2!r}, added={self.added!r}, "
212
+ f"removed={self.removed!r}, modified={self.modified!r})"
213
+ )
214
+
215
+ def add_diff(self, diff) -> "BaseDiffCollection":
216
+ return BaseDiffCollection([self, diff])
217
+
218
+
219
+ if __name__ == "__main__":
220
+ from edsl import Question
221
+
222
+ q_ft = Question.example("free_text")
223
+ q_mc = Question.example("multiple_choice")
224
+
225
+ diff1 = q_ft - q_mc
226
+ assert q_ft == q_mc + diff1
227
+ assert q_ft == diff1.apply(q_mc)
228
+ # new_q_mc = diff1.apply(q_ft)
229
+ # assert new_q_mc == q_mc
230
+
231
+ # new_q_mc = q_ft + diff1
232
+ # assert new_q_mc == q_mc
233
+
234
+ # new_q_mc = diff1 + q_ft
235
+ # assert new_q_mc == q_mc
236
+
237
+ # ## Test chain of diffs
238
+ q0 = Question.example("free_text")
239
+ q1 = q0.copy()
240
+ q1.question_text = "Why is Buzzard's Bay so named?"
241
+ diff1 = q1 - q0
242
+ q2 = q1.copy()
243
+ q2.question_name = "buzzard_bay"
244
+ diff2 = q2 - q1
245
+
246
+ diff_chain = diff1.add_diff(diff2)
247
+
248
+ new_q2 = diff_chain.apply(q0)
249
+ assert new_q2 == q2
250
+
251
+ new_q2 = diff_chain + q0
252
+ assert new_q2 == q2
253
+
254
+ # new_diffs = diff1.add_diff(diff1).add_diff(diff1)
255
+ # assert len(new_diffs) == 3
256
+
257
+ # q0 = Question.example("free_text")
258
+ # q1 = Question.example("free_text")
259
+ # q1.question_text = "Why is Buzzard's Bay so named?"
260
+ # q2 = q1.copy()
edsl/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import time
2
3
 
3
4
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
4
5
  ROOT_DIR = os.path.dirname(BASE_DIR)
@@ -7,32 +8,35 @@ from edsl.__version__ import __version__
7
8
  from edsl.config import Config, CONFIG
8
9
  from edsl.agents.Agent import Agent
9
10
  from edsl.agents.AgentList import AgentList
10
- from edsl.questions import (
11
- QuestionBase,
12
- QuestionBudget,
13
- QuestionCheckBox,
14
- QuestionExtract,
15
- QuestionFreeText,
16
- QuestionFunctional,
17
- QuestionLikertFive,
18
- QuestionList,
19
- QuestionLinearScale,
20
- QuestionMultipleChoice,
21
- QuestionNumerical,
22
- QuestionRank,
23
- QuestionTopK,
24
- QuestionYesNo,
25
- )
26
- from edsl.scenarios.Scenario import Scenario
27
- from edsl.scenarios.ScenarioList import ScenarioList
28
- from edsl.utilities.interface import print_dict_with_rich
11
+ from edsl.questions import QuestionBase
12
+ from edsl.questions import QuestionMultipleChoice
13
+ from edsl.questions import QuestionBudget
14
+ from edsl.questions import QuestionCheckBox
15
+ from edsl.questions import QuestionExtract
16
+ from edsl.questions import QuestionFreeText
17
+ from edsl.questions import QuestionFunctional
18
+ from edsl.questions import QuestionLikertFive
19
+ from edsl.questions import QuestionList
20
+ from edsl.questions import QuestionLinearScale
21
+ from edsl.questions import QuestionNumerical
22
+ from edsl.questions import QuestionRank
23
+ from edsl.questions import QuestionTopK
24
+ from edsl.questions import QuestionYesNo
25
+ from edsl.questions.question_registry import Question
26
+ from edsl.scenarios import Scenario
27
+ from edsl.scenarios import ScenarioList
28
+
29
+ # from edsl.utilities.interface import print_dict_with_rich
29
30
  from edsl.surveys.Survey import Survey
30
31
  from edsl.language_models.registry import Model
31
- from edsl.questions.question_registry import Question
32
+ from edsl.language_models.ModelList import ModelList
32
33
  from edsl.results.Results import Results
33
34
  from edsl.data.Cache import Cache
34
35
  from edsl.data.CacheEntry import CacheEntry
35
36
  from edsl.data.CacheHandler import set_session_cache, unset_session_cache
36
37
  from edsl.shared import shared_globals
37
- from edsl.jobs import Jobs
38
+ from edsl.jobs.Jobs import Jobs
39
+ from edsl.notebooks.Notebook import Notebook
40
+ from edsl.study.Study import Study
41
+ from edsl.conjure.Conjure import Conjure
38
42
  from edsl.coop.coop import Coop
edsl/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.27.dev2"
1
+ __version__ = "0.1.29"