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

File based predef in analogy to ammonite #263

Closed
mpacer opened this issue Nov 29, 2018 · 3 comments
Closed

File based predef in analogy to ammonite #263

mpacer opened this issue Nov 29, 2018 · 3 comments

Comments

@mpacer
Copy link

mpacer commented Nov 29, 2018

In Ammonite, you can pass in a file to the --predef command line option. It seems that almond only allows you to pass in a string that implements some scala code.

I tried to get the same effect in a variety of ways

  • I attempted to cat a file into the option's value via the command line --predef $(cat "${PATH_TO_PREDEF}/spark_predef.scala"), and while that didn't cause it to fail to start… none of the content was actually run.
  • cat and join everything onto a single line, adding semi-colons to the end of lines based on key words.
    • This effectively required getting rid of all comments; but still did not work
  • passing in a $exec and $file command to load the script
    • This didn't work because the dependencies had not yet been resolved at the time that they needed to be inside the script (see http://ammonite.io/#Multi-stageScripts)
    • or if I added a @ the almond interpreter attempted to reload all of the other predefs again (as well as the predef I supplied) and crashed
    • or if I removed the need for those dependencies to be completely resolved… it also attempted to reload the other predefs again (as well as the predef I supplied) and then crashed

So… I'm thinking there's no good way to do this right now.

Is there a reason almond does not replicate ammonite's --predef file functionality? If the reason is only "we haven't done that yet", how would we go about changing that?

@jameskoch2 @alexarchambault @MSeal

@jameskoch
Copy link

jameskoch commented Nov 29, 2018

I would use this as well. For now, since I had already created my own kernel using the almond ScalaInterpreter, I just read the file in my own code, then pass this into the predef constructor argument.

@mpacer
Copy link
Author

mpacer commented Nov 29, 2018

@jameskoch could you be more explicit about the steps involved in that?

When you say that you read the file in your own code, where does that code live and what runs it?

What do you end up passing into the predef constructor?

@alexarchambault
Copy link
Member

I agree this ought to be fixed. I'll look into it (or if any of you feel like sending a PR…)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants