Skip to content

Commit

Permalink
Merge pull request #759 from viash-io/feature/scala3
Browse files Browse the repository at this point in the history
WIP upgrade to scala 3
  • Loading branch information
Grifs authored Dec 9, 2024
2 parents 3e33053 + 4c8cb7d commit 570b10f
Show file tree
Hide file tree
Showing 118 changed files with 957 additions and 894 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ TODO add summary

* `RRequirements`: Allow single quotes to be used again in the `.script` field (PR #771).

* `scala`: Update Scala to Scala 3 (PR #759).
For most of the code, this was a minor update, so no breaking changes are expected.
The biggest change is how the exporting of the schema is done, but this has no impact on the user.
However, switching to Scala 3 allows for additional features and improvements in the future.

## BUG FIXES

* `config build`: Fix a bug where a missing main script would cause a stack trace instead of a proper error message (PR #776).
Expand Down
23 changes: 14 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@ name := "viash"

version := "0.9.1-dev"

scalaVersion := "2.13.14"
scalaVersion := "3.3.4"

libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.2.15" % "test",
"org.scalatest" %% "scalatest" % "3.2.15" % "test",
"org.rogach" %% "scallop" % "5.0.0",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4",
"com.github.julien-truffaut" %% "monocle-core" % "2.1.0",
"com.github.julien-truffaut" %% "monocle-macro" % "2.1.0"
"dev.optics" %% "monocle-core" % "3.1.0",
"dev.optics" %% "monocle-macro" % "3.1.0"
)

val circeVersion = "0.14.1"
val circeVersion = "0.14.7"

libraryDependencies ++= Seq(
"io.circe" %% "circe-core",
"io.circe" %% "circe-generic",
"io.circe" %% "circe-parser",
"io.circe" %% "circe-generic-extras",
"io.circe" %% "circe-optics",
"io.circe" %% "circe-yaml"
// "io.circe" %% "circe-generic-extras",
// "io.circe" %% "circe-optics",
// "io.circe" %% "circe-yaml"
).map(_ % circeVersion)

scalacOptions ++= Seq("-unchecked", "-deprecation")
libraryDependencies ++= Seq(
"io.circe" %% "circe-optics" % "0.15.0",
"io.circe" %% "circe-yaml" % "0.15.2",
)

scalacOptions ++= Seq("-unchecked", "-deprecation", "-explain")
scalacOptions ++= Seq("-Xmax-inlines", "50")

organization := "Data Intuitive"
startYear := Some(2020)
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/viash/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import io.viash.helpers.LoggerLevel
import io.viash.runners.Runner
import io.viash.config.AppliedConfig
import io.viash.engines.Engine
import io.viash.helpers.data_structures.*

object Main extends Logging {
private val pkg = getClass.getPackage
Expand Down Expand Up @@ -551,7 +552,7 @@ object Main extends Logging {
configs0
}

configs1
configs1
}

// Handle dependencies operations for a single config
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/viash/ViashBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package io.viash

import java.nio.file.{Files, Paths}
import scala.sys.process.{Process, ProcessLogger}
import io.viash.helpers.status
import io.viash.helpers.status._

import config._
Expand All @@ -31,7 +32,7 @@ object ViashBuild extends Logging {
output: String,
setup: Option[String] = None,
push: Boolean = false
): Status = {
): status.Status = {
val resources = appliedConfig.generateRunner(false)

// create dir
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/io/viash/ViashTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ object ViashTest extends Logging {
val configYaml = ConfigMeta.toMetaFile(appliedConfig, Some(dir))

// assemble full resources list for test
val confFinal = resourcesLens.set(
val confFinal = resourcesLens.replace(
testBash ::
// the executable, wrapped with an executable runner,
// to be run inside of the runner of the test
Expand Down
18 changes: 8 additions & 10 deletions src/main/scala/io/viash/cli/DocumentedSubcommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.rogach.scallop.Subcommand
import org.rogach.scallop.ScallopOptionGroup
import org.rogach.scallop.ValueConverter
import org.rogach.scallop.ScallopOption
import scala.reflect.runtime.universe._
import io.viash.helpers.typeOf

/**
* Wrapper class for Subcommand to expose protected members
Expand Down Expand Up @@ -76,7 +76,7 @@ class DocumentedSubcommand(commandNameAndAliases: String*) extends Subcommand(co
// We need to get the TypeTag[A], which changes the interface of 'opt', however since we have default values we can't just overload the methods.
// The same goes for 'trailArgs'. Not really for 'choice' but it's better to keep the same change in naming schema here too.

def registerOpt[A](
inline def registerOpt[A](
name: String,
short: Option[Char] = None,
descr: String = "",
Expand All @@ -86,9 +86,8 @@ class DocumentedSubcommand(commandNameAndAliases: String*) extends Subcommand(co
argName: String = "arg",
hidden: Boolean = false,
group: ScallopOptionGroup = null
)(implicit conv:ValueConverter[A], tag: TypeTag[A]): ScallopOption[A] = {
)(implicit conv:ValueConverter[A]): ScallopOption[A] = {

val `type` = tag.tpe
val cleanName = name match {
case null => ""
case _ => name
Expand All @@ -103,14 +102,14 @@ class DocumentedSubcommand(commandNameAndAliases: String*) extends Subcommand(co
argName = Some(argName),
hidden = hidden,
choices = None,
`type` = `type`.toString(),
`type` = typeOf[A],
optType = "opt"
)
registeredOpts = registeredOpts :+ registeredOpt
opt(name, short.getOrElse('\u0000'), removeMarkup(descr), default, validate, required, argName, hidden, short.isEmpty, group)
}

def registerChoice(
inline def registerChoice(
choices: Seq[String],
name: String,
short: Option[Char],
Expand Down Expand Up @@ -143,17 +142,16 @@ class DocumentedSubcommand(commandNameAndAliases: String*) extends Subcommand(co
choice(choices, name, short.getOrElse('\u0000'), removeMarkup(descr), default, required, argName, hidden, short.isEmpty, group)
}

def registerTrailArg[A](
inline def registerTrailArg[A](
name: String,
descr: String = "",
validate: A => Boolean = (_:A) => true,
required: Boolean = true,
default: => Option[A] = None,
hidden: Boolean = false,
group: ScallopOptionGroup = null
)(implicit conv:ValueConverter[A], tag: TypeTag[A]) = {
)(implicit conv:ValueConverter[A]) = {

val `type` = tag.tpe
val cleanName = name match {
case null => ""
case _ => name
Expand All @@ -168,7 +166,7 @@ class DocumentedSubcommand(commandNameAndAliases: String*) extends Subcommand(co
argName = None,
hidden = hidden,
choices = None,
`type` = `type`.toString,
`type` = typeOf[A],
optType = "trailArgs"
)
registeredOpts = registeredOpts :+ registeredOpt
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/io/viash/cli/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.viash

import io.circe.Encoder
import io.circe.generic.extras.semiauto.deriveConfiguredEncoder
import org.rogach.scallop.CliOption

package object cli {
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/io/viash/config/ArgumentGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import io.viash.schemas._
| - name: "--output_optional"
| type: file
| direction: output
|""".stripMargin,
|""",
"yaml")
case class ArgumentGroup(
@description("The name of the argument group.")
Expand All @@ -62,7 +62,7 @@ case class ArgumentGroup(
@example(
"""description: |
| A (multiline) description of the purpose of the arguments
| in this argument group.""".stripMargin, "yaml")
| in this argument group.""", "yaml")
@default("Empty")
description: Option[String] = None,

Expand All @@ -76,7 +76,7 @@ case class ArgumentGroup(
| - @[boolean](arg_boolean)
| - @[boolean_true](arg_boolean_true)
| - @[boolean_false](arg_boolean_false)
|""".stripMargin)
|""")
@example(
"""arguments:
| - name: --foo
Expand All @@ -91,7 +91,7 @@ case class ArgumentGroup(
| multiple_sep: ";"
| - name: --bar
| type: string
|""".stripMargin,
|""",
"yaml")
@default("Empty")
arguments: List[Argument[_]] = Nil
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/viash/config/Author.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import io.viash.schemas._
| twitter: janedoe
| orcid: XXAABBCCXX
| groups: [ one, two, three ]
|""".stripMargin, "yaml")
|""", "yaml")
case class Author(
@description("Full name of the author, usually in the name of FirstName MiddleName LastName.")
name: String,
Expand All @@ -48,7 +48,7 @@ case class Author(
|* `"author"`: Authors who have made substantial contributions to the component.
|* `"maintainer"`: The maintainer of the component.
|* `"contributor"`: Authors who have made smaller contributions (such as code patches etc.).
|""".stripMargin)
|""")
@default("Empty")
roles: OneOrMore[String] = Nil,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.viash.schemas._
"""requirements:
| cpus: 5
| memory: 10GB
|""".stripMargin,
|""",
"yaml")
@since("Viash 0.6.0")
case class ComputationalRequirements(
Expand Down
Loading

0 comments on commit 570b10f

Please sign in to comment.