Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openmole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
RoiArthurB
openmole
Commits
9fa387e2
Commit
9fa387e2
authored
May 07, 2020
by
Romain Reuillon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Core] enh: create format and hook packages in workflow
parent
40e08183
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
211 additions
and
161 deletions
+211
-161
openmole/bin/org.openmole.modules/src/main/scala/org/openmole/modules/Module.scala
....modules/src/main/scala/org/openmole/modules/Module.scala
+1
-1
openmole/core/org.openmole.core.dsl/src/main/scala/org/openmole/core/dsl/extension/package.scala
.../main/scala/org/openmole/core/dsl/extension/package.scala
+9
-5
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/Activator.scala
...src/main/scala/org/openmole/core/workflow/Activator.scala
+1
-3
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/composition/package.scala
...cala/org/openmole/core/workflow/composition/package.scala
+5
-4
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/CSVOutputFormat.scala
...a/org/openmole/core/workflow/format/CSVOutputFormat.scala
+71
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/OutputFormat.scala
...cala/org/openmole/core/workflow/format/OutputFormat.scala
+23
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/WritableOutput.scala
...la/org/openmole/core/workflow/format/WritableOutput.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/package.scala
...ain/scala/org/openmole/core/workflow/format/package.scala
+16
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/CSVHook.scala
.../main/scala/org/openmole/core/workflow/hook/CSVHook.scala
+33
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/FormattedFileHook.scala
...a/org/openmole/core/workflow/hook/FormattedFileHook.scala
+4
-23
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/FromContextHook.scala
...ala/org/openmole/core/workflow/hook/FromContextHook.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/Hook.scala
...src/main/scala/org/openmole/core/workflow/hook/Hook.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/package.scala
.../main/scala/org/openmole/core/workflow/hook/package.scala
+13
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/CSVHook.scala
.../main/scala/org/openmole/core/workflow/mole/CSVHook.scala
+0
-94
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/MoleExecution.scala
...scala/org/openmole/core/workflow/mole/MoleExecution.scala
+1
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/package.scala
.../main/scala/org/openmole/core/workflow/mole/package.scala
+3
-10
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/package.scala
...w/src/main/scala/org/openmole/core/workflow/package.scala
+4
-0
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/test/TestHook.scala
...main/scala/org/openmole/core/workflow/test/TestHook.scala
+1
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/tools/package.scala
...main/scala/org/openmole/core/workflow/tools/package.scala
+0
-3
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/validation/DataflowProblem.scala
...g/openmole/core/workflow/validation/DataflowProblem.scala
+2
-1
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/validation/ValidationProblem.scala
...openmole/core/workflow/validation/ValidationProblem.scala
+2
-1
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/Activator.scala
.../main/scala/org/openmole/plugin/hook/file/Activator.scala
+1
-1
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/AppendToFileHook.scala
...cala/org/openmole/plugin/hook/file/AppendToFileHook.scala
+1
-5
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/CopyFileHook.scala
...in/scala/org/openmole/plugin/hook/file/CopyFileHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/MatrixHook.scala
...main/scala/org/openmole/plugin/hook/file/MatrixHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/SaveHook.scala
...c/main/scala/org/openmole/plugin/hook/file/SaveHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/package.scala
...rc/main/scala/org/openmole/plugin/hook/file/package.scala
+1
-1
openmole/plugins/org.openmole.plugin.hook.json/src/main/scala/org/openmole/plugin/hook/json/JSONHook.scala
...c/main/scala/org/openmole/plugin/hook/json/JSONHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.hook.modifier/src/main/scala/org/openmole/plugin/hook/modifier/ConditionHook.scala
...ala/org/openmole/plugin/hook/modifier/ConditionHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.hook.modifier/src/main/scala/org/openmole/plugin/hook/modifier/package.scala
...ain/scala/org/openmole/plugin/hook/modifier/package.scala
+2
-1
openmole/plugins/org.openmole.plugin.hook.omr/src/main/scala/org/openmole/plugin/hook/omr/OMROutputFormat.scala
.../scala/org/openmole/plugin/hook/omr/OMROutputFormat.scala
+1
-1
openmole/plugins/org.openmole.plugin.method.directsampling/src/main/scala/org/openmole/plugin/method/directsampling/package.scala
...a/org/openmole/plugin/method/directsampling/package.scala
+2
-2
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/SavePopulationHook.scala
...openmole/plugin/method/evolution/SavePopulationHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.method.evolution/src/main/scala/org/openmole/plugin/method/evolution/package.scala
.../scala/org/openmole/plugin/method/evolution/package.scala
+1
-0
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/MorrisHook.scala
...a/org/openmole/plugin/method/sensitivity/MorrisHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/SaltelliHook.scala
...org/openmole/plugin/method/sensitivity/SaltelliHook.scala
+1
-0
openmole/plugins/org.openmole.plugin.method.sensitivity/src/main/scala/org/openmole/plugin/method/sensitivity/package.scala
...cala/org/openmole/plugin/method/sensitivity/package.scala
+1
-0
openmole/plugins/org.openmole.plugin.task.scala/src/main/scala/org/openmole/plugin/task/scala/ScalaTask.scala
...main/scala/org/openmole/plugin/task/scala/ScalaTask.scala
+1
-1
No files found.
openmole/bin/org.openmole.modules/src/main/scala/org/openmole/modules/Module.scala
View file @
9fa387e2
...
...
@@ -18,7 +18,7 @@
package
org.openmole.modules
import
org.openmole.core.module._
import
org.openmole.core.workflow.
mole
.CSVHook
import
org.openmole.core.workflow.
hook
.CSVHook
import
org.openmole.plugin.environment.condor.CondorEnvironment
import
org.openmole.plugin.environment.egi._
import
org.openmole.plugin.environment.oar.OAREnvironment
...
...
openmole/core/org.openmole.core.dsl/src/main/scala/org/openmole/core/dsl/extension/package.scala
View file @
9fa387e2
...
...
@@ -13,9 +13,9 @@ package object extension {
type
ScalarOrSequenceOfDouble
[
T
]
=
org
.
openmole
.
core
.
workflow
.
tools
.
ScalarOrSequenceOfDouble
[
T
]
def
ScalarOrSequenceOfDouble
=
org
.
openmole
.
core
.
workflow
.
tools
.
ScalarOrSequenceOfDouble
type
Hook
=
org
.
openmole
.
core
.
workflow
.
mole
.
FromContextHook
def
Hook
=
org
.
openmole
.
core
.
workflow
.
mole
.
Hook
def
FormattedFileHook
=
org
.
openmole
.
core
.
workflow
.
mole
.
FormattedFileHook
type
Hook
=
org
.
openmole
.
core
.
workflow
.
hook
.
FromContextHook
def
Hook
=
org
.
openmole
.
core
.
workflow
.
hook
.
Hook
def
FormattedFileHook
=
org
.
openmole
.
core
.
workflow
.
hook
.
FormattedFileHook
type
Source
=
org
.
openmole
.
core
.
workflow
.
mole
.
Source
type
FromContextSource
=
org
.
openmole
.
core
.
workflow
.
mole
.
FromContextSource
...
...
@@ -41,8 +41,12 @@ package object extension {
type
Context
=
org
.
openmole
.
core
.
context
.
Context
def
Context
=
org
.
openmole
.
core
.
context
.
Context
type
WritableOutput
=
org
.
openmole
.
core
.
workflow
.
tools
.
WritableOutput
val
WritableOutput
=
org
.
openmole
.
core
.
workflow
.
tools
.
WritableOutput
type
WritableOutput
=
org
.
openmole
.
core
.
workflow
.
format
.
WritableOutput
val
WritableOutput
=
org
.
openmole
.
core
.
workflow
.
format
.
WritableOutput
val
OutputFormat
=
org
.
openmole
.
core
.
workflow
.
format
.
OutputFormat
type
OutputFormat
[
T
,
D
]
=
org
.
openmole
.
core
.
workflow
.
format
.
OutputFormat
[
T
,
D
]
type
OutputContent
=
OutputFormat
.
OutputContent
def
ExpandedString
=
org
.
openmole
.
core
.
expansion
.
ExpandedString
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/Activator.scala
View file @
9fa387e2
...
...
@@ -2,7 +2,7 @@ package org.openmole.core.workflow
import
org.openmole.core.pluginmanager.PluginInfo
import
org.openmole.core.preference.ConfigurationInfo
import
org.openmole.core.workflow.
mole.CSVHook
.CSVOutputFormat
import
org.openmole.core.workflow.
format
.CSVOutputFormat
import
org.osgi.framework.
{
BundleActivator
,
BundleContext
}
class
Activator
extends
BundleActivator
{
...
...
@@ -54,8 +54,6 @@ class Activator extends BundleActivator {
TaskKeyWord
(
objectName
(
ClosureTask
)),
TaskKeyWord
(
objectName
(
ToArrayTask
)),
TaskKeyWord
(
objectName
(
MoleTask
)),
TaskKeyWord
(
objectName
(
FromContextTask
)),
HookKeyWord
(
objectName
(
FromContextHook
)),
OtherKeyWord
(
objectName
(
CSVOutputFormat
))
)
}
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/composition/package.scala
View file @
9fa387e2
...
...
@@ -31,12 +31,13 @@ package composition {
import
org.openmole.core.outputmanager.OutputManager
import
org.openmole.core.workflow.builder.DefinitionScope
import
org.openmole.core.workflow.execution.
{
EnvironmentProvider
,
LocalEnvironmentProvider
}
import
org.openmole.core.workflow.mole.CSVHook.CSVOutputFormat
import
org.openmole.core.workflow.mole.
{
CSVHook
,
OutputFormat
,
FormattedFileHook
,
Grouping
,
Hook
,
MasterCapsule
,
Mole
,
MoleCapsule
,
MoleExecution
,
MoleExecutionContext
,
MoleServices
,
Source
}
import
org.openmole.core.workflow.format.
{
OutputFormat
,
WritableOutput
,
CSVOutputFormat
}
import
org.openmole.core.workflow.hook.
{
FormattedFileHook
,
Hook
}
import
org.openmole.core.workflow.mole.
{
Grouping
,
MasterCapsule
,
Mole
,
MoleCapsule
,
MoleExecution
,
MoleExecutionContext
,
MoleServices
,
Source
}
import
org.openmole.core.workflow.sampling.Sampling
import
org.openmole.core.workflow.task.
{
EmptyTask
,
ExplorationTask
,
Task
}
import
org.openmole.core.workflow.tools.
{
OptionalArgument
,
WritableOutput
}
import
org.openmole.core.workflow.
tools
.WritableOutput.Display
import
org.openmole.core.workflow.tools.
OptionalArgument
import
org.openmole.core.workflow.
format
.WritableOutput.Display
import
org.openmole.core.workflow.transition._
import
org.openmole.core.workflow.validation.TypeUtil
import
shapeless.
{
::,
HList
}
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/CSVOutputFormat.scala
0 → 100644
View file @
9fa387e2
package
org.openmole.core.workflow.format
import
java.io.PrintStream
import
org.openmole.core.context.
{
Val
,
Variable
}
import
org.openmole.core.csv
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.tools.OptionalArgument
object
CSVOutputFormat
{
implicit
def
format
:
OutputFormat
[
CSVOutputFormat
,
Any
]
=
new
OutputFormat
[
CSVOutputFormat
,
Any
]
{
override
def
write
(
format
:
CSVOutputFormat
,
output
:
WritableOutput
,
content
:
OutputFormat.OutputContent
,
method
:
Any
)
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
import
p._
def
headerLine
(
variables
:
Seq
[
Variable
[
_
]])
=
format
.
header
.
map
(
_
.
from
(
context
))
getOrElse
csv
.
header
(
variables
.
map
(
_
.
prototype
),
variables
.
map
(
_
.
value
),
arrayOnRow
=
format
.
arrayOnRow
)
def
writeFile
(
f
:
File
,
variables
:
Seq
[
Variable
[
_
]])
=
{
val
create
=
!
format
.
append
||
f
.
isEmpty
val
h
=
if
(
f
.
isEmpty
)
Some
(
headerLine
(
variables
))
else
None
if
(
create
)
f
.
atomicWithPrintStream
{
ps
⇒
csv
.
writeVariablesToCSV
(
ps
,
h
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
}
else
f
.
withPrintStream
(
append
=
true
,
create
=
true
)
{
ps
⇒
csv
.
writeVariablesToCSV
(
ps
,
h
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
}
}
def
writeStream
(
ps
:
PrintStream
,
section
:
Option
[
String
],
variables
:
Seq
[
Variable
[
_
]])
=
section
match
{
case
None
⇒
val
header
=
Some
(
headerLine
(
variables
))
csv
.
writeVariablesToCSV
(
ps
,
header
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
case
Some
(
section
)
⇒
ps
.
println
(
section
+
":"
)
val
header
=
Some
(
headerLine
(
variables
))
csv
.
writeVariablesToCSV
(
ps
,
header
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
,
margin
=
" "
)
}
import
OutputFormat._
import
WritableOutput._
(
output
,
content
)
match
{
case
(
FileValue
(
file
),
PlainContent
(
variables
,
name
))
⇒
val
f
=
name
match
{
case
None
⇒
file
.
from
(
context
)
case
Some
(
name
)
⇒
file
.
from
(
context
)
/
s
"${name.from(context)}.csv"
}
writeFile
(
f
,
variables
)
case
(
FileValue
(
file
),
SectionContent
(
sections
))
⇒
val
directory
=
file
.
from
(
context
)
for
{
section
←
sections
}
writeFile
(
directory
/
s
"${section.name.from(context)}.csv"
,
section
.
variables
)
case
(
StreamValue
(
ps
),
PlainContent
(
variables
,
name
))
⇒
writeStream
(
ps
,
name
.
map
(
_
.
from
(
context
)),
variables
)
case
(
StreamValue
(
ps
),
SectionContent
(
sections
))
⇒
for
{
section
←
sections
}
writeStream
(
ps
,
Some
(
section
.
name
.
from
(
context
)),
section
.
variables
)
}
}
override
def
validate
(
format
:
CSVOutputFormat
)
=
{
p
⇒
import
p._
format
.
header
.
option
.
toSeq
.
flatMap
(
_
.
validate
(
inputs
))
}
}
}
case
class
CSVOutputFormat
(
header
:
OptionalArgument
[
FromContext
[
String
]]
=
None
,
unrollArray
:
Boolean
=
false
,
arrayOnRow
:
Boolean
=
false
,
append
:
Boolean
=
false
)
\ No newline at end of file
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/OutputFormat.scala
0 → 100644
View file @
9fa387e2
package
org.openmole.core.workflow.format
import
org.openmole.core.context._
import
org.openmole.core.expansion._
import
org.openmole.core.workflow.hook.FromContextHook
object
OutputFormat
{
object
OutputContent
{
implicit
def
sectionToContent
(
s
:
Seq
[
OutputSection
])
=
SectionContent
(
s
)
implicit
def
variablesToPlainContent
(
v
:
Seq
[
Variable
[
_
]])
=
PlainContent
(
v
)
}
sealed
trait
OutputContent
case
class
SectionContent
(
sections
:
Seq
[
OutputSection
])
extends
OutputContent
case
class
PlainContent
(
variables
:
Seq
[
Variable
[
_
]],
name
:
Option
[
FromContext
[
String
]]
=
None
)
extends
OutputContent
case
class
OutputSection
(
name
:
FromContext
[
String
],
variables
:
Seq
[
Variable
[
_
]])
}
trait
OutputFormat
[
T
,
-M
]
{
def
write
(
format
:
T
,
output
:
WritableOutput
,
content
:
OutputFormat.OutputContent
,
method
:
M
)
:
FromContext
[
Unit
]
def
validate
(
format
:
T
)
:
FromContextHook.ValidateParameters
⇒
Seq
[
Throwable
]
}
\ No newline at end of file
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
tools
/WritableOutput.scala
→
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
format
/WritableOutput.scala
View file @
9fa387e2
package
org.openmole.core.workflow.
tools
package
org.openmole.core.workflow.
format
/*
* Copyright (C) 2019 Romain Reuillon
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/format/package.scala
0 → 100644
View file @
9fa387e2
package
org.openmole.core.workflow
package
format
{
import
org.openmole.tool.outputredirection._
trait
FormatPackage
{
type
Display
=
WritableOutput
.
Display
def
display
(
implicit
outputRedirection
:
OutputRedirection
)
:
Display
=
outputRedirection
.
output
def
CSVOutputFormat
=
format
.
CSVOutputFormat
}
}
package
object
format
{
}
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/CSVHook.scala
0 → 100644
View file @
9fa387e2
package
org.openmole.core.workflow.hook
import
java.io.PrintStream
import
org.openmole.core.context.
{
Val
,
Variable
}
import
org.openmole.core.csv
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder.DefinitionScope
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.format.
{
CSVOutputFormat
,
WritableOutput
}
import
org.openmole.core.workflow.tools.OptionalArgument
object
CSVHook
{
def
apply
(
output
:
WritableOutput
,
values
:
Val
[
_
]*)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
)
:
FromContextHook
=
apply
(
output
,
values
.
toVector
)
def
apply
(
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
exclude
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
header
:
OptionalArgument
[
FromContext
[
String
]]
=
None
,
unrollArray
:
Boolean
=
false
,
overwrite
:
Boolean
=
false
)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
)
:
FromContextHook
=
FormattedFileHook
(
format
=
CSVOutputFormat
(
header
=
header
,
unrollArray
=
unrollArray
,
append
=
!
overwrite
),
output
=
output
,
values
=
values
,
exclude
=
exclude
,
name
=
Some
(
"CSVHook"
)
)
}
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
mole
/FormattedFileHook.scala
→
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
hook
/FormattedFileHook.scala
View file @
9fa387e2
package
org.openmole.core.workflow.
mole
package
org.openmole.core.workflow.
hook
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.mole
import
org.openmole.core.workflow.tools.WritableOutput
import
org.openmole.core.context._
import
org.openmole.core.exception.UserBadDataError
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
object
OutputFormat
{
object
OutputContent
{
implicit
def
sectionToContent
(
s
:
Seq
[
OutputSection
])
=
SectionContent
(
s
)
implicit
def
variablesToPlainContent
(
v
:
Seq
[
Variable
[
_
]])
=
PlainContent
(
v
)
}
sealed
trait
OutputContent
case
class
SectionContent
(
sections
:
Seq
[
OutputSection
])
extends
OutputContent
case
class
PlainContent
(
variables
:
Seq
[
Variable
[
_
]],
name
:
Option
[
FromContext
[
String
]]
=
None
)
extends
OutputContent
case
class
OutputSection
(
name
:
FromContext
[
String
],
variables
:
Seq
[
Variable
[
_
]])
}
trait
OutputFormat
[
T
,
-M
]
{
def
write
(
format
:
T
,
output
:
WritableOutput
,
content
:
OutputFormat.OutputContent
,
method
:
M
)
:
FromContext
[
Unit
]
def
validate
(
format
:
T
)
:
FromContextHook.ValidateParameters
⇒
Seq
[
Throwable
]
}
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.format._
object
FormattedFileHook
{
...
...
@@ -34,7 +15,7 @@ object FormattedFileHook {
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
exclude
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
method
:
M
=
None
,
name
:
Option
[
String
]
=
None
)(
implicit
valName
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
T
,
M
])
:
mole.
FromContextHook
=
name
:
Option
[
String
]
=
None
)(
implicit
valName
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
,
fileFormat
:
OutputFormat
[
T
,
M
])
:
FromContextHook
=
Hook
(
name
getOrElse
"FileFormatHook"
)
{
parameters
⇒
import
parameters._
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
mole
/FromContextHook.scala
→
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
hook
/FromContextHook.scala
View file @
9fa387e2
package
org.openmole.core.workflow.
mole
package
org.openmole.core.workflow.
hook
import
monocle.macros._
import
org.openmole.core.context._
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
mole
/Hook.scala
→
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/
hook
/Hook.scala
View file @
9fa387e2
...
...
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.openmole.core.workflow.
mole
package
org.openmole.core.workflow.
hook
import
org.openmole.core.context.Context
import
org.openmole.core.expansion.FromContext
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/hook/package.scala
0 → 100644
View file @
9fa387e2
package
org.openmole.core.workflow
package
hook
{
trait
HookPackage
{
def
CSVHook
=
hook
.
CSVHook
val
FromContextHook
=
hook
.
FromContextHook
type
FromContextHook
=
hook
.
FromContextHook
}
}
package
object
hook
{
def
Hook
=
FromContextHook
}
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/CSVHook.scala
deleted
100644 → 0
View file @
40e08183
package
org.openmole.core.workflow.mole
import
java.io.PrintStream
import
org.openmole.core.csv
import
org.openmole.core.workflow.mole
import
org.openmole.core.workflow.tools.
{
OptionalArgument
,
WritableOutput
}
import
org.openmole.core.context._
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
import
org.openmole.core.workflow.dsl._
object
CSVHook
{
def
apply
(
output
:
WritableOutput
,
values
:
Val
[
_
]*)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
)
:
mole.FromContextHook
=
apply
(
output
,
values
.
toVector
)
def
apply
(
output
:
WritableOutput
,
values
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
exclude
:
Seq
[
Val
[
_
]]
=
Vector
.
empty
,
header
:
OptionalArgument
[
FromContext
[
String
]]
=
None
,
unrollArray
:
Boolean
=
false
,
overwrite
:
Boolean
=
false
)(
implicit
name
:
sourcecode.Name
,
definitionScope
:
DefinitionScope
)
:
mole.FromContextHook
=
FormattedFileHook
(
format
=
CSVOutputFormat
(
header
=
header
,
unrollArray
=
unrollArray
,
append
=
!
overwrite
),
output
=
output
,
values
=
values
,
exclude
=
exclude
,
name
=
Some
(
"CSVHook"
)
)
object
CSVOutputFormat
{
implicit
def
format
:
OutputFormat
[
CSVOutputFormat
,
Any
]
=
new
OutputFormat
[
CSVOutputFormat
,
Any
]
{
override
def
write
(
format
:
CSVOutputFormat
,
output
:
WritableOutput
,
content
:
OutputFormat.OutputContent
,
method
:
Any
)
:
FromContext
[
Unit
]
=
FromContext
{
p
⇒
import
p._
def
headerLine
(
variables
:
Seq
[
Variable
[
_
]])
=
format
.
header
.
map
(
_
.
from
(
context
))
getOrElse
csv
.
header
(
variables
.
map
(
_
.
prototype
),
variables
.
map
(
_
.
value
),
arrayOnRow
=
format
.
arrayOnRow
)
def
writeFile
(
f
:
File
,
variables
:
Seq
[
Variable
[
_
]])
=
{
val
create
=
!
format
.
append
||
f
.
isEmpty
val
h
=
if
(
f
.
isEmpty
)
Some
(
headerLine
(
variables
))
else
None
if
(
create
)
f
.
atomicWithPrintStream
{
ps
⇒
csv
.
writeVariablesToCSV
(
ps
,
h
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
}
else
f
.
withPrintStream
(
append
=
true
,
create
=
true
)
{
ps
⇒
csv
.
writeVariablesToCSV
(
ps
,
h
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
}
}
def
writeStream
(
ps
:
PrintStream
,
section
:
Option
[
String
],
variables
:
Seq
[
Variable
[
_
]])
=
section
match
{
case
None
⇒
val
header
=
Some
(
headerLine
(
variables
))
csv
.
writeVariablesToCSV
(
ps
,
header
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
)
case
Some
(
section
)
⇒
ps
.
println
(
section
+
":"
)
val
header
=
Some
(
headerLine
(
variables
))
csv
.
writeVariablesToCSV
(
ps
,
header
,
variables
.
map
(
_
.
value
),
unrollArray
=
format
.
unrollArray
,
arrayOnRow
=
format
.
arrayOnRow
,
margin
=
" "
)
}
import
WritableOutput._
import
OutputFormat._
(
output
,
content
)
match
{
case
(
FileValue
(
file
),
PlainContent
(
variables
,
name
))
⇒
val
f
=
name
match
{
case
None
⇒
file
.
from
(
context
)
case
Some
(
name
)
⇒
file
.
from
(
context
)
/
s
"${name.from(context)}.csv"
}
writeFile
(
f
,
variables
)
case
(
FileValue
(
file
),
SectionContent
(
sections
))
⇒
val
directory
=
file
.
from
(
context
)
for
{
section
←
sections
}
writeFile
(
directory
/
s
"${section.name.from(context)}.csv"
,
section
.
variables
)
case
(
StreamValue
(
ps
),
PlainContent
(
variables
,
name
))
⇒
writeStream
(
ps
,
name
.
map
(
_
.
from
(
context
)),
variables
)
case
(
StreamValue
(
ps
),
SectionContent
(
sections
))
⇒
for
{
section
←
sections
}
writeStream
(
ps
,
Some
(
section
.
name
.
from
(
context
)),
section
.
variables
)
}
}
override
def
validate
(
format
:
CSVOutputFormat
)
=
{
p
⇒
import
p._
format
.
header
.
option
.
toSeq
.
flatMap
(
_
.
validate
(
inputs
))
}
}
}
case
class
CSVOutputFormat
(
header
:
OptionalArgument
[
FromContext
[
String
]]
=
None
,
unrollArray
:
Boolean
=
false
,
arrayOnRow
:
Boolean
=
false
,
append
:
Boolean
=
false
)
}
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/MoleExecution.scala
View file @
9fa387e2
...
...
@@ -27,6 +27,7 @@ import org.openmole.core.exception.{ InternalProcessingError, UserBadDataError }
import
org.openmole.core.threadprovider.ThreadProvider
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.execution._
import
org.openmole.core.workflow.hook.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.job.State._
import
org.openmole.core.workflow.job._
import
org.openmole.core.workflow.mole
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/mole/package.scala
View file @
9fa387e2
...
...
@@ -17,26 +17,19 @@
package
org.openmole.core.workflow
import
org.openmole.core.workflow.hook.Hook
import
scala.language.implicitConversions
package
mole
{
trait
MolePackage
{
def
CSVHook
=
mole
.
CSVHook
def
CSVOutputFormat
=
mole
.
CSVHook
.
CSVOutputFormat
val
FromContextHook
=
mole
.
FromContextHook
type
FromContextHook
=
mole
.
FromContextHook
trait
MolePackage
{
type
FromContextSource
=
mole
.
FromContextSource
val
OutputFormat
=
mole
.
OutputFormat
type
OutputFormat
[
T
,
D
]
=
mole
.
OutputFormat
[
T
,
D
]
type
OutputContent
=
OutputFormat
.
OutputContent
}
}
package
object
mole
{
def
Hook
=
FromContextHook
def
Source
=
FromContextSource
case
class
Hooks
(
map
:
Map
[
MoleCapsule
,
Traversable
[
Hook
]])
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/package.scala
View file @
9fa387e2
...
...
@@ -26,6 +26,8 @@ package workflow {
import
org.openmole.core.workflow.builder.BuilderPackage
import
org.openmole.core.workflow.mole.MolePackage
import
org.openmole.core.workflow.composition.CompositionPackage
import
org.openmole.core.workflow.format.FormatPackage
import
org.openmole.core.workflow.hook.HookPackage
import
org.openmole.core.workflow.sampling.SamplingPackage
import
org.openmole.core.workflow.task.TaskPackage
import
org.openmole.core.workflow.tools.ToolsPackage
...
...
@@ -42,6 +44,8 @@ package workflow {
with
ContextPackage
with
ExpansionPackage
with
KeyWordPackage
with
FormatPackage
with
HookPackage
object
dsl
extends
ExportedPackage
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/test/TestHook.scala
View file @
9fa387e2
...
...
@@ -20,7 +20,7 @@ import monocle.macros.Lenses
import
org.openmole.core.context.Context
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
import
org.openmole.core.workflow.
mole
.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.
hook
.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.test.Stubs._
object
TestHook
{
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/tools/package.scala
View file @
9fa387e2
...
...
@@ -46,9 +46,6 @@ package tools {
def
apply
[
S
](
s
:
S
)(
implicit
expandable
:
Expandable
[
S
,
T
])
=
expandable
.
expand
(
s
)
}
type
Display
=
tools
.
WritableOutput
.
Display
def
display
(
implicit
outputRedirection
:
OutputRedirection
)
:
Display
=
outputRedirection
.
output
}
}
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/validation/DataflowProblem.scala
View file @
9fa387e2
...
...
@@ -18,7 +18,8 @@
package
org.openmole.core.workflow.validation
import
org.openmole.core.context.
{
Val
,
ValType
}
import
org.openmole.core.workflow.mole.
{
Hook
,
MoleCapsule
,
Source
}
import
org.openmole.core.workflow.hook.Hook
import
org.openmole.core.workflow.mole.
{
MoleCapsule
,
Source
}
import
org.openmole.core.workflow.transition.TransitionSlot
import
org.openmole.core.workflow.validation.TypeUtil.InvalidType
...
...
openmole/core/org.openmole.core.workflow/src/main/scala/org/openmole/core/workflow/validation/ValidationProblem.scala
View file @
9fa387e2
...
...
@@ -20,7 +20,8 @@ package org.openmole.core.workflow.validation
import
org.openmole.core.context.Val
import
org.openmole.core.fileservice.FileService
import
org.openmole.core.tools.io.Prettifier
import
org.openmole.core.workflow.mole.
{
Hook
,
_
}
import
org.openmole.core.workflow.hook.Hook
import
org.openmole.core.workflow.mole._
import
org.openmole.core.workflow.task._
import
org.openmole.core.workflow.transition._
import
org.openmole.core.workspace.TmpDirectory
...
...
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/Activator.scala
View file @
9fa387e2
...
...
@@ -19,7 +19,7 @@ package org.openmole.plugin.hook.file
import
org.openmole.core.pluginmanager._
import
org.openmole.core.preference.ConfigurationInfo
import
org.openmole.core.workflow.
mole
.CSVHook
import
org.openmole.core.workflow.
hook
.CSVHook
import
org.osgi.framework.BundleContext
class
Activator
extends
PluginInfoActivator
{
...
...
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/AppendToFileHook.scala
View file @
9fa387e2
...
...
@@ -19,13 +19,9 @@ package org.openmole.plugin.hook.file
import
java.io.File
import
monocle.macros.Lenses
import
org.openmole.core.context.Context
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
import
org.openmole.core.dsl._
import
org.openmole.core.workflow.mole.
{
MoleExecutionContext
,
_
}
import
org.openmole.core.workflow.validation._
import
org.openmole.core.dsl.extension._
import
org.openmole.tool.stream._
object
AppendToFileHook
{
...
...
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/CopyFileHook.scala
View file @
9fa387e2
...
...
@@ -25,6 +25,7 @@ import org.openmole.core.context.{ Context, Val, Variable }
import
org.openmole.core.expansion.FromContext
import
org.openmole.core.workflow.builder._
import
org.openmole.core.workflow.dsl._
import
org.openmole.core.workflow.hook.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.mole.
{
MoleExecutionContext
,
_
}
import
org.openmole.core.workflow.validation._
import
org.openmole.plugin.hook.file.CopyFileHook._
...
...
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/MatrixHook.scala
View file @
9fa387e2
...
...
@@ -5,6 +5,7 @@ import org.openmole.core.context.Context
import
org.openmole.core.dsl._
import
org.openmole.core.expansion._
import
org.openmole.core.workflow.builder._
import
org.openmole.core.workflow.hook.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.mole._
import
org.openmole.core.workflow.validation._
...
...
openmole/plugins/org.openmole.plugin.hook.file/src/main/scala/org/openmole/plugin/hook/file/SaveHook.scala
View file @
9fa387e2
...
...
@@ -25,6 +25,7 @@ import org.openmole.core.exception._
import
org.openmole.core.expansion._
import
org.openmole.core.serializer._
import
org.openmole.core.workflow.builder._
import
org.openmole.core.workflow.hook.
{
Hook
,
HookExecutionContext
}
import
org.openmole.core.workflow.mole._