Skip to content

Commit ebdc67e

Browse files
authored
Merge pull request #133 from FlickerSoul/dev
Fix recorder bug and translation display
2 parents ab12e36 + 1270da7 commit ebdc67e

File tree

12 files changed

+83
-51
lines changed

12 files changed

+83
-51
lines changed

backend/bundle/seeker/sight.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ def trace(self, frame, event, arg):
466466
self.recorder.add_vc_to_previous_record(identifier_string, value)
467467
self.write('{indent}{newish_string}{name} = {value_repr}'.format(**locals()))
468468
elif old_local_reprs[name][1] != value_repr:
469-
self.recorder.add_vc_to_previous_record(identifier_string, value)
469+
if event == 'return':
470+
self.recorder.add_vc_to_last_record(identifier_string, value)
471+
else:
472+
self.recorder.add_vc_to_previous_record(identifier_string, value)
470473
self.write('{indent}Modified var:.. {name} = {value_repr}'.format(**locals()))
471474

472475
# #

backend/bundle/server_utils/params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
REQUEST_GRAPH_NAME: str = 'graph'
2929

3030
REQUEST_VERSION_NAME: str = 'version'
31-
VERSION: str = '0.2.1'
31+
VERSION: str = '0.2.2'
3232

3333
SERVER_LOG = None
3434

backend/bundle/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read_file(filename):
1111

1212
setuptools.setup(
1313
name="bundle",
14-
version="0.2.1",
14+
version="0.2.2",
1515
packages=setuptools.find_packages(exclude=['tests*']),
1616
author="Heyuan Zeng",
1717
author_email="[email protected]",

backend/bundle/tests/utils_tests/test_recorder.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __ne__(self, other):
167167

168168
def test_json_dump(empty_recorder):
169169
result_string = [{'accesses': None,
170-
'line': 0,
170+
'line': _anything,
171171
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
172172
'repr': None,
173173
'type': 'init'},
@@ -189,7 +189,7 @@ def test_json_dump(empty_recorder):
189189
'python_id': _anything,
190190
'repr': 'Node(1)',
191191
'type': 'Node'}],
192-
'line': 1,
192+
'line': _anything,
193193
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
194194
'python_id': _anything,
195195
'repr': '1',
@@ -255,7 +255,7 @@ def test_json_dump(empty_recorder):
255255
'repr': '9',
256256
'type': 'Number'}}],
257257
'type': 'Mapping'}],
258-
'line': 2,
258+
'line': _anything,
259259
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
260260
'python_id': _anything,
261261
'repr': '1',
@@ -277,7 +277,7 @@ def test_json_dump(empty_recorder):
277277
'python_id': _anything,
278278
'repr': 'None',
279279
'type': 'None'}}},
280-
{'accesses': None, 'line': 20, 'variables': None}]
280+
{'accesses': None, 'line': _anything, 'variables': None}]
281281
first_line_no = 1
282282
empty_recorder.add_record(first_line_no)
283283

@@ -354,6 +354,30 @@ def test_recursive():
354354
'repr': [],
355355
'type': 'List'}}},
356356
{'accesses': None, 'line': _anything, 'variables': None},
357+
{'accesses': None,
358+
'line': _anything,
359+
'variables': {'t\u200b@a': {'color': '#A6CEE3',
360+
'python_id': _anything,
361+
'repr': [{'color': '#828282',
362+
'python_id': _anything,
363+
'repr': [{'color': '#828282',
364+
'python_id': _anything,
365+
'repr': '1',
366+
'type': 'Number'},
367+
{'color': '#828282',
368+
'python_id': _anything,
369+
'repr': '2',
370+
'type': 'Number'},
371+
{'color': '#828282',
372+
'python_id': _anything,
373+
'repr': '3',
374+
'type': 'Number'},
375+
{'color': '#828282',
376+
'python_id': _anything,
377+
'repr': None,
378+
'type': 'reference'}],
379+
'type': 'List'}],
380+
'type': 'List'}}},
357381
{'accesses': None,
358382
'line': _anything,
359383
'variables': {'t\u200b@a': {'color': '#A6CEE3',
@@ -381,8 +405,7 @@ def test_recursive():
381405
'python_id': _anything,
382406
'repr': '4',
383407
'type': 'Number'}],
384-
'type': 'List'}}},
385-
{'accesses': None, 'line': _anything, 'variables': None}]
408+
'type': 'List'}}}]
386409

387410
tracer.set_new_recorder(Recorder())
388411

backend/server/backend/intel_wrappers/intel_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ def __init__(self):
186186
'tutorials': tutorial_anchors_validator
187187
}, post_actions=[self._execute_code_after_submission])
188188

