-
Notifications
You must be signed in to change notification settings - Fork 55
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
Creating C and Python bindings for all functionality used by Repl. Refactoring Repl to call through Python by default #450
Conversation
…n-UI parts of the REPL environment
…action, in the Python build path
…to initialize the logger (the platform Environment) See trueagi-io#314
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luke, thanks for the such amount of work. Didn't look at the REPL code changes yet, but posting current comments to not slow this down.
…default initialization was used
…ly fail Reworking C API to use builder object, rather than relying on a static state. This allows flexibility to initialize the environment from multiple threads - although that is still ugly and discouraged
…vironments to be initialized and used from C & Python layers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luke, I am very sorry for a late review. Thanks for adding ability to initialize runner with instance of the environment 👍 I propose to go further with fixing the rest of comments and merging it.
One major question to me here is should we keep some shared instance of the environment or just replace it by asking user to create a default instance if it is needed?
lib/src/metta/runner/mod.rs
Outdated
/// | ||
/// NOTE: If `env_builder` is `None`, the platform environment will be used | ||
/// NOTE: This function does not load any stdlib atoms, nor run the [Environment]'s 'init.metta' | ||
pub fn new_with_space(space: DynSpace, tokenizer: Shared<Tokenizer>, env_builder: Option<EnvBuilder>) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intentionally use EnvBuilder
instead of Environment
here? We could also pass a Builder
a Environment
instance here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I felt like having the built environment in an owned state complicated the API (especially in other languages) without much gain.
So now Environment
is like Path
; ie. the API user can have access &Environment references, and call methods on it, but they can't own a naked Environment
outside the hyperon crate.
…vec_t with a Python list of atoms Changing `sexpr_parser_t` from wrapped Shared ptr to wrapped Box Changing RunnerState API to take ownership of the parser and, rather than asking the caller to provide the parser each step. There is no good reason to switch parsers with the same RunnerState and switching them is just asking for bugs Adding “with_atoms” alternative to create a RunnerState
…ific stdlib loader
…se.py, because error expressions are not part of the core MeTTa spec
…APIs, and adding some infrastructure around error expression atoms
I believe I have addressed all of the feedback in this PR. The only remaining issue is whether or not |
None => EMPTY_SYMBOL, | ||
}; | ||
if let Some(err_code) = err_code { | ||
Atom::expr([ERROR_SYMBOL, err_atom, err_code, Atom::sym(message)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment Error
expressions use only two arguments: first is atom and second one is either error code or custom message. Also atom is required argument. Which use-cases do you have in mind for the changes made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was that sometimes both an err_code
and a custom message are desirable. The caller can branch on an err code in a way that they can't reliably branch on a human-readable message. But a human-readable message can specify additional information, including composing a message with specific details about the error.
|
||
//QUESTION: These functions below seem to only be used in tests. If that's the case, should we | ||
// move them into a test-only module so they aren't exposed as part of the public API? | ||
//Alternatively rewrite the tests to use a runner? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please move them into a test-only module for now. There is no much sense in re-writing these tests, they will vanish after migration to the minimal interpreter.
…r with a custom space
…er handles Re-adding runner-equivalence test
… doesn't appear to be the same as encountering parse errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Luke, I approved it, please feel free to merge when you are ready.
I think this is ready for merge after these fixes. As discussed, I'll take care of the extraneous API in the metta/mod.rs file in a separate PR. |
Thanks Luke, I merged it |
Thanks Luke. Looks cool and working! |
Creating C and Python bindings for all functionality used by Repl.
Refactoring Repl to call through Python by default.
Changes include: