<commit_before>package fr.iscpif.gridscale.ssh
import java.io.File

import fr.iscpif.gridscale.authentication._
import concurrent.duration._

object TestSSH extends App {

  import freedsl.random._
  import freedsl.util._

  val c = freedsl.dsl.merge(Util, SSH, Random)
  import c._

  import cats._
  import cats.implicits._
  import freek._

  def randomData[M[_]](implicit randomM: Random[M]) = randomM.shuffle(Seq(1, 2, 2, 3, 3, 3))

  def job(data: String) =
    SSHJobDescription(
      command = s"echo -n $data",
      workDirectory = "/tmp/")

  val prg =
    for {
      sData ← randomData[M]
      jobId ← submit[M](job(sData.mkString(", ")))
      _ ← implicitly[Util[M]].sleep(2 second)
      s ← state[M](jobId)
      out ← stdOut[M](jobId)
    } yield s"""Job status is $s, stdout is "$out"."""

  val zebulon = Server("zebulon.iscpif.fr")
  val key = PrivateKey("reuillon", new File("/home/reuillon/.ssh/id_rsa"), "")

  val sshClient =
    SSH.client(
      zebulon,
      _.authPrivateKey(key)
    )

  val interpreter =
    SSH.interpreter(sshClient) :&:
      Util.interpreter :&:
      Random.interpreter(42)

  try println(result.getOption(prg.value.interpret(interpreter))) //.map(_.leftMap(_.asInstanceOf[SSH.ConnectionError].t.printStackTrace)))
  finally sshClient.foreach(_.close())
}
<commit_msg>Organize imports.<commit_after>package fr.iscpif.gridscale.ssh
import java.io.File

import fr.iscpif.gridscale.authentication._
import concurrent.duration._

object TestSSH extends App {

  import freek._
  import cats.implicits._
  import freedsl.random._
  import freedsl.util._

  val c = freedsl.dsl.merge(Util, SSH, Random)
  import c._

  def randomData[M[_]](implicit randomM: Random[M]) = randomM.shuffle(Seq(1, 2, 2, 3, 3, 3))

  def job(data: String) =
    SSHJobDescription(
      command = s"echo -n $data",
      workDirectory = "/tmp/")

  val prg =
    for {
      sData ← randomData[M]
      jobId ← submit[M](job(sData.mkString(", ")))
      _ ← implicitly[Util[M]].sleep(2 second)
      s ← state[M](jobId)
      out ← stdOut[M](jobId)
    } yield s"""Job status is $s, stdout is "$out"."""

  val zebulon = Server("zebulon.iscpif.fr")
  val key = PrivateKey("reuillon", new File("/home/reuillon/.ssh/id_rsa"), "")

  val sshClient =
    SSH.client(
      zebulon,
      _.authPrivateKey(key)
    )

  val interpreter =
    SSH.interpreter(sshClient) :&:
      Util.interpreter :&:
      Random.interpreter(42)

  try println(result.getOption(prg.value.interpret(interpreter))) //.map(_.leftMap(_.asInstanceOf[SSH.ConnectionError].t.printStackTrace)))
  finally sshClient.foreach(_.close())
}

{'fraction_non_alphanumeric': 0.14800759013282733, 'fraction_numerical': 0.00683111954459203, 'mean_word_length': 3.328407224958949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4045797', 'n_tokens_mistral': 993, 'n_tokens_neox': 955, 'n_words': 195}