189-
def _execute_code_after_submission(self) -> None:
189+
def _execute_code_after_submission(self) -> List:
190190
code_list: List[Code] = list(tutorial.code
191191
for tutorial in self.model.tutorials.filter(code__isnull=False))
192192
graph_list: List[Graph] = [self.model]
193193
failed_missions = _result_json_updater(code_list, graph_list)
194-
print(failed_missions)
194+
return failed_missions
195195

196196
def load_model_var(self, loaded_model: Graph) -> None:
197197
super().load_model_var(loaded_model)
@@ -242,11 +242,11 @@ def __init__(self):
242242
'code': code_validator
243243
}, post_actions=[self._execute_code_after_submission])
244244

245-
def _execute_code_after_submission(self) -> None:
245+
def _execute_code_after_submission(self) -> List:
246246
code_list: List[Code] = [self.model]
247247
graph_list: QuerySet[Graph] = self.tutorial.model.graph_set.all()
248248
failed_missions = _result_json_updater(code_list, graph_list)
249-
print(failed_missions)
249+
return failed_missions
250250

251251
def load_model_var(self, loaded_model: Code) -> None:
252252
super().load_model_var(loaded_model)

backend/server/backend/intel_wrappers/wrapper_bases.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from abc import abstractmethod, ABC
44

5-
from typing import Optional, Iterable, Mapping, Callable, Any, Type, Union, MutableMapping, TypeVar, Generic, Sequence
5+
from typing import Optional, Iterable, Mapping, Callable, Any, Type, Union, MutableMapping, TypeVar, Generic, Sequence, \
6+
List
67

78
from django.core.exceptions import ValidationError
89
from django.db import models, IntegrityError, transaction
@@ -122,9 +123,11 @@ def __init__(self, actions: Sequence[Callable] = ()) -> None:
122123
def set_actions(self, actions: Sequence[Callable]) -> None:
123124
self.actions_ = actions
124125

125-
def _perform_post_actions(self) -> None:
126+
def _perform_post_actions(self) -> List[Any]:
127+
output = []
126128
for action in self.actions_:
127-
action()
129+
output.append(action())
130+
return output
128131

129132

130133
_S = TypeVar('_S', bound=UUIDMixin)
@@ -215,7 +218,7 @@ def _finalize_model_helper(self, overwrite: bool) -> None:
215218
self.validate()
216219
self.overwrite_model()
217220

218-
def finalize_model(self, overwrite: bool = True, validate: bool = True) -> None:
221+
def finalize_model(self, overwrite: bool = True, validate: bool = True) -> Mapping[str, Any]:
219222
with transaction.atomic():
220223
self.prepare_model()
221224
is_newly_created = self.get_model(validate=validate)
@@ -227,7 +230,10 @@ def finalize_model(self, overwrite: bool = True, validate: bool = True) -> None:
227230
if overwrite and validate:
228231
self.save_model()
229232

230-
self._perform_post_actions()
233+
post_action_output = self._perform_post_actions()
234+
return {
235+
'post_action_output': post_action_output
236+
}
231237

232238

233239
_V = TypeVar('_V', bound=PublishedMixin)

backend/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read_file(filename):
1111

