revisit 0.0.27__py2.py3-none-any.whl → 0.0.28__py2.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.
revisit/revisit.py
CHANGED
@@ -45,7 +45,6 @@ class _WrappedResponse(_JSONableBaseModel):
|
|
45
45
|
self.root = self.root.root
|
46
46
|
|
47
47
|
def set(self, overwrite=True, **kwargs) -> _WrappedResponse:
|
48
|
-
print('but I got here')
|
49
48
|
for key, value in kwargs.items():
|
50
49
|
# Disallow changing type
|
51
50
|
if key == 'type':
|
@@ -54,7 +53,6 @@ class _WrappedResponse(_JSONableBaseModel):
|
|
54
53
|
elif key != 'base':
|
55
54
|
if overwrite is True or (overwrite is False and getattr(self.root, key) is None):
|
56
55
|
setattr(self.root, key, value)
|
57
|
-
print('do I get here???')
|
58
56
|
# Re-validates the model. Returns the new model.
|
59
57
|
self.root = _validate_response(self.root.__dict__)
|
60
58
|
return self
|
@@ -454,9 +452,39 @@ def data(file_path: str) -> List[Any]:
|
|
454
452
|
return data_rows
|
455
453
|
|
456
454
|
|
457
|
-
def widget(study: _WrappedStudyConfig, revisitPath: str):
|
458
|
-
|
459
|
-
|
455
|
+
def widget(study: _WrappedStudyConfig, revisitPath: str = '', server=False, pathToLib=''):
|
456
|
+
|
457
|
+
# If server is set to true, needs to use the correct package path.
|
458
|
+
# If server is not true, needs to have a valid revisitPath. I think we already handle that below
|
459
|
+
|
460
|
+
if server is False and not os.path.isdir(revisitPath):
|
461
|
+
raise RevisitError(message=f'"{revisitPath}" does not exist. Specify a correct revisitPath or use the revisti_server module and set "server" to "True".')
|
462
|
+
|
463
|
+
# Set defaults for when not using server.
|
464
|
+
dest_loc = f"{revisitPath}/public/__revisit-widget/assets/"
|
465
|
+
dest_loc_react = f"{revisitPath}/src/public/__revisit-widget/assets/"
|
466
|
+
|
467
|
+
# If using server,
|
468
|
+
if server is True:
|
469
|
+
# If not path specified, search in current environment.
|
470
|
+
if pathToLib == '':
|
471
|
+
# Get working directory
|
472
|
+
current_dir = os.getcwd()
|
473
|
+
# Get parent directory (list of packages installed in .venv)
|
474
|
+
parent_dir = os.path.dirname(current_dir)
|
475
|
+
|
476
|
+
# Construct the path to the revisit_server package
|
477
|
+
revisit_server_dir = os.path.join(parent_dir, 'revisit_server')
|
478
|
+
if not os.path.isdir(revisit_server_dir):
|
479
|
+
raise RevisitError(message='Cannot locate "revisit_server" package in current environment. Specify directory using "pathToLib" or install "revisit_server" in same environment as "revisit" package.')
|
480
|
+
|
481
|
+
dest_loc = f"{revisit_server_dir}/static/__revisit-widget/assets/"
|
482
|
+
else:
|
483
|
+
if not os.path.isdir(pathToLib):
|
484
|
+
raise RevisitError(message=f'"{pathToLib}" is not a directory.')
|
485
|
+
dest_loc = f"{pathToLib}/static/__revisit-widget/assets/"
|
486
|
+
if not os.path.isdir(dest_loc):
|
487
|
+
raise RevisitError(message=f'"{dest_loc}" is not a directory.')
|
460
488
|
|
461
489
|
extracted_paths = []
|
462
490
|
|
@@ -469,11 +497,12 @@ def widget(study: _WrappedStudyConfig, revisitPath: str):
|
|
469
497
|
fileName = actual_component.path.split('/')[-1]
|
470
498
|
|
471
499
|
if actual_component.type == 'react-component':
|
472
|
-
dest = f"{
|
500
|
+
dest = f"{dest_loc_react}{fileName}"
|
473
501
|
else:
|
474
|
-
dest = f"{
|
502
|
+
dest = f"{dest_loc}{fileName}"
|
475
503
|
|
476
504
|
extracted_paths.append({
|
505
|
+
"type": actual_component.type,
|
477
506
|
"src": actual_component.path,
|
478
507
|
"dest": dest
|
479
508
|
})
|
@@ -485,9 +514,10 @@ def widget(study: _WrappedStudyConfig, revisitPath: str):
|
|
485
514
|
if uiConfig.helpTextPath is not None:
|
486
515
|
|
487
516
|
fileName = uiConfig.helpTextPath.split('/')[-1]
|
488
|
-
dest = f"{
|
517
|
+
dest = f"{dest_loc}{fileName}"
|
489
518
|
|
490
519
|
extracted_paths.append({
|
520
|
+
"type": 'helpTextPath',
|
491
521
|
"src": uiConfig.helpTextPath,
|
492
522
|
"dest": dest
|
493
523
|
})
|
@@ -499,9 +529,10 @@ def widget(study: _WrappedStudyConfig, revisitPath: str):
|
|
499
529
|
|
500
530
|
fileName = uiConfig.logoPath.split('/')[-1]
|
501
531
|
|
502
|
-
dest = f"{
|
532
|
+
dest = f"{dest_loc}{fileName}"
|
503
533
|
|
504
534
|
extracted_paths.append({
|
535
|
+
"type": 'logoPath',
|
505
536
|
"src": uiConfig.logoPath,
|
506
537
|
"dest": dest
|
507
538
|
})
|
@@ -511,7 +542,10 @@ def widget(study: _WrappedStudyConfig, revisitPath: str):
|
|
511
542
|
|
512
543
|
# Copy all files
|
513
544
|
for item in extracted_paths:
|
514
|
-
|
545
|
+
if item['type'] == 'react-component' and server is True:
|
546
|
+
print('Skipping react component when "server" is set to "True".')
|
547
|
+
else:
|
548
|
+
_copy_file(item['src'], item['dest'])
|
515
549
|
|
516
550
|
w = _widget.Widget()
|
517
551
|
w.config = json.loads(study.__str__())
|
@@ -1,9 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: revisit
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.28
|
4
4
|
Requires-Dist: anywidget
|
5
5
|
Requires-Dist: pandas
|
6
6
|
Requires-Dist: pydantic>=2.10.5
|
7
|
+
Requires-Dist: revisit-server>=0.0.1
|
7
8
|
Provides-Extra: dev
|
8
9
|
Requires-Dist: jupyterlab; extra == 'dev'
|
9
10
|
Requires-Dist: watchfiles; extra == 'dev'
|
@@ -101,11 +102,40 @@ my_response = rvt.response(
|
|
101
102
|
)
|
102
103
|
```
|
103
104
|
|
105
|
+
## `studyMetadata(**kwargs: dict) -> StudyMetadata`
|
106
|
+
|
107
|
+
## `uiConfig(**kwargs: dict) -> UIConfig`
|
108
|
+
|
109
|
+
### `studyConfig(studyMetadata: StudyMetadata, uiConfig: UIConfig, sequence: ComponentBlock, schema: str, components: Optional[List[Component]]) -> StudyConfig`
|
110
|
+
|
111
|
+
Instantiates a the final `StudyConfig` based on the `UIConfig`, `StudyMetadata`, `Sequence`, and `Components` input. Note that the components list is completely optional: using the `studyConfig` factory function automatically populates all components based on their presence in the sequence.
|
112
|
+
|
113
|
+
### **Parameters**:
|
114
|
+
| Parameter | Type | Description | Default Value |
|
115
|
+
|-----------|--------|---------------------------------|---------------|
|
116
|
+
| `studyMetadata` | `StudyMetadata` | An instance of the `StudyMetadata` class | _None_ |
|
117
|
+
| `uiConfig` | `UIConfig` | An instance of the `UIConfig` class | _None_ |
|
118
|
+
| `sequence` | `ComponentBlock` | The top level member of your sequence. | _None_ |
|
119
|
+
| `components` | `Optional[List[Component]]` | The list of `Component`s to be added to the config. This is automatically populated based on the inputted sequence | `[]` |
|
120
|
+
| `schema` | `str` |The valid `$schema` value for the config | _None_ |
|
121
|
+
|
122
|
+
### **Returns**:
|
123
|
+
- `StudyConfig`: Returns an instantiation of the StudyConfig class.
|
124
|
+
|
125
|
+
### **Raises**:
|
126
|
+
- `RevisitError`: If the required properties are not specified, and exception will be raised.
|
127
|
+
|
128
|
+
### **Example**:
|
129
|
+
|
130
|
+
```python
|
131
|
+
|
132
|
+
```
|
133
|
+
|
104
134
|
# Classes
|
105
135
|
|
106
136
|
## `Component`
|
107
137
|
|
108
|
-
|
138
|
+
The class that is instantiated when calling the `component` factory function. Used to define the components in the study configuration file.
|
109
139
|
|
110
140
|
### **Attributes**:
|
111
141
|
| Attribute | Type | Description | Default Value |
|
@@ -1,10 +1,10 @@
|
|
1
1
|
revisit/StudyConfigSchema.json,sha256=xtzwZifuPJoiHASx0o8PHqBuh5L30mjBlhQ5eqsYm10,132168
|
2
2
|
revisit/__init__.py,sha256=QCvYt8m9QwpjcK4dv6GlLMUDCzRXGy16cua1r2biNCg,255
|
3
3
|
revisit/models.py,sha256=FRy8IlUAtDS3gdmZwwvqR935lbViTPnnr7k0CAkDkzI,134084
|
4
|
-
revisit/revisit.py,sha256=
|
4
|
+
revisit/revisit.py,sha256=cLCXFrUP0H7IXAsZWFegO6EJBIXuBPl-NKl68-3Fem4,29532
|
5
5
|
revisit/widget.py,sha256=VvFqRvvvn86fW8ASe1pxaAvh5ZLvvSRThI5XtlCdgcg,915
|
6
6
|
revisit/static/widget.css,sha256=TLu5F6k0CvowQtmApPswG-JZUXYszo7a10dVWKnZsIg,647
|
7
7
|
revisit/static/widget.js,sha256=jjc-RvauEnU8dHCR7oGSjg0y1CRXtAlw1-4yDeSbdKE,186472
|
8
|
-
revisit-0.0.
|
9
|
-
revisit-0.0.
|
10
|
-
revisit-0.0.
|
8
|
+
revisit-0.0.28.dist-info/METADATA,sha256=dwgAyxwbnoNV6YIq8pfjbRG9VRGM9PLfHSv1OIymKkk,24407
|
9
|
+
revisit-0.0.28.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
10
|
+
revisit-0.0.28.dist-info/RECORD,,
|
File without changes
|