-
Notifications
You must be signed in to change notification settings - Fork 59
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
Import mechanism in DaphneDSL #214
Comments
We need this feature to be able to reuse DaphneDSL code in other DaphneDSL scripts. For instance, we want to create a DAPHNE standard library of high-level data analysis and ML functions, which are in turn implemented as functions in DaphneDSL. Then, users should be able to simply import those library functions and use them in their own DaphneDSL scripts. It could look like this:
The particulars of this feature are yet to be designed. Here is some inspiration:
|
Assigned to @akroviakov . |
Importing a DaphneDSL script file should have roughly the same effect as pasting its contents literally. |
Actually, I explicitly chose Thus, I would really use
The k-means was only a syntax example. Was not meant to exactly match the kmeans script ;) . |
I'm trying to write unit test cases that use information from const char* configFilePath = "test/api/cli/import/UserConfig.json";
DYNAMIC_SECTION(configFilePath) {
compareDaphneToRef(
"test/api/cli/import/import_success_4.txt",
"test/api/cli/import/import_success_4.daphne", "--config", configFilePath
);
} It fails, so I added a check for user config existence: ConfigParser::fileExists(args["--config"]) And it showed
The member Those scripts that do not interact with UserConfig work fine regardless of whether |
Unfortunately, I cannot reproduce this problem on main. I tried modifying the existing script-level test case
When I modify the "config success" test case in So I suspect that something is going wrong in the parser in your code. If you cannot find the error, please create a draft PR, so that I can try out your state of the code. PS: Since you mention |
Please correct me if I'm wrong, but aren't DaphneDSLParser parser(scriptArgsFinal); where they are stored as DaphneDSLParser(std::unordered_map<std::string, std::string> args) : args(args) {
//
} which are then passed to the visitor in DaphneDSLVisitor visitor(module, builder, args); and so on the console call like
we can access Also, I found what was the issue with: compareDaphneToRef(
"test/api/cli/import/import_success_4.txt",
"test/api/cli/import/import_success_4.daphne", "--config", configFilePath
); It appears that in unit test cases
Do I misunderstand something about the current usage of And a bit of a separate question, we need to read some paths in
The first option seems better than reading json on each import, but maybe you have some precautions against dragging |
Ok, I see my confusion with unit tests and config passing.
since it is not conform to daphne's usage stated in
so a correct call would be:
And just if someone would need the difference explained: What I was trying to do is to retrieve So in short, I haven't noticed that I violated daphne's usage stated in And yes, the question above whether to use |
In GitLab by @pdamme on Mar 8, 2022, 18:20
Like many other script/programming languages, DaphneDSL should have some kind of import/include mechanism enabling users to employ code in other files. This is necessary for both, user files and DaphneDSL standard lib files.
Open questions include how exactly the file to include shall be specified and how exactly it will be included.
The text was updated successfully, but these errors were encountered: