Skip to content

Commit

Permalink
Merge pull request #133 from FlickerSoul/dev
Browse files Browse the repository at this point in the history
Fix recorder bug and translation display
  • Loading branch information
FlickerSoul authored Jan 17, 2021
2 parents ab12e36 + 1270da7 commit ebdc67e
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 51 deletions.
5 changes: 4 additions & 1 deletion backend/bundle/seeker/sight.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ def trace(self, frame, event, arg):
self.recorder.add_vc_to_previous_record(identifier_string, value)
self.write('{indent}{newish_string}{name} = {value_repr}'.format(**locals()))
elif old_local_reprs[name][1] != value_repr:
self.recorder.add_vc_to_previous_record(identifier_string, value)
if event == 'return':
self.recorder.add_vc_to_last_record(identifier_string, value)
else:
self.recorder.add_vc_to_previous_record(identifier_string, value)
self.write('{indent}Modified var:.. {name} = {value_repr}'.format(**locals()))

# #
Expand Down
2 changes: 1 addition & 1 deletion backend/bundle/server_utils/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
REQUEST_GRAPH_NAME: str = 'graph'

REQUEST_VERSION_NAME: str = 'version'
VERSION: str = '0.2.1'
VERSION: str = '0.2.2'

SERVER_LOG = None

Expand Down
2 changes: 1 addition & 1 deletion backend/bundle/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def read_file(filename):

setuptools.setup(
name="bundle",
version="0.2.1",
version="0.2.2",
packages=setuptools.find_packages(exclude=['tests*']),
author="Heyuan Zeng",
author_email="[email protected]",
Expand Down
35 changes: 29 additions & 6 deletions backend/bundle/tests/utils_tests/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __ne__(self, other):

def test_json_dump(empty_recorder):
result_string = [{'accesses': None,
'line': 0,
'line': _anything,
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
'repr': None,
'type': 'init'},
Expand All @@ -189,7 +189,7 @@ def test_json_dump(empty_recorder):
'python_id': _anything,
'repr': 'Node(1)',
'type': 'Node'}],
'line': 1,
'line': _anything,
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
'python_id': _anything,
'repr': '1',
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_json_dump(empty_recorder):
'repr': '9',
'type': 'Number'}}],
'type': 'Mapping'}],
'line': 2,
'line': _anything,
'variables': {'main\u200b@var_1': {'color': '#A6CEE3',
'python_id': _anything,
'repr': '1',
Expand All @@ -277,7 +277,7 @@ def test_json_dump(empty_recorder):
'python_id': _anything,
'repr': 'None',
'type': 'None'}}},
{'accesses': None, 'line': 20, 'variables': None}]
{'accesses': None, 'line': _anything, 'variables': None}]
first_line_no = 1
empty_recorder.add_record(first_line_no)

Expand Down Expand Up @@ -354,6 +354,30 @@ def test_recursive():
'repr': [],
'type': 'List'}}},
{'accesses': None, 'line': _anything, 'variables': None},
{'accesses': None,
'line': _anything,
'variables': {'t\u200b@a': {'color': '#A6CEE3',
'python_id': _anything,
'repr': [{'color': '#828282',
'python_id': _anything,
'repr': [{'color': '#828282',
'python_id': _anything,
'repr': '1',
'type': 'Number'},
{'color': '#828282',
'python_id': _anything,
'repr': '2',
'type': 'Number'},
{'color': '#828282',
'python_id': _anything,
'repr': '3',
'type': 'Number'},
{'color': '#828282',
'python_id': _anything,
'repr': None,
'type': 'reference'}],
'type': 'List'}],
'type': 'List'}}},
{'accesses': None,
'line': _anything,
'variables': {'t\u200b@a': {'color': '#A6CEE3',
Expand Down Expand Up @@ -381,8 +405,7 @@ def test_recursive():
'python_id': _anything,
'repr': '4',
'type': 'Number'}],
'type': 'List'}}},
{'accesses': None, 'line': _anything, 'variables': None}]
'type': 'List'}}}]

tracer.set_new_recorder(Recorder())

Expand Down
8 changes: 4 additions & 4 deletions backend/server/backend/intel_wrappers/intel_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ def __init__(self):
'tutorials': tutorial_anchors_validator
}, post_actions=[self._execute_code_after_submission])

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

def load_model_var(self, loaded_model: Graph) -> None:
super().load_model_var(loaded_model)
Expand Down Expand Up @@ -242,11 +242,11 @@ def __init__(self):
'code': code_validator
}, post_actions=[self._execute_code_after_submission])

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

def load_model_var(self, loaded_model: Code) -> None:
super().load_model_var(loaded_model)
Expand Down
16 changes: 11 additions & 5 deletions backend/server/backend/intel_wrappers/wrapper_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from abc import abstractmethod, ABC

from typing import Optional, Iterable, Mapping, Callable, Any, Type, Union, MutableMapping, TypeVar, Generic, Sequence
from typing import Optional, Iterable, Mapping, Callable, Any, Type, Union, MutableMapping, TypeVar, Generic, Sequence, \
List

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

def _perform_post_actions(self) -> None:
def _perform_post_actions(self) -> List[Any]:
output = []
for action in self.actions_:
action()
output.append(action())
return output


_S = TypeVar('_S', bound=UUIDMixin)
Expand Down Expand Up @@ -215,7 +218,7 @@ def _finalize_model_helper(self, overwrite: bool) -> None:
self.validate()
self.overwrite_model()

def finalize_model(self, overwrite: bool = True, validate: bool = True) -> None:
def finalize_model(self, overwrite: bool = True, validate: bool = True) -> Mapping[str, Any]:
with transaction.atomic():
self.prepare_model()
is_newly_created = self.get_model(validate=validate)
Expand All @@ -227,7 +230,10 @@ def finalize_model(self, overwrite: bool = True, validate: bool = True) -> None:
if overwrite and validate:
self.save_model()

self._perform_post_actions()
post_action_output = self._perform_post_actions()
return {
'post_action_output': post_action_output
}


_V = TypeVar('_V', bound=PublishedMixin)
Expand Down
2 changes: 1 addition & 1 deletion backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def read_file(filename):