1212
setuptools.setup(
1313
name="Graphery Servers",
14-
version="0.24.3",
14+
version="0.24.5",
1515
packages=setuptools.find_packages(exclude=['tests*']),
1616
install_requires=read_file('requirements.txt'),
1717
author="Heyuan Zeng",

graphery/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphery",
3-
"version": "0.24.3",
3+
"version": "0.24.5",
44
"private": true,
55
"repository": {
66
"type": "git",

graphery/src/components/ControlPanel/editors/CodeCreation.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<IDCard :id="codeObject.id" />
1010
<q-card id="editor-wrapper" class="q-py-md q-px-sm q-mb-md">
1111
<div style="height: 70vh;" id="editor"></div>
12-
<q-inner-loading :showing="editor === null">
12+
<q-inner-loading :showing="editor === null || loadingContent">
1313
<q-spinner-pie size="64px" color="primary" />
1414
</q-inner-loading>
1515
</q-card>
@@ -37,13 +37,19 @@
3737
</div>
3838

3939
<div id="submit-section">
40-
<SubmitButton class="full-width" :action="postCode" />
40+
<SubmitButton
41+
class="full-width"
42+
:loading="loadingContent"
43+
:action="postCode"
44+
/>
4145
</div>
4246
</template>
4347
</EditorFrame>
4448
<JsonCreation
49+
ref="resultJsonEditor"
4550
:codeId="codeObject.id"
4651
:codeContent="this.codeObject.code"
52+
:updating="loadingContent"
4753
/>
4854
</template>
4955
</ControlPanelContentFrame>
@@ -168,6 +174,7 @@
168174
successDialog({
169175
message: 'Update Code Successfully!',
170176
});
177+
this.$refs.resultJsonEditor?.fetchTutorialGraphs();
171178
})
172179
.catch((err) => {
173180
errorDialog({

graphery/src/components/ControlPanel/editors/JsonCreation.vue

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,21 @@
1414
outlined
1515
map-options
1616
option-label="name"
17-
:disable="loadingContent"
18-
:loading="loadingContent"
17+
:disable="customLoading"
18+
:loading="customLoading"
1919
/>
2020
</div>
2121
<div>
22-
<q-btn
23-
label="Exec"
24-
:loading="loadingContent"
25-
@click="notAvailableMessage"
26-
class="q-mr-sm"
27-
/>
2822
<q-btn
2923
label="Exec Locally"
30-
:loading="loadingContent"
31-
@click="execCodeOnCurrentGraph"
32-
class="q-mr-sm"
33-
/>
34-
<q-btn
35-
label="Exec All"
36-
:loading="loadingContent"
37-
@click="notAvailableMessage"
24+
:loading="customLoading"
25+
@click="execCodeOnCurrentGraphLocally"
3826
class="q-mr-sm"
3927
/>
4028
<q-btn
4129
label="Exec All Locally"
42-
:loading="loadingContent"
43-
@click="execCodeOnAllGraphs"
30+
:loading="customLoading"
31+
@click="execCodeOnAllGraphsLocally"
4432
class="q-mr-sm"
4533
/>
4634
</div>
@@ -53,7 +41,7 @@
5341
type="textarea"
5442
outlined
5543
label="Execution Result Json (Read Only)"
56-
:loading="loadingContent"
44+
:loading="customLoading"
5745
/>
5846
</div>
5947
</InfoCard>
@@ -62,7 +50,7 @@
6250
<JSONSubmissionAttentionCard />
6351
<SubmitButton
6452
class="full-width"
65-
:loading="loadingContent"
53+
:loading="customLoading"
6654
:action="postExecJson"
6755
/>
6856
</template>
@@ -80,14 +68,13 @@
8068
errorDialog,
8169
successDialog,
8270
warningDialog,
83-
notAvailableMessage,
8471
} from '@/services/helpers';
85-
import pushCodeToLocalMixin from '@/components/mixins/PushCodeToLocalMixin';
72+
import PushCodeToLocalMixin from '@/components/mixins/PushCodeToLocalMixin';
8673
import { newModelUUID } from '@/services/params';
8774
8875
export default {
89-
props: ['codeId', 'codeContent'],
90-
mixins: [loadingMixin, pushCodeToLocalMixin],
76+
props: ['codeId', 'codeContent', 'updating'],
77+
mixins: [loadingMixin, PushCodeToLocalMixin],
9178
components: {
9279
JSONSubmissionAttentionCard: () =>
9380
import(
@@ -113,6 +100,9 @@
113100
this.execResults[this.graphChoice.id]
114101
);
115102
},
103+
customLoading() {
104+
return this.loadingContent || this.updating;
105+
},
116106
allowSubmit() {
117107
if (this.graphOptions) {
118108
if (this.graphOptions.length === 0) {
@@ -160,6 +150,10 @@
160150
data.code.execresultjsonSet.forEach((obj) => {
161151
this.execResults[obj.graph.id] = obj.json;
162152
});
153+
154+
successDialog({
155+
message: 'Fetched result JSON set.',
156+
});
163157
})
164158
.catch((err) => {
165159
errorDialog({
@@ -185,7 +179,7 @@
185179
null
186180
);
187181
},
188-
async execCodeOnCurrentGraph() {
182+
async execCodeOnCurrentGraphLocally() {
189183
if (this.graphChoice) {
190184
const graphJson = JSON.parse(this.graphChoice.cyjs);
191185
const graphId = this.graphChoice.id;
@@ -198,7 +192,7 @@
198192
});
199193
}
200194
},
201-
async execCodeOnAllGraphs() {
195+
async execCodeOnAllGraphsLocally() {
202196
this.startLoading();
203197
for (const obj of this.graphOptions) {
204198
await this.localExec(JSON.parse(obj.cyjs), obj.id);
@@ -233,7 +227,6 @@
233227
this.finishedLoading();
234228
});
235229
},
236-
notAvailableMessage,
237230
},
238231
mounted() {
239232
this.fetchTutorialGraphs();

graphery/src/components/framework/GraphInfoPopup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
successDialog(
6161
{
6262
message: this.$t(
63-
'graph.You can also edit this in the Settings page.'
63+
'graph.You can also edit this in the Settings page'
6464
),
6565
},
6666
3000

graphery/src/services/params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def main() -> None:
2121
# https://github.com/FlickerSoul/Graphery/tree/master/backend/bundle#readme
2222
`;
2323

24-
export const localServerTargetVersion = '0.2.1';
24+
export const localServerTargetVersion = '0.2.2';

0 commit comments

Comments
 (0)