Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 30 14:37
    bhaskarmelkani starred lihaoyi/Ammonite
  • Jan 29 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 29 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 28 15:07
    ishubelko starred lihaoyi/Ammonite
  • Jan 25 22:38
    borissmidt starred lihaoyi/Ammonite
  • Jan 25 17:12

    alexarchambault on 1.6.3

    (compare)

  • Jan 25 17:11

    alexarchambault on master

    1.6.3 (compare)

  • Jan 25 15:48
    alexarchambault commented #923
  • Jan 25 01:15

    lihaoyi on gh-pages

    5ad9ae5538f23cab92ccd8c6b1617d8… (compare)

  • Jan 25 00:50

    alexarchambault on master

    Partly revert 84d48542 (#923) … (compare)

  • Jan 25 00:50
    alexarchambault closed #923
  • Jan 25 00:50
    alexarchambault closed #920
  • Jan 25 00:50
    alexarchambault closed #922
  • Jan 24 23:13
    lihaoyi commented #923
  • Jan 24 22:39
    alexarchambault closed #921
  • Jan 24 22:39
    alexarchambault commented #921
  • Jan 24 22:39
    alexarchambault edited #923
  • Jan 24 22:38
    alexarchambault opened #923
  • Jan 24 22:37
    david-bouyssie commented #919
  • Jan 24 21:33
    nksureshkumar commented #922
Sören Brunk
@sbrunk
@bmaso perhaps not exactly the same but you can use Ammonite with support for embedded plots in an actual Jupyter notebook via https://almond.sh
Brian Maso
@bmaso
@sbrunk Thanks. I hadn't realized jupyter-scala had advanced somewhat -- last time I had tried to use it it, it was a bit krufty.
Anton Kulaga
@antonkulaga
Stupid question: how one can pre-compile ammonite script without running it?
In my docker container I have a script with one @main() method, I want to precompile when I build docker container so the user will not wait much, but I do not want the main function to be run.
ReiReiRei
@ReiReiRei
Hi all, is it any workaround for lihaoyi/Ammonite#763 ?
Alexandre Archambault
@alexarchambault
@ReiReiRei The workaround described in the issue should work with the latest releases of Ammonite.
ReiReiRei
@ReiReiRei
@alexarchambault the problem is I am using spark 2.3.1/scala 2.11 and almond-spark The highest version for scala 2.11 almond-spark is 0.6.0 and uses old version of ammonite
hmf
@hmf
I have asked this question in the Mill channel but I think it is more of a Ammonite question. How can I get the path of a class define in the a script (defined in an external file script)? I need to add this to a classpath for dynamic class loading. TIA
ReiReiRei
@ReiReiRei
@lihaoyi @alexarchambault so does it mean that ammonite does not support most stable version of spark correctly? beacase spark is officially still on 2.11 scala
Alexandre Archambault
@alexarchambault
@hmf Not 100% sure I understand your question, but repl.sess.frames.flatMap(_.classloader.inMemoryClasses) gives a list of class names / class byte code generated by the repl.
@ReiReiRei I'm afraid so, as it stands currently. 2.11 is getting quite old, 2.12 has been out for almost 3 years now(!)
ReiReiRei
@ReiReiRei
@alexarchambault but a lot of spark libs a based on only 2.11 spark ) hadoop distributions( cloudera hortonworks does not support spark based on scala 2.12 yet)
is it possible to say to old version of ammonite not to add sources to classpath ? something like this ? interp.resolutionHooks += { fetch => fetch.withClassifiers(fetch.classifiers.filter(_ != "sources")) }
hmf
@hmf
@alexarchambault Thanks for the feedback. Don't think that will do - I am running a Mill script. I need to get hold of the .class file of an object (extends PostModifier) and place it on the classpath for dynamic loading by another library (MDoc). Is this doable?
trepidacious
@trepidacious
Is it possible to disable the "extra" printing in the ammonite repl (e.g. imports, defining variables etc.)? I'm using it from almond and it's great, but I don't need the extra output, just the results of println and explicitly sending plots etc. to the worksheet.
Crosson David
@dacr

