Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lustre-v6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
verimag
synchrone
lustre-v6
Commits
36ae3160
Commit
36ae3160
authored
9 months ago
by
Leandre Lacourt
Browse files
Options
Downloads
Patches
Plain Diff
generateur d'un nouveau yaml pour generer des taches (pas fini)
parent
28641cf6
No related branches found
No related tags found
No related merge requests found
Pipeline
#187798
passed
9 months ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/soc2yaml.ml
+109
-70
109 additions, 70 deletions
lib/soc2yaml.ml
with
109 additions
and
70 deletions
lib/soc2yaml.ml
+
109
−
70
View file @
36ae3160
...
...
@@ -9,12 +9,65 @@ open SocNameC
let
(
f
:
Soc
.
key
->
Soc
.
tbl
->
string
->
unit
)
=
fun
sk
stbl
basename
->
let
main_soc
=
SocUtils
.
find
(
Lxm
.
dummy
"dfsdf"
)
sk
stbl
in
(*let str = SocUtils.string_of_soc main_soc in*)
printf
"%s.yaml file created
\n
%!"
basename
;
let
nodes
=
SocNameC
.
get_nodes
main_soc
in
let
filename
=
SocNameC
.
get_filename
main_soc
in
let
ctx_name
=
SocNameC
.
get_ctx_name
main_soc
in
let
variables
=
(
SocNameC
.
get_inputs
main_soc
)
@
(
SocNameC
.
get_variables
main_soc
)
@
(
SocNameC
.
get_outputs
main_soc
)
in
let
instances
=
SocNameC
.
get_instances
main_soc
in
let
yaml_file
=
open_out
(
filename
^
".yml"
)
in
let
(
var2yaml
:
int
->
string
)
=
fun
i
->
let
choose_var
:
int
->
variable_type
->
bool
=
fun
i
var
->
i
=
var
.
id
in
let
findvar
:
unit
->
variable_type
=
fun
()
->
List
.
find
(
choose_var
i
)
variables
in
let
var
=
findvar
()
in
let
s
=
" - name: _"
^
var
.
name
^
"
\n
type: "
^
var
.
var_type
^
"
\n
"
in
s
in
(* va y avoir des tâches à la place donc penser à changer pour utiliser les instances avec des tâches
PS : ident = la liste des ids des variables qui vont être utilisées*)
let
(
tasks2yaml
:
instance_type
->
unit
)
=
fun
inst
->
let
node
=
inst
.
node
in
let
f1
:
node_type
->
string
=
fun
node
->
node
.
file_name
in
let
s_vi
=
String
.
concat
""
(
List
.
map
var2yaml
inst
.
var_in
)
in
let
s_vo
=
String
.
concat
""
(
List
.
map
var2yaml
inst
.
var_out
)
in
let
s
=
" - task: "
^
"
\n
name: "
^
(
f1
(
List
.
nth
nodes
node
))
^
"
\n
var_in:
\n
"
^
s_vi
^
" var_out:
\n
"
^
s_vo
in
fprintf
yaml_file
"%s"
s
in
let
(
main2yaml
:
unit
->
unit
)
=
fun
()
->
let
s
=
"main_node: "
^
filename
in
fprintf
yaml_file
"
\n
%s"
s
in
fprintf
yaml_file
"tasks:
\n
"
;
let
n
=
ref
[]
in
let
rec
(
get_one_inst_by_node
:
instance_type
list
->
instance_type
list
)
=
fun
inst_list
->
match
inst_list
with
|
[]
->
[]
|
h
::
p
->
if
Bool
.
not
(
List
.
exists
(
fun
v
->
h
.
node
=
v
)
!
n
)
then
(
n
:=
(
h
.
node
)
::!
n
;
h
::
(
get_one_inst_by_node
p
))
else
get_one_inst_by_node
p
in
List
.
iter
tasks2yaml
(
get_one_inst_by_node
instances
);
main2yaml
()
;
close_out
yaml_file
;
printf
"%s.yaml file created
\n
%!"
basename
(*let ctx_name = SocNameC.get_ctx_name main_soc in
let ctx_new = SocNameC.get_ctx_new main_soc in
let inputs = SocNameC.get_inputs main_soc in
let outputs = SocNameC.get_outputs main_soc in
...
...
@@ -23,7 +76,7 @@ let (f : Soc.key -> Soc.tbl -> string -> unit) = fun sk stbl basename ->
let instances = SocNameC.get_instances main_soc in
let yaml_file = open_out (filename ^ ".yml") in
let inst_of_var = List.init ((List.length inputs) + (List.length outputs)
+
(
List
.
length
variables
))
(
fun
_
->
ref
0
)
in
+ (List.length variables)) (fun _ -> ref 0) in
let set_inst_of_var = fun i ->
List.iter (fun v -> (List.nth inst_of_var v) := i.id) i.var_out
in
...
...
@@ -32,38 +85,32 @@ let (f : Soc.key -> Soc.tbl -> string -> unit) = fun sk stbl basename ->
let add_inst = fun id v ->
if not (List.mem !(List.nth inst_of_var v) !(List.nth inst_to_inst id)) then
(List.nth inst_to_inst id) := List.append !(List.nth inst_to_inst id) [!(List.nth inst_of_var v)]
in
let
set_inst_to_inst
=
fun
i
->
List
.
iter
(
add_inst
i
.
id
)
i
.
var_in
in
List
.
iter
set_inst_to_inst
instances
;
let
(
add_inst
:
variable_type
->
unit
)
=
fun
v
->
add_inst
0
v
.
id
in
List
.
iter
add_inst
outputs
;
let
channel_id
=
ref
0
in
let
channels
=
List
.
init
(
List
.
length
instances
+
1
)
(
fun
_
->
(
ref
[]
,
ref
[]
))
in
let
add_channel
=
fun
x
->
fun
y
->
fst
(
List
.
nth
channels
x
)
:=
List
.
append
!
(
fst
(
List
.
nth
channels
x
))
[
!
channel_id
];
snd
(
List
.
nth
channels
y
)
:=
List
.
append
!
(
snd
(
List
.
nth
channels
y
))
[
!
channel_id
];
channel_id
:=
!
channel_id
+
1
in
List
.
iteri
(
fun
x
->
fun
yl
->
(
List
.
iter
(
add_channel
x
)
!
yl
))
inst_to_inst
;
let
(
var2yaml
:
variable_type
->
unit
)
=
fun
i
->
let
s
=
" - id: "
^
(
string_of_int
i
.
id
)
^
"
\n
name: "
^
i
.
name
^
"
\n
type: "
^
i
.
var_type
in
fprintf
yaml_file
"%s
\n
"
s
in
let
(
channel2yaml
:
unit
->
unit
)
=
fun
()
->
in
let set_inst_to_inst = fun i ->
List.iter (add_inst i.id) i.var_in
in
List.iter set_inst_to_inst instances;
let (add_inst : variable_type -> unit) = fun v -> add_inst 0 v.id in
List.iter add_inst outputs;
let channel_id = ref 0 in
let channels = List.init (List.length instances + 1) (fun _ -> (ref [], ref [])) in
let add_channel = fun x -> fun y ->
fst (List.nth channels x) := List.append !(fst (List.nth channels x)) [!channel_id];
snd (List.nth channels y) := List.append !(snd (List.nth channels y)) [!channel_id];
channel_id := !channel_id + 1
in
List.iteri (fun x -> fun yl -> (List.iter (add_channel x) !yl)) inst_to_inst; *)
(*let (channel2yaml : unit -> unit) = fun () ->
for i = 0 to (!channel_id - 1) do
fprintf yaml_file " - %i\n" i;
done
in
let
(
main2yaml
:
unit
->
unit
)
=
fun
()
->
in
*)
(*
let (main2yaml : unit -> unit) = fun () ->
let f1 : variable_type -> string = fun x -> " - " ^ (string_of_int x.id) ^ "\n" in
let s_vi = String.concat "" (List.map f1 inputs) in
let s_vo = String.concat "" (List.map f1 outputs) in
...
...
@@ -71,28 +118,27 @@ let (f : Soc.key -> Soc.tbl -> string -> unit) = fun sk stbl basename ->
let s_ci = String.concat "" (List.map f2 !(snd (List.nth channels 0))) in
let s_co = String.concat "" (List.map f2 !(fst (List.nth channels 0))) in
let s = " name: " ^ filename
^
"
\n
ctx_type: "
^
ctx_name
^
"
\n
ctx_new: "
^
ctx_new
^
"
\n
var_in:
\n
"
^
s_vi
^
" var_out:
\n
"
^
s_vo
^
" ch_in:
\n
"
^
s_ci
^
" ch_out:
\n
"
^
s_co
in
fprintf
yaml_file
"%s
\n
"
s
in
let
node_id
=
ref
0
^ "\n ctx_type: " ^ ctx_name
^ "\n ctx_new: " ^ ctx_new
^ "\n var_in:\n" ^ s_vi
^ " var_out:\n" ^ s_vo
^ " ch_in:\n" ^ s_ci
^ " ch_out:\n" ^ s_co in
fprintf yaml_file "%s\n" s*)
(* let node_id = ref 0
in
let (node2yaml : node_type -> unit) = fun n ->
let s = " - id: " ^ (string_of_int !node_id)
^
"
\n
file_name: "
^
n
.
file_name
^
"
\n
fct_name: "
^
n
.
fct_name
^
"
\n
ctx: "
^
(
string_of_bool
n
.
ctx
)
in
^ "\n file_name: " ^ n.file_name
^ "\n fct_name: " ^ n.fct_name
^ "\n ctx: " ^ (string_of_bool n.ctx) in
let s_ctx = if n.ctx then "\n ctx_tab: " ^ n.ctx_tab else "" in
node_id := !node_id + 1;
fprintf yaml_file "%s\n\n" (s ^ s_ctx)
in
let
inst_id
=
(
List
.
init
(
List
.
length
nodes
)
(
fun
_
->
ref
0
))
in
in
*)
(*
let inst_id = (List.init (List.length nodes) (fun _ -> ref 0)) in
let (instance2yaml : instance_type -> unit) = fun i ->
let f1 : int -> string = fun x -> " - " ^ (string_of_int x) ^ "\n" in
let s_vi = String.concat "" (List.map f1 i.var_in) in
...
...
@@ -101,29 +147,22 @@ let (f : Soc.key -> Soc.tbl -> string -> unit) = fun sk stbl basename ->
let s_ci = String.concat "" (List.map f2 !(fst (List.nth channels i.id))) in
let s_co = String.concat "" (List.map f2 !(snd (List.nth channels i.id))) in
let s = " - id: " ^ (string_of_int !(List.nth inst_id i.node))
^
"
\n
node: "
^
(
string_of_int
i
.
node
)
^
"
\n
var_in:
\n
"
^
s_vi
^
" var_out:
\n
"
^
s_vo
^
" ch_in:
\n
"
^
s_ci
^
" ch_out:
\n
"
^
s_co
in
^ "\n node: " ^ (string_of_int i.node)
^ "\n var_in:\n" ^ s_vi
^ " var_out:\n" ^ s_vo
^ " ch_in:\n" ^ s_ci
^ " ch_out:\n" ^ s_co in
(List.nth inst_id i.node) := !(List.nth inst_id i.node) + 1;
fprintf yaml_file "%s\n" s
in
fprintf yaml_file "variables:\n";
List.iter var2yaml (inputs);
List.iter var2yaml (outputs);
List
.
iter
var2yaml
(
variables
);
fprintf
yaml_file
"
\n
channels:
\n
"
;
channel2yaml
()
;
fprintf
yaml_file
"
\n
main:
\n
"
;
main2yaml
()
;
fprintf
yaml_file
"nodes:
\n
"
;
List
.
iter
node2yaml
nodes
;
fprintf
yaml_file
"instances:
\n
"
;
List
.
iter
instance2yaml
instances
;
close_out
yaml_file
List.iter var2yaml (variables);*)
(*fprintf yaml_file "\nchannels:\n";
channel2yaml ();*)
(*fprintf yaml_file "nodes:\n";*)
(*fprintf yaml_file "\nmain:\n";*)
(*fprintf yaml_file "instances:\n";
List.iter instance2yaml instances;*)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment