Skip to content

Commit

Permalink
Update cwl-d
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-tan committed Mar 31, 2024
1 parent 9177d46 commit ee6f49b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"copyright": "Copyright © 2022, Tomoya Tanjo",
"dependencies": {
"cwl-d": "~>0.2.1"
"cwl-d": "~>0.3.0"
},
"description": "A workflow engine for CommandLineTool in local machine",
"homepage": "https://github.com/tom-tan/shaft",
Expand Down
4 changes: 2 additions & 2 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"versions": {
"automem": "0.6.9",
"cachetools": "0.4.1",
"cwl-d": "0.2.1",
"cwl-d": "0.3.0",
"dyaml": "0.9.2",
"requests": "2.0.9",
"schema-salad-d": "1.0.2",
"schema-salad-d": "1.1.0",
"sumtype": "1.1.4",
"test_allocator": "0.3.4",
"tinyendian": "0.2.0",
Expand Down
8 changes: 4 additions & 4 deletions source/shaft/command_line_tool.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cwl.v1_0;

import dyaml : Node;

import salad.type : Either, Optional, orElse;
import salad.type : Union, Optional, orElse;

import shaft.evaluator : Evaluator;
import shaft.runtime : Runtime;
Expand Down Expand Up @@ -177,7 +177,7 @@ alias Param = Tuple!(
/**
* See_Also: 3 in https://www.commonwl.org/v1.1/CommandLineTool.html#CommandLineBinding
*/
alias TieBreaker = Either!(size_t, string);
alias TieBreaker = Union!(size_t, string);

/**
* See_Also: https://www.commonwl.org/v1.2/CommandLineTool.html#Input_binding
Expand Down Expand Up @@ -403,8 +403,8 @@ EOS";
assert(args == ["echo", "10"]);
}

alias Str = Either!(NonEscapedString, EscapedString);
alias CmdElemType = Either!(Str, Str[]);
alias Str = Union!(NonEscapedString, EscapedString);
alias CmdElemType = Union!(Str, Str[]);

///
auto toCmdElems(CmdElemType val, CommandLineBinding clb, bool useShell)
Expand Down
10 changes: 5 additions & 5 deletions source/shaft/evaluator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct Evaluator
*/
Node eval(string expression, Node inputs, Runtime runtime, Node self = YAMLNull()) /+ pure +/ @safe
{
import salad.type : Either, match;
import salad.type : Union, match;
import std.algorithm : map;
import std.array : join;
import std.range : empty;
Expand All @@ -87,16 +87,16 @@ struct Evaluator
exp = exp[0..$-1];
}

Either!(string, Node)[] evaled;
Union!(string, Node)[] evaled;
while (auto c = matchFirst(exp))
{
if (!c.pre.empty)
{
evaled ~= Either!(string, Node)(c.pre);
evaled ~= Union!(string, Node)(c.pre);
}

auto result = evaluate(c.hit, inputs, runtime, self, expressionLibs, enableExtProps, engine);
evaled ~= Either!(string, Node)(result);
evaled ~= Union!(string, Node)(result);

exp = c.post;
if (exp.empty)
Expand All @@ -107,7 +107,7 @@ struct Evaluator

if (!exp.empty)
{
evaled ~= Either!(string, Node)(exp);
evaled ~= Union!(string, Node)(exp);
}

if (evaled.length == 1)
Expand Down
20 changes: 10 additions & 10 deletions source/shaft/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cwl.v1_0 : Directory, File;

import dyaml : Node, NodeType, YAMLNull;

import salad.type : Either, None;
import salad.type : Union, None;

import std.digest : isDigest;
import std.exception : assertNotThrown;
Expand Down Expand Up @@ -109,9 +109,9 @@ do
// ret.size_ = file.size_; // TODO

ret.secondaryFiles_ = file.secondaryFiles_.match!(
(Either!(File, Directory)[] ff) => typeof(ret.secondaryFiles_)(ff.map!(f => f.match!(
(File f) => Either!(File, Directory)(f.toURIFile),
(Directory dir) => Either!(File, Directory)(dir.toURIDirectory),
(Union!(File, Directory)[] ff) => typeof(ret.secondaryFiles_)(ff.map!(f => f.match!(
(File f) => Union!(File, Directory)(f.toURIFile),
(Directory dir) => Union!(File, Directory)(dir.toURIDirectory),
)).array),
_ => typeof(ret.secondaryFiles_).init,
);
Expand Down Expand Up @@ -214,9 +214,9 @@ do
);

ret.listing_ = dir.listing_.match!(
(Either!(File, Directory)[] ff) => typeof(ret.listing_)(ff.map!(f => f.match!(
(File f) => Either!(File, Directory)(f.toURIFile),
(Directory d) => Either!(File, Directory)(d.toURIDirectory),
(Union!(File, Directory)[] ff) => typeof(ret.listing_)(ff.map!(f => f.match!(
(File f) => Union!(File, Directory)(f.toURIFile),
(Directory d) => Union!(File, Directory)(d.toURIDirectory),
)).array),
_ => typeof(ret.listing_).init,
);
Expand Down Expand Up @@ -343,7 +343,7 @@ void enforceValid(File file) @safe
);

file.secondaryFiles_.match!(
(Either!(File, Directory)[] files) => files.each!(
(Union!(File, Directory)[] files) => files.each!(
ff => ff.match!(
(File f) => f.enforceValid,
(Directory d) => d.enforceValid,
Expand All @@ -367,7 +367,7 @@ void enforceValid(Directory dir) @safe

match!(
(None _1, None _2) => dir.listing_.match!(
(Either!(File, Directory)[] ls) => true,
(Union!(File, Directory)[] ls) => true,
none => enforce(false, new InvalidDocument("`listing`, `location` or `path` is required", dir.mark)),
),
(None _, string loc) {
Expand Down Expand Up @@ -409,7 +409,7 @@ void enforceValid(Directory dir) @safe
);

dir.listing_.match!(
(Either!(File, Directory)[] listing) => listing.each!(
(Union!(File, Directory)[] listing) => listing.each!(
ff => ff.match!(
(File f) => f.enforceValid,
(Directory d) => d.enforceValid,
Expand Down
4 changes: 2 additions & 2 deletions source/shaft/type/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cwl.v1_0;

import dyaml : Node;

import salad.type : Either, Optional, This;
import salad.type : Union, Optional, This;
import shaft.exception : TypeException;
import std.json : JSONValue;
import std.range : isOutputRange;
Expand All @@ -33,7 +33,7 @@ struct StagingOption
alias EnumType = Tuple!(string, "name", Optional!CommandLineBinding, "inputBinding");

///
alias DeterminedType = Either!(
alias DeterminedType = Union!(
PrimitiveType,
EnumType,
Tuple!(This*[], "types", Optional!CommandLineBinding, "inputBinding"),
Expand Down
22 changes: 11 additions & 11 deletions source/shaft/type/input.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dyaml : Node, NodeType;

import cwl.v1_0;
import salad.context : LoadingContext;
import salad.type : Either, Optional, This;
import salad.type : Union, Optional, This;
import shaft.exception : TypeException, InputCannotBeLoaded;
import shaft.type.common : DeterminedType, TypedParameters, TypedValue;
import shaft.type.common : TC_ = TypeConflicts;
Expand All @@ -18,13 +18,13 @@ import std.typecons : Flag, Tuple, Yes;
import std.logger : stdThreadLocalLog;

///
alias DeclaredType = Either!(
alias DeclaredType = Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
CommandInputArraySchema,
string,
Either!(
Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand Down Expand Up @@ -55,7 +55,7 @@ string toStr(DeclaredType dt) pure @safe

return dt.match!(
funs,
(Either!(
(Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand Down Expand Up @@ -389,7 +389,7 @@ TypedValue bindType(
return n.bindType(def, defMap, context);
}
},
(Either!(
(Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand Down Expand Up @@ -460,7 +460,7 @@ CommandInputRecordField toCommandField(InputRecordField field)
import std.algorithm : map;
import std.array : array;

alias EType = Either!(
alias EType = Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand All @@ -471,7 +471,7 @@ CommandInputRecordField toCommandField(InputRecordField field)
auto ret = new typeof(return);
ret.name_ = field.name_;
ret.type_ = field.type_.match!(
(Either!(
(Union!(
CWLType,
InputRecordSchema,
InputEnumSchema,
Expand Down Expand Up @@ -517,7 +517,7 @@ CommandInputArraySchema toCommandSchema(InputArraySchema schema)
import std.algorithm : map;
import std.array : array;

alias EType = Either!(
alias EType = Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand All @@ -527,7 +527,7 @@ CommandInputArraySchema toCommandSchema(InputArraySchema schema)

auto ret = new typeof(return);
ret.items_ = schema.items_.match!(
(Either!(
(Union!(
CWLType,
InputRecordSchema,
InputEnumSchema,
Expand Down Expand Up @@ -580,7 +580,7 @@ auto toCommandInputType(typeof(InputParameter.init.type_) type)
alias RetType = typeof(CommandInputParameter.init.type_);
RetType ret;

alias EType = Either!(
alias EType = Union!(
CWLType,
CommandInputRecordSchema,
CommandInputEnumSchema,
Expand All @@ -592,7 +592,7 @@ auto toCommandInputType(typeof(InputParameter.init.type_) type)
(None none) => RetType(none),
(CWLType t) => RetType(t),
(string s) => RetType(s),
(Either!(
(Union!(
CWLType,
InputRecordSchema,
InputEnumSchema,
Expand Down
Loading

0 comments on commit ee6f49b

Please sign in to comment.