Hi, any idea why I get java.lang.ClassNotFoundException: scala.jdk.CollectionConverters$ issues with amm-2.12-1.7.4 and not with amm-2.13-1.7.4, and not at all within the test (sbt +test) of my project which cross-compiles 2.11, 2.12, 2.13 (https://github.com/dacr/drools-scripting) using scala-collection-compat library.

10:46 $ amm-2.12-1.7.4 drools-hello-world.sc 
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/sourceBridge.sc
Compiling (synthetic)/ammonite/predef/frontEndBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Compiling /home/dcr/notes/scripts/drools-hello-world.sc
drools$minushello$minusworld$HelloTest:
Drools
ammonite.$file.drools$minushello$minusworld$HelloTest$ *** ABORTED ***
...
10:48 $ amm-2.13-1.7.4 drools-hello-world.sc 
Compiling (synthetic)/ammonite/predef/interpBridge.sc
Compiling (synthetic)/ammonite/predef/sourceBridge.sc
Compiling (synthetic)/ammonite/predef/frontEndBridge.sc
Compiling (synthetic)/ammonite/predef/DefaultPredef.sc
Compiling /home/dcr/notes/scripts/drools-hello-world.sc
drools$minushello$minusworld$HelloTest:
Drools
- should say hello

I'm not sure it is a bug, if it is I'll fill a dedicated issue, the executed code is the following : https://gist.github.com/dacr/6921d569fd33182da358d6a8e383aa0a :

import $ivy.`org.scalatest::scalatest:3.0.8`
import $ivy.`fr.janalyse::drools-scripting:1.0.1`

import org.scalatest._, org.scalatest.OptionValues._
import fr.janalyse.droolscripting._

object HelloTest extends FlatSpec with Matchers {
  "Drools" should "say hello" in {
    val drl =
      """package testdrools
        |rule "hello" when
        |then
        |  insert("HELLO WORLD");
        |end
        |""".stripMargin
    val engine = DroolsEngine(drl)
    engine.fireAllRules()
    engine.getObjects.headOption.value shouldBe "HELLO WORLD"
  }
}
HelloTest.execute()
May be because ammonite is using an old release of ("org.scala-lang.modules" %% "scala-collection-compat") "2.0.0" while the latest is "2.1.2" ?
Crosson David
@dacr
Yes I've just checked it and it was coming from this old release :)
Pull request sent. lihaoyi/Ammonite#1011
nsram
@nsram_twitter
Just started using Li Haoyi's work. Needed to load jars from a local folder due to limited internet access. The following worked.
@  val jarpath = pwd / 'dev / 'jar  // local folder with jars
@  ls! jarpath | interp.load.cp
Brian Maso
@bmaso
:thumbsup: That's pretty cool
nsram
@nsram_twitter
On ubuntu, I am not seeing the color syntax highlighting for error stack trace (its all red). Colors are working normally otherwise. Amm 1.7.1
Milan Satala
@msatala

Hi guys,
ammonite-sshd doesn't run predef when running inside docker container.
I'm running ammonite embedded in play server. When I start play via runProd and connect to ammonite via ssh I get this

Compiling /home/milan/dev/traceability/traceability/server/playserver/target/universal/stage/(console)
Setting front-end. // My println in predef
Welcome to the Ammonite Repl 1.7.4

However when I run the same play server inside alpine-java docker container I only get this:

Password: 
Welcome to the Ammonite Repl 1.7.4

Any ideas?

Glen Marchesani
@fizzy33
anyone know of a simple way to use ammonite as a server side scripting language ?
Olivier Mélois
@Baccata
@fizzy33 can you refine your question ? ammonite provides you with a way to access a repl over ssh, and you can can embed it in a server : http://ammonite.io/#RemoteREPL , but that might not be what you need
@msatala chances your docker container doesn't see your predef. It's likely a docker problem, not an ammonite problem.
Abhishek Srivastava
@abhishes_twitter
I am having a problem with ammonite with international characters. Try to copy and paste this string into ammonite (on macOS).
大学院小学高校入試高校受験
Now move the cursor to the beginning of the line and try to move the cursor to the end. you will see that the cursor gets stuck at the character . Even Cmd+E doesn't work and it doesn't take you to the end of the line.
This doesn't happen in Scala REPL or Bash. only in ammonite it gets stuck
Emmanuel Nhan
@enhan
Hi there, I am using sbt 1.3.2 and I try to use ammonite 1.7.4 with a commandAlias. It works, but the supershell feature of sbt makes it almost unusable. Is there a way to deactivate supershell for just one task ? I tried Test / useSuperShell := falsebut it did not work. Does someone has an alternative workaround than just calling sbt with --supershell=false ?
Abhishek Srivastava
@abhishes_twitter

I had the following two lines in my predef.sc

import coursier.MavenRepository
interp.repositories() ++= Seq(MavenRepository("https://repository.mulesoft.org/nexus/content/repositories/public/"))

These used to work fine. today I upgraded my ammonite to 1.7.4 and now its broken. Error

predef.sc:17: not found: value coursier
import coursier.MavenRepository
Abhishek Srivastava
@abhishes_twitter
OK. I was able to resolve the issue of MavenRepository. The updated code is like this
import coursierapi.MavenRepository
interp.repositories() ++= Seq(
        MavenRepository.of("https://repository.mulesoft.org/nexus/content/repositories/public/")
)
Now it works fine.
Zsolt Szilagyi
@esgott
@abhishes_twitter I have the same issue, but I also need authentication. Couldn't manage to make it work yet.
Natalia Tisseyre
@supperslonic
Is it possible to have 2 ScalaInterpreters in the single JVM process who share same classLoader? I ran into ClassCastException when trying to deserialize/serialize some instances created by a different classLoader: almond-sh/almond#452
Haifeng Li
@haifengl

I develop a small DSL in scala. It works in Scala's REPL. But in Ammonite, I get the following error:

@ val formula = "class" ~ 
cmd2.sc:1: value ~ is not a member of String
val formula = "class" ~
                      ^
Compilation Failed

All my classes and implicit conversation are already imported.

The same expression works in Scala REPL
scala> val formula = "class" ~
formula: smile.data.formula.FormulaBuilder = FormulaBuilder(Some(class),ListBuffer())
Haifeng Li
@haifengl
Never mind. I find the root cause. It is on my end.
phrmoy
@phrmoy
hello all, thanks for such a great package!
I am running into "org.apache.spark.sql.AnalysisException: Unable to generate an encoder for inner class ammonite.$sess.cmd29$Helper$SimpleTuple without access to the scope that this class was defined in.
Try moving this class out of its parent class.;" and google searches are not too helpful at the moment
can anyone help me get through this?
Just mapping values of a dataset to
case class SimpleTuple(id: Int, desc: String) {
    def >(other:SimpleTuple) = this.id > other.id
}
phrmoy
@phrmoy
So here's what I had to do to make this work
case class SimpleTuple4(id: Int, desc: String) {
    def >(other:SimpleTuple4) = this.id > other.id
}
org.apache.spark.sql.catalyst.encoders.OuterScopes.addOuterScope(this)
textFile.map(line => SimpleTuple4(line.split(" ").size,line)).reduce((a, b) => if (a > b) a else b)
all within the same cell
is this the current workaround? This is Spark 2.4.4
Sören Brunk
@sbrunk
@phrmoy yes, on Spark master this is included by default, but it seems it's not part of 2.4. See https://github.com/apache/spark/pull/23607/files#diff-28a2ffae3ceff1bd5646567163c3a00b
phrmoy
@phrmoy
Well, it's great to know that this will be included in Spark at some point. Thanks for sharing.
Li Haoyi
@lihaoyi
@/all Ammonite 1.8.0 is out http://ammonite.io/#1.8.0, with an OS-Lib upgrade
Diego E. Alonso Blas
@diesalbla
Good morning.
Is there a way of run an ammonite console in sbt, as an alternative to sbt console, that will load the files in the project?
I have tried writing a Main as suggested in https://ammonite.io/#Debugging, and running it with the run command inside sbt , but that did not work...
Emmanuel Nhan
@enhan

@diesalbla Use this :

libraryDependencies += {
  val version = scalaBinaryVersion.value match {
    case "2.10" => "1.0.3"
    case _ ⇒ "1.8.0"
  }
  "com.lihaoyi" % "ammonite" % version % "test" cross CrossVersion.full
}

sourceGenerators in Test += Def.task {
  val file = (sourceManaged in Test).value / "amm.scala"
  IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
  Seq(file)
}.taskValue

and if you want, add a shortcut :
addCommandAlias("repl", "test:runMain amm")

Diego E. Alonso Blas
@diesalbla
:eyeglasses:
Emmanuel Nhan
@enhan
@diesalbla by the way, it is in https://ammonite.io/#Ammonite-REPL section of the doc. Not under the "debugging" one.
Diego E. Alonso Blas
@diesalbla
@enhan Do you have an example of some project with the full SBT configured? I am afraid it is still failing me...