setuptools.setup(
name="Graphery Servers",
version="0.24.3",
version="0.24.5",
packages=setuptools.find_packages(exclude=['tests*']),
install_requires=read_file('requirements.txt'),
author="Heyuan Zeng",
Expand Down
2 changes: 1 addition & 1 deletion graphery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphery",
"version": "0.24.3",
"version": "0.24.5",
"private": true,
"repository": {
"type": "git",
Expand Down
11 changes: 9 additions & 2 deletions graphery/src/components/ControlPanel/editors/CodeCreation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<IDCard :id="codeObject.id" />
<q-card id="editor-wrapper" class="q-py-md q-px-sm q-mb-md">
<div style="height: 70vh;" id="editor"></div>
<q-inner-loading :showing="editor === null">
<q-inner-loading :showing="editor === null || loadingContent">
<q-spinner-pie size="64px" color="primary" />
</q-inner-loading>
</q-card>
Expand Down Expand Up @@ -37,13 +37,19 @@
</div>

<div id="submit-section">
<SubmitButton class="full-width" :action="postCode" />
<SubmitButton
class="full-width"
:loading="loadingContent"
:action="postCode"
/>
</div>
</template>
</EditorFrame>
<JsonCreation
ref="resultJsonEditor"
:codeId="codeObject.id"
:codeContent="this.codeObject.code"
:updating="loadingContent"
/>
</template>
</ControlPanelContentFrame>
Expand Down Expand Up @@ -168,6 +174,7 @@
successDialog({
message: 'Update Code Successfully!',
});
this.$refs.resultJsonEditor?.fetchTutorialGraphs();
})
.catch((err) => {
errorDialog({
Expand Down
47 changes: 20 additions & 27 deletions graphery/src/components/ControlPanel/editors/JsonCreation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,21 @@
outlined
map-options
option-label="name"
:disable="loadingContent"
:loading="loadingContent"
:disable="customLoading"
:loading="customLoading"
/>
</div>
<div>
<q-btn
label="Exec"
:loading="loadingContent"
@click="notAvailableMessage"
class="q-mr-sm"
/>
<q-btn
label="Exec Locally"
:loading="loadingContent"
@click="execCodeOnCurrentGraph"
class="q-mr-sm"
/>
<q-btn
label="Exec All"
:loading="loadingContent"
@click="notAvailableMessage"
:loading="customLoading"
@click="execCodeOnCurrentGraphLocally"
class="q-mr-sm"
/>
<q-btn
label="Exec All Locally"
:loading="loadingContent"
@click="execCodeOnAllGraphs"
:loading="customLoading"
@click="execCodeOnAllGraphsLocally"
class="q-mr-sm"
/>
</div>
Expand All @@ -53,7 +41,7 @@
type="textarea"
outlined
label="Execution Result Json (Read Only)"
:loading="loadingContent"
:loading="customLoading"
/>
</div>
</InfoCard>
Expand All @@ -62,7 +50,7 @@
<JSONSubmissionAttentionCard />
<SubmitButton
class="full-width"
:loading="loadingContent"
:loading="customLoading"
:action="postExecJson"
/>
</template>
Expand All @@ -80,14 +68,13 @@
errorDialog,
successDialog,
warningDialog,
notAvailableMessage,
} from '@/services/helpers';
import pushCodeToLocalMixin from '@/components/mixins/PushCodeToLocalMixin';
import PushCodeToLocalMixin from '@/components/mixins/PushCodeToLocalMixin';
import { newModelUUID } from '@/services/params';
export default {
props: ['codeId', 'codeContent'],
mixins: [loadingMixin, pushCodeToLocalMixin],
props: ['codeId', 'codeContent', 'updating'],
mixins: [loadingMixin, PushCodeToLocalMixin],
components: {
JSONSubmissionAttentionCard: () =>
import(
Expand All @@ -113,6 +100,9 @@
this.execResults[this.graphChoice.id]
);
},
customLoading() {
return this.loadingContent || this.updating;
},
allowSubmit() {
if (this.graphOptions) {
if (this.graphOptions.length === 0) {
Expand Down Expand Up @@ -160,6 +150,10 @@
data.code.execresultjsonSet.forEach((obj) => {
this.execResults[obj.graph.id] = obj.json;
});
successDialog({
message: 'Fetched result JSON set.',
});
})
.catch((err) => {
errorDialog({
Expand All @@ -185,7 +179,7 @@
null
);
},
async execCodeOnCurrentGraph() {
async execCodeOnCurrentGraphLocally() {
if (this.graphChoice) {
const graphJson = JSON.parse(this.graphChoice.cyjs);
const graphId = this.graphChoice.id;
Expand All @@ -198,7 +192,7 @@
});
}
},
async execCodeOnAllGraphs() {
async execCodeOnAllGraphsLocally() {
this.startLoading();
for (const obj of this.graphOptions) {
await this.localExec(JSON.parse(obj.cyjs), obj.id);
Expand Down Expand Up @@ -233,7 +227,6 @@
this.finishedLoading();
});
},
notAvailableMessage,
},
mounted() {
this.fetchTutorialGraphs();
Expand Down
2 changes: 1 addition & 1 deletion graphery/src/components/framework/GraphInfoPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
successDialog(
{
message: this.$t(
'graph.You can also edit this in the Settings page.'
'graph.You can also edit this in the Settings page'
),
},
3000
Expand Down
2 changes: 1 addition & 1 deletion graphery/src/services/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def main() -> None:
# https://github.com/FlickerSoul/Graphery/tree/master/backend/bundle#readme
`;

export const localServerTargetVersion = '0.2.1';
export const localServerTargetVersion = '0.2.2';

0 comments on commit ebdc67e

Please sign in to comment.