Dist bug fixes (#422)

This commit is contained in:
Dima 2022-02-06 08:52:51 +03:00 committed by GitHub
parent 6d03a0d95b
commit 88da133e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 7 deletions

View File

@ -1,10 +1,10 @@
package aqua.dist
import aqua.builder.IPFSUploader
import aqua.builder.{ArgumentGetter, IPFSUploader}
import aqua.files.AquaFilesIO
import aqua.io.OutputPrinter
import aqua.ipfs.js.IpfsApi
import aqua.js.{Fluence, PeerConfig}
import aqua.js.{Config, Fluence, PeerConfig}
import aqua.keypair.KeyPairShow.show
import aqua.model.LiteralModel
import aqua.raw.value.{LiteralRaw, VarRaw}
@ -49,6 +49,12 @@ object DistOpts extends Logging {
Opts.subcommand(deploy)
}
def fillConfigOptionalFields(getter: ArgumentGetter): ArgumentGetter = {
val arg = getter.function.arg
val filledConfig = Config.fillWithEmptyArrays(arg)
ArgumentGetter(getter.function.value, filledConfig)
}
// Uploads a file to IPFS
def deploy[F[_]: Async](implicit ec: ExecutionContext): Command[F[ExitCode]] =
Command(
@ -66,13 +72,18 @@ object DistOpts extends Logging {
dff
.andThen(data =>
checkDataGetServices(args, data).map(getServices =>
// TODO: delete this another dirty hack
// if we have default timeout, increase it
val commonWithTimeout = if (common.timeout == 14000) {
common.copy(timeout = 60000)
} else common
RunOpts.execRun(
common,
commonWithTimeout,
DeployFuncName,
distAquaPath,
Nil,
args,
getServices,
getServices.map { (k, v) => (k, fillConfigOptionalFields(v)) },
Nil
)
)

View File

@ -0,0 +1,13 @@
package aqua.js
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSExportAll, JSImport}
object Config {
@js.native
@JSImport("./dist/config.js", "fillWithEmptyArrays")
def fillWithEmptyArrays(
config: js.Dynamic
): js.Dynamic = js.native
}

View File

@ -11,7 +11,7 @@ object FluenceOpts {
val timeoutOpt: Opts[Int] =
Opts
.option[Int]("timeout", "Request timeout in milliseconds", "t")
.withDefault(7000)
.withDefault(14000)
val multiaddrOpt: Opts[String] =
Opts

View File

@ -73,6 +73,10 @@ func deploy(serviceConf: ServiceConf) -> string:
service_id <- Srv.create(blueprint_id)
Console.print("Blueprint id:")
Console.print(blueprint_id)
Console.print("And your service id is:")
<- service_id
func remove(service_id: string):

33
npm/src/config.ts Normal file
View File

@ -0,0 +1,33 @@
type Module = {
name: string,
path: string,
mounted_binaries: string[][],
logger_enabled: boolean[],
preopened_files: string[],
mapped_dirs: string[]
}
type Config = {
name: string,
modules: Module[]
}
export function fillWithEmptyArrays(config: Config): Config {
config.modules = config.modules.map((m) => {
if (!m.logger_enabled) {
m.logger_enabled = []
}
if (!m.mounted_binaries) {
m.mounted_binaries = []
}
if (!m.preopened_files) {
m.preopened_files = []
}
if (!m.mapped_dirs) {
m.mapped_dirs = []
}
return m
})
return config
}

View File

@ -1,8 +1,6 @@
import {create, globSource} from "ipfs-http-client";
import { Multiaddr, protocols } from "multiaddr";
import * as util from "util";
type UploadResult = {
cid: string,
size: number