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

Updated following dependencies as they need changes to the code to wo… #2348

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ val scalafixSettings = Seq(

val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := "2.13.10",
scalaVersion := "2.13.12",
organizationName := "Eike K. & Contributors",
licenses += ("AGPL-3.0-or-later", url(
"https://spdx.org/licenses/AGPL-3.0-or-later.html"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final case class AddonArchive(url: LenientUri, name: String, version: String) {
def nameAndVersion: String =
s"$name-$version"

def extractTo[F[_]: Async](
def extractTo[F[_]: Async: Files](
reader: UrlReader[F],
directory: Path,
withSubdir: Boolean = true,
Expand Down Expand Up @@ -48,7 +48,7 @@ final case class AddonArchive(url: LenientUri, name: String, version: String) {
/** Read meta either from the given directory or extract the url to find the metadata
* file to read
*/
def readMeta[F[_]: Async](
def readMeta[F[_]: Async: Files](
urlReader: UrlReader[F],
directory: Option[Path] = None
): F[AddonMeta] =
Expand All @@ -58,7 +58,7 @@ final case class AddonArchive(url: LenientUri, name: String, version: String) {
}

object AddonArchive {
def read[F[_]: Async](
def read[F[_]: Async: Files](
url: LenientUri,
urlReader: UrlReader[F],
extractDir: Option[Path] = None
Expand All @@ -69,7 +69,7 @@ object AddonArchive {
.map(m => addon.copy(name = m.meta.name, version = m.meta.version))
}

def dockerAndFlakeExists[F[_]: Async](
def dockerAndFlakeExists[F[_]: Async: Files](
archive: Either[Path, Stream[F, Byte]]
): F[(Boolean, Boolean)] = {
val files = Files[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait AddonExecutor[F[_]] {

object AddonExecutor {

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
cfg: AddonExecutorConfig,
urlReader: UrlReader[F]
): AddonExecutor[F] =
Expand Down Expand Up @@ -104,7 +104,7 @@ object AddonExecutor {
} yield result
}

def selectRunner[F[_]: Async](
def selectRunner[F[_]: Async: Files](
cfg: AddonExecutorConfig,
meta: AddonMeta,
addonDir: Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ case class AddonMeta(
* inspecting the archive to return defaults when the addon isn't declaring it in the
* descriptor.
*/
def enabledTypes[F[_]: Async](
def enabledTypes[F[_]: Async: Files](
archive: Either[Path, Stream[F, Byte]]
): F[List[RunnerType]] =
for {
Expand Down Expand Up @@ -207,7 +207,7 @@ object AddonMeta {
)
}

def findInZip[F[_]: Async](zipFile: Stream[F, Byte]): F[AddonMeta] = {
def findInZip[F[_]: Async: Files](zipFile: Stream[F, Byte]): F[AddonMeta] = {
val logger = docspell.logging.getLogger[F]
val fail: F[AddonMeta] = Async[F].raiseError(
new FileNotFoundException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import cats.Applicative
import cats.effect._
import cats.syntax.all._
import fs2.Stream
import fs2.io.file.Files

import docspell.addons.runner._
import docspell.common.exec.Env
Expand All @@ -26,7 +27,9 @@ trait AddonRunner[F[_]] {
}

object AddonRunner {
def forType[F[_]: Async](cfg: AddonExecutorConfig)(rt: RunnerType) =
def forType[F[_]: Async: Files](
cfg: AddonExecutorConfig
)(rt: RunnerType): AddonRunner[F] =
rt match {
case RunnerType.NixFlake => NixFlakeRunner[F](cfg)
case RunnerType.Docker => DockerRunner[F](cfg)
Expand All @@ -38,9 +41,9 @@ object AddonRunner {

def pure[F[_]: Applicative](result: AddonResult): AddonRunner[F] =
new AddonRunner[F] {
val runnerType = Nil
val runnerType: List[RunnerType] = Nil

def run(logger: Logger[F], env: Env, ctx: Context) =
def run(logger: Logger[F], env: Env, ctx: Context): F[AddonResult] =
Applicative[F].pure(result)
}

Expand All @@ -50,9 +53,9 @@ object AddonRunner {
case a :: Nil => a
case _ =>
new AddonRunner[F] {
val runnerType = runners.flatMap(_.runnerType).distinct
val runnerType: List[RunnerType] = runners.flatMap(_.runnerType).distinct

def run(logger: Logger[F], env: Env, ctx: Context) =
def run(logger: Logger[F], env: Env, ctx: Context): F[AddonResult] =
Stream
.emits(runners)
.evalTap(r =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import docspell.common.Duration
import docspell.common.exec._
import docspell.logging.Logger

final class NixFlakeRunner[F[_]: Async](cfg: NixFlakeRunner.Config)
final class NixFlakeRunner[F[_]: Async: Files](cfg: NixFlakeRunner.Config)
extends AddonRunner[F] {

val runnerType = List(RunnerType.NixFlake)
Expand Down Expand Up @@ -104,7 +104,7 @@ final class NixFlakeRunner[F[_]: Async](cfg: NixFlakeRunner.Config)
}

object NixFlakeRunner {
def apply[F[_]: Async](cfg: AddonExecutorConfig): NixFlakeRunner[F] =
def apply[F[_]: Async: Files](cfg: AddonExecutorConfig): NixFlakeRunner[F] =
new NixFlakeRunner[F](Config(cfg.nixRunner, cfg.nspawn, cfg.runTimeout))

case class Config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private[addons] object RunnerUtil {
* expected to be relative to the `ctx.baseDir`. Additional arguments and environment
* variables are added as configured in the addon.
*/
def runInContainer[F[_]: Async](
def runInContainer[F[_]: Async: Files](
logger: Logger[F],
cfg: AddonExecutorConfig.NSpawn,
ctx: Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import docspell.common.Duration
import docspell.common.exec.{Args, Env, SysCmd}
import docspell.logging.Logger

final class TrivialRunner[F[_]: Async](cfg: TrivialRunner.Config) extends AddonRunner[F] {
final class TrivialRunner[F[_]: Async: Files](cfg: TrivialRunner.Config)
extends AddonRunner[F] {
private val sync = Async[F]
private val files = Files[F]
implicit val andMonoid: Monoid[Boolean] = Monoid.instance[Boolean](true, _ && _)
implicit val andMonoid: Monoid[Boolean] =
Monoid.instance[Boolean](emptyValue = true, _ && _)

private val executeBits = PosixPermissions(
OwnerExecute,
Expand All @@ -34,13 +36,13 @@ final class TrivialRunner[F[_]: Async](cfg: TrivialRunner.Config) extends AddonR
OthersRead
)

val runnerType = List(RunnerType.Trivial)
val runnerType: List[RunnerType] = List(RunnerType.Trivial)

def run(
logger: Logger[F],
env: Env,
ctx: Context
) = {
): F[AddonResult] = {
val binaryPath = ctx.meta.runner
.flatMap(_.trivial)
.map(_.exec)
Expand Down Expand Up @@ -71,7 +73,7 @@ final class TrivialRunner[F[_]: Async](cfg: TrivialRunner.Config) extends AddonR
}

object TrivialRunner {
def apply[F[_]: Async](cfg: AddonExecutorConfig): TrivialRunner[F] =
def apply[F[_]: Async: Files](cfg: AddonExecutorConfig): TrivialRunner[F] =
new TrivialRunner[F](Config(cfg.nspawn, cfg.runTimeout))

case class Config(nspawn: NSpawn, timeout: Duration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package docspell.analysis
import cats.Applicative
import cats.effect._
import cats.implicits._
import fs2.io.file.Files

import docspell.analysis.classifier.{StanfordTextClassifier, TextClassifier}
import docspell.analysis.contact.Contact
Expand Down Expand Up @@ -36,7 +37,7 @@ object TextAnalyser {
labels ++ dates.map(dl => dl.label.copy(label = dl.date.toString))
}

def create[F[_]: Async](cfg: TextAnalysisConfig): Resource[F, TextAnalyser[F]] =
def create[F[_]: Async: Files](cfg: TextAnalysisConfig): Resource[F, TextAnalyser[F]] =
Resource
.eval(Nlp(cfg.nlpConfig))
.map(stanfordNer =>
Expand Down Expand Up @@ -83,7 +84,7 @@ object TextAnalyser {

/** Provides the nlp pipeline based on the configuration. */
private object Nlp {
def apply[F[_]: Async](
def apply[F[_]: Async: Files](
cfg: TextAnalysisConfig.NlpConfig
): F[Input[F] => F[Vector[NerLabel]]] = {
val log = docspell.logging.getLogger[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import docspell.logging.Logger

import edu.stanford.nlp.classify.ColumnDataClassifier

final class StanfordTextClassifier[F[_]: Async](cfg: TextClassifierConfig)
final class StanfordTextClassifier[F[_]: Async: Files](cfg: TextClassifierConfig)
extends TextClassifier[F] {

def trainClassifier[A](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import scala.concurrent.duration.{Duration => _, _}
import cats.effect.Ref
import cats.effect._
import cats.implicits._
import fs2.io.file.Files

import docspell.analysis.NlpSettings
import docspell.common._
Expand All @@ -32,7 +33,7 @@ trait PipelineCache[F[_]] {
object PipelineCache {
private[this] val logger = docspell.logging.unsafeLogger

def apply[F[_]: Async](clearInterval: Duration)(
def apply[F[_]: Async: Files](clearInterval: Duration)(
creator: NlpSettings => Annotator[F],
release: F[Unit]
): F[PipelineCache[F]] = {
Expand All @@ -44,7 +45,7 @@ object PipelineCache {
} yield new Impl[F](data, creator, cacheClear)
}

final private class Impl[F[_]: Async](
final private class Impl[F[_]: Async: Files](
data: Ref[F, Map[String, Entry[Annotator[F]]]],
creator: NlpSettings => Annotator[F],
cacheClear: CacheClearing[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package docspell.backend

import cats.effect._
import fs2.io.file.Files

import docspell.backend.BackendCommands.EventContext
import docspell.backend.auth.Login
Expand Down Expand Up @@ -65,7 +66,7 @@ trait BackendApp[F[_]] {

object BackendApp {

def create[F[_]: Async](
def create[F[_]: Async: Files](
cfg: Config,
store: Store[F],
javaEmil: Emil[F],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package docspell.backend.joex
import cats.data.OptionT
import cats.effect._
import cats.syntax.all._
import fs2.io.file.Files

import docspell.addons._
import docspell.backend.joex.AddonOps.{AddonRunConfigRef, ExecResult}
Expand Down Expand Up @@ -98,7 +99,7 @@ object AddonOps {
)
}

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
cfg: AddonEnvConfig,
store: Store[F],
cmdRunner: BackendCommandRunner[F, Unit],
Expand Down Expand Up @@ -160,7 +161,10 @@ object AddonOps {
execRes = ExecResult(List(result), List(runCfg))
} yield execRes

def createMiddleware(custom: Middleware[F], runCfg: AddonRunConfigRef) = for {
def createMiddleware(
custom: Middleware[F],
runCfg: AddonRunConfigRef
): F[Middleware[F]] = for {
dscMW <- prepare.createDscEnv(runCfg, cfg.executorConfig.runTimeout)
mm = dscMW >> custom >> prepare.logResult(logger, runCfg) >> Middleware
.ephemeralRun[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cats.data.EitherT
import cats.effect._
import cats.syntax.all._
import fs2.Stream
import fs2.io.file.Path
import fs2.io.file.{Files, Path}

import docspell.addons.{AddonMeta, RunnerType}
import docspell.backend.Config
Expand All @@ -21,7 +21,7 @@ import docspell.joexapi.model.AddonSupport
import docspell.store.Store
import docspell.store.records.RAddonArchive

final class AddonValidate[F[_]: Async](
final class AddonValidate[F[_]: Async: Files](
cfg: Config.Addons,
store: Store[F],
joexOps: OJoex[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package docspell.backend.ops
import cats.data.{EitherT, NonEmptyList, OptionT}
import cats.effect._
import cats.syntax.all._
import fs2.io.file.Files

import docspell.addons.{AddonMeta, AddonTriggerType}
import docspell.backend.ops.AddonValidationError._
Expand Down Expand Up @@ -129,7 +130,7 @@ object OAddons {
def failure[A](error: AddonValidationError): AddonValidationResult[A] = Left(error)
}

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
cfg: Config.Addons,
store: Store[F],
userTasks: UserTaskStore[F],
Expand Down
6 changes: 3 additions & 3 deletions modules/common/src/main/scala/docspell/common/Binary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final case class Binary[F[_]](name: String, mime: MimeType, data: Stream[F, Byte

object Binary {

def apply[F[_]: Async](file: Path): Binary[F] =
def apply[F[_]: Files](file: Path): Binary[F] =
Binary(file.fileName.toString, Files[F].readAll(file))

def apply[F[_]](name: String, data: Stream[F, Byte]): Binary[F] =
Expand Down Expand Up @@ -74,11 +74,11 @@ object Binary {
data.chunks.map(_.toByteVector).compile.fold(ByteVector.empty)((r, e) => r ++ e)

/** Convert paths into `Binary`s */
def toBinary[F[_]: Async]: Pipe[F, Path, Binary[F]] =
def toBinary[F[_]: Files]: Pipe[F, Path, Binary[F]] =
_.map(Binary[F](_))

/** Save one or more binaries to a target directory. */
def saveTo[F[_]: Async](
def saveTo[F[_]: Async: Files](
logger: Logger[F],
targetDir: Path
): Pipe[F, Binary[F], Path] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ object File {
.drain
.map(_ => file)

def readJson[F[_]: Async, A](file: Path)(implicit d: Decoder[A]): F[A] =
def readJson[F[_]: Async: Files, A](file: Path)(implicit d: Decoder[A]): F[A] =
readText[F](file).map(parser.decode[A]).rethrow
}
6 changes: 3 additions & 3 deletions modules/common/src/main/scala/docspell/common/util/Zip.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package docspell.common.util

import cats.effect._
import fs2.io.file.Path
import fs2.io.file.{Files, Path}
import fs2.{Pipe, Stream}

import docspell.common.Glob
Expand All @@ -33,9 +33,9 @@ trait Zip[F[_]] {
}

object Zip {
val defaultChunkSize = 64 * 1024
private val defaultChunkSize = 64 * 1024

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
logger: Option[Logger[F]] = None,
tempDir: Option[Path] = None
): Zip[F] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import fs2.{Chunk, Pipe, Stream}
import docspell.common.Glob
import docspell.logging.Logger

final private class ZipImpl[F[_]: Async](
final private class ZipImpl[F[_]: Async: Files](
log: Option[Logger[F]],
tempDir: Option[Path]
) extends Zip[F] {
Expand Down
Loading