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

WIP upgrade to scala 3 #759

Draft
wants to merge 25 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d19a0d3
Disable any reflection & circe calls as it was tripping over its toes
Grifs Aug 8, 2024
76595ff
Merge branch 'develop' into feature/scala3
Grifs Aug 29, 2024
f9226ab
Start re-enabling circe calls with replaced encoder and decoders
Grifs Aug 29, 2024
673570b
Start to re-enable decoders and encoders
Grifs Aug 29, 2024
b186934
fudge BuildStatus type to assist type matching, set max-inlines in sb…
Grifs Aug 29, 2024
1b8d8ae
re-enable json encoding and decoding calls that were previously disabled
Grifs Aug 29, 2024
e30ee82
Fix another handful of issues, start to fix some tests
Grifs Aug 29, 2024
c9d10b8
Fix another bunch of issues with testbenches
Grifs Aug 29, 2024
b008154
Re-enable code & provide temporary methods as needed. Further cleanup
Grifs Sep 5, 2024
664a782
minor cleanup
Grifs Sep 5, 2024
dfdf294
fix temporary code still being present
Grifs Sep 5, 2024
ef49859
Tweak how the encoder & decoder placeholders are formatted
Grifs Sep 5, 2024
25891ca
remove all stripMargins from field case class annotations
Grifs Sep 5, 2024
9ed9d94
Add custom encoder & decoder for Status enum
Grifs Sep 12, 2024
b299ac9
Add back some validation code to assist with invalid fields
Grifs Sep 12, 2024
3e9da39
provide safeguard to solve empty packageconfig issues
Grifs Sep 12, 2024
83aaaee
Start using reflection to get class name and fields
Grifs Sep 12, 2024
8d422d0
reactivate some code
Grifs Sep 13, 2024
e39672c
fix broken indentation
Grifs Sep 13, 2024
fd79c50
Start progressing to Circe to use mirroring directly instead of going…
Grifs Sep 27, 2024
4fde75b
Add implementation of fieldsInternalFunctionality
Grifs Sep 27, 2024
f7e2d0b
add deprecation & removal annotation code
Grifs Sep 28, 2024
ba38803
Refactor mirror method names
Grifs Sep 28, 2024
0d98639
Fix empty package configs failing as it gets parsed as `false`
Grifs Sep 28, 2024
7d84d7d
rename `niceNameOf` to `typeOf` and improve output of e.g. List[String]
Grifs Sep 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@ name := "viash"

version := "0.9.0-dev"

scalaVersion := "2.13.14"
scalaVersion := "3.3.3"

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" % "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.9"

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.16.0",
)

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
6 changes: 3 additions & 3 deletions src/main/scala/io/viash/config/ArgumentGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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."""/*.stripMargin*/, "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)
|"""/*.stripMargin*/)
@example(
"""arguments:
| - name: --foo
Expand All @@ -91,7 +91,7 @@ case class ArgumentGroup(
| multiple_sep: ";"
| - name: --bar
| type: string
|""".stripMargin,
|"""/*.stripMargin*/,
"yaml")
@default("Empty")
arguments: List[Argument[_]] = Nil
Expand Down
Loading
Loading