Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish items #140

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
[![jaseci_core](https://github.com/Jaseci-Labs/jaseci/actions/workflows/jaseci_core_build.yml/badge.svg?branch=main)](https://github.com/Jaseci-Labs/jaseci/actions/workflows/jaseci_core_build.yml)
[![jaseci_serv](https://github.com/Jaseci-Labs/jaseci/actions/workflows/jaseci_serv_build.yml/badge.svg?branch=main)](https://github.com/Jaseci-Labs/jaseci/actions/workflows/jaseci_serv_build.yml)

# Jaseci Release Notes

## Version 1.3.1

### Updates

- New Feature: `std.get_report` gives the what is to be reported so far
- Improvement: General polish items of JSCTL UI
- Improvement: Raised the default core logging reporting level to warning

## Version 1.3

### Updates
Expand Down
3 changes: 2 additions & 1 deletion jaseci_core/jaseci/actions/live_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from jaseci.actions.remote_actions import ACTIONS_SPEC_LOC
from jaseci.actions.remote_actions import serv_actions, mark_as_remote
import requests
import os, sys
import os
import sys
import inspect

live_actions = {}
Expand Down
8 changes: 8 additions & 0 deletions jaseci_core/jaseci/actions/standard/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ def revoke_perms(obj: element, mast: element, meta):
mast = meta['h'].get_obj(meta['m_id'], uuid.UUID(meta['m_id']))
return mast.object_perms_revoke(obj=obj,
mast=mast)['success']


@jaseci_action()
def get_report(meta):
"""
Get current report so far for walker run
"""
return meta['interp'].report
7 changes: 3 additions & 4 deletions jaseci_core/jaseci/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def provide_internal_default(self, param):
else:
return glob_id
return self.active_snt_id
if(param == 'gph' and self.active_gph_id):
return self.active_gph_id
if(param == 'nd' and self.active_gph_id):
return self.active_gph_id
if(param == 'gph' or param == 'nd'):
return self.active_gph_id if self.active_gph_id else \
self.interface_error('No default graph node available!')
return None

def interface_error(self, err, stack=None):
Expand Down
5 changes: 3 additions & 2 deletions jaseci_core/jaseci/attr/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, preset_in_out=None, access_list=None,
self.access_list = access_list
super().__init__(*args, **kwargs)

def trigger(self, param_list, scope):
def trigger(self, param_list, scope, interp):
"""
param_list should be passed as list of values to lib functions
Also note that Jac stores preset_in_out as input/output list of hex
Expand All @@ -34,5 +34,6 @@ def trigger(self, param_list, scope):
result = live_actions[
self.value](*param_list,
meta={'m_id': scope.parent._m_id,
'h': scope.parent._h, 'scope': scope})
'h': scope.parent._h, 'scope': scope,
'interp': interp})
return result
5 changes: 3 additions & 2 deletions jaseci_core/jaseci/jac/interpreter/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ def run_func_call(self, jac_ast):
param_list = self.run_expr_list(kid[1]).value
if (isinstance(atom_res.value, action)):
try:
ret = atom_res.value.trigger(param_list, self._jac_scope)
ret = atom_res.value.trigger(
param_list, self._jac_scope, self)
except Exception as e:
self.rt_error(f'{e}', jac_ast)
ret = None
Expand Down Expand Up @@ -861,7 +862,7 @@ def run_dict_built_in(self, jac_ast, atom_res):
kid = jac_ast.kid
if (kid[0].name == "KW_KEYS"):
if(isinstance(atom_res.value, dict)):
return jac_value(self, value=atom_res.value.keys())
return jac_value(self, value=list(atom_res.value.keys()))
else:
self.rt_error(f'Cannot get keys of {atom_res}. '
f'Not Dictionary!', kid[0])
Expand Down
2 changes: 1 addition & 1 deletion jaseci_core/jaseci/jac/interpreter/walker_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def run_preset_in_out(self, jac_ast, obj, act):
if(kid[1].name == "expr_list"):
param_list = m.run_expr_list(kid[1]).value
try:
result = act.trigger(param_list, self._jac_scope)
result = act.trigger(param_list, self._jac_scope, self)
except Exception as e:
self.rt_error(f'{e}', jac_ast)
result = None
Expand Down
12 changes: 12 additions & 0 deletions jaseci_core/jaseci/tests/jac_test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,15 @@
report &(spawn here walker::print);
}
"""

std_get_report = \
"""
walker init {
report 3;
report 5;
report 6;
report 7;
report std.get_report();
report 8;
}
"""
11 changes: 11 additions & 0 deletions jaseci_core/jaseci/tests/test_jac.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,14 @@ def test_walker_spawn_unwrap_check(self):
test_walker.run()
rep = test_walker.report
self.assertTrue(rep[0].startswith('urn:uuid'))

def test_std_get_report(self):
gph = graph(m_id='anon', h=mem_hook())
sent = sentinel(m_id='anon', h=gph._h)
sent.register_code(jtc.std_get_report)
test_walker = \
sent.walker_ids.get_obj_by_name('init')
test_walker.prime(gph)
test_walker.run()
rep = test_walker.report
self.assertEqual(rep, [3, 5, 6, 7, [3, 5, 6, 7], 8])
6 changes: 3 additions & 3 deletions jaseci_core/jaseci/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


# Get an instance of a logger
def connect_logger_handler(target_logger, handler):
def connect_logger_handler(target_logger, handler, level=logging.WARN):
"""Attaches standard formatting and adds handler to logger"""
target_logger.setLevel(logging.INFO)
target_logger.setLevel(level)
handler.setFormatter(
logging.Formatter(
'%(asctime)s - %(levelname)s - %(funcName)s: %(message)s')
Expand All @@ -33,7 +33,7 @@ def connect_logger_handler(target_logger, handler):

app_logger = logging.getLogger('app')
if(len(app_logger.handlers) < 1):
connect_logger_handler(app_logger, logging.StreamHandler())
connect_logger_handler(app_logger, logging.StreamHandler(), logging.INFO)


def log_var_out(val):
Expand Down