Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iotamak-core
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
SMAC
AMAK
Python
IoTAMAK
iotamak-core
Commits
0e1b7f73
Commit
0e1b7f73
authored
3 years ago
by
shinedday
Browse files
Options
Downloads
Patches
Plain Diff
Remove mode in scheduler as it's not usefull
parent
00ea69ac
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dist/iotAmak-0.0.1-py3-none-any.whl
+0
-0
0 additions, 0 deletions
dist/iotAmak-0.0.1-py3-none-any.whl
iotAmak/ihm.py
+1
-10
1 addition, 10 deletions
iotAmak/ihm.py
iotAmak/scheduler.py
+5
-13
5 additions, 13 deletions
iotAmak/scheduler.py
with
6 additions
and
23 deletions
dist/iotAmak-0.0.1-py3-none-any.whl
+
0
−
0
View file @
0e1b7f73
No preview for this file type
This diff is collapsed.
Click to expand it.
iotAmak/ihm.py
+
1
−
10
View file @
0e1b7f73
...
@@ -150,14 +150,8 @@ class Ihm(MqttClient, SSHClient):
...
@@ -150,14 +150,8 @@ class Ihm(MqttClient, SSHClient):
if
self
.
experiment_loaded
and
self
.
ping_is_true
:
if
self
.
experiment_loaded
and
self
.
ping_is_true
:
# choose exec
print
(
"
Choose execution mode for the scheduler
"
)
print
(
"
0 : step by step, 1 : auto
"
)
while
cmd
not
in
[
"
0
"
,
"
1
"
]:
cmd
=
input
(
"
>
"
)
# start subprocess scheduler
# start subprocess scheduler
p1
=
Popen
([
sys
.
executable
,
'
./scheduler.py
'
,
cmd
,
self
.
broker_ip
])
p1
=
Popen
([
sys
.
executable
,
'
./scheduler.py
'
,
self
.
broker_ip
])
sleep
(
1
)
sleep
(
1
)
# start subprocess amas
# start subprocess amas
send_client
=
[
c
.
to_send
()
for
c
in
self
.
clients
]
send_client
=
[
c
.
to_send
()
for
c
in
self
.
clients
]
...
@@ -174,8 +168,5 @@ class Ihm(MqttClient, SSHClient):
...
@@ -174,8 +168,5 @@ class Ihm(MqttClient, SSHClient):
if
cmd
.
lower
()
in
[
"
s
"
,
"
step
"
]:
if
cmd
.
lower
()
in
[
"
s
"
,
"
step
"
]:
self
.
client
.
publish
(
"
ihm/step
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
if
cmd
.
lower
()
==
"
mode
"
:
self
.
client
.
publish
(
"
ihm/mode
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
sleep
(
2
)
sleep
(
2
)
This diff is collapsed.
Click to expand it.
iotAmak/scheduler.py
+
5
−
13
View file @
0e1b7f73
...
@@ -16,13 +16,11 @@ class Scheduler(Schedulable):
...
@@ -16,13 +16,11 @@ class Scheduler(Schedulable):
Scheduler class, it
'
s role is to make sure the amas, the env and all the agents stay in sync
Scheduler class, it
'
s role is to make sure the amas, the env and all the agents stay in sync
"""
"""
def
__init__
(
self
,
execution_policy
:
int
,
broker_ip
:
str
)
->
None
:
def
__init__
(
self
,
broker_ip
:
str
)
->
None
:
Schedulable
.
__init__
(
self
,
broker_ip
,
"
Scheduler
"
)
Schedulable
.
__init__
(
self
,
broker_ip
,
"
Scheduler
"
)
self
.
sleep_between_cycle
=
0
self
.
sleep_between_cycle
=
0
# 0: pas a pas, 1: auto
self
.
execution_policy
:
int
=
execution_policy
self
.
ihm_token
=
0
self
.
ihm_token
=
0
self
.
paused
=
True
self
.
paused
=
True
...
@@ -33,19 +31,12 @@ class Scheduler(Schedulable):
...
@@ -33,19 +31,12 @@ class Scheduler(Schedulable):
self
.
subscribe
(
"
ihm/step
"
,
self
.
step
)
self
.
subscribe
(
"
ihm/step
"
,
self
.
step
)
self
.
subscribe
(
"
ihm/pause
"
,
self
.
pause
)
self
.
subscribe
(
"
ihm/pause
"
,
self
.
pause
)
self
.
subscribe
(
"
ihm/unpause
"
,
self
.
unpause
)
self
.
subscribe
(
"
ihm/unpause
"
,
self
.
unpause
)
self
.
subscribe
(
"
ihm/mode
"
,
self
.
mode
)
self
.
agent_waiting
=
0
self
.
agent_waiting
=
0
self
.
schedulable_waiting
=
0
self
.
schedulable_waiting
=
0
print
(
"
Init done
"
)
print
(
"
Init done
"
)
def
mode
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
Function called when the IHM change scheduler mode
"""
self
.
execution_policy
=
(
1
-
self
.
execution_policy
)
%
2
def
pause
(
self
,
client
,
userdata
,
message
)
->
None
:
def
pause
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
"""
Function called when the IHM pause the scheduler
Function called when the IHM pause the scheduler
...
@@ -109,6 +100,8 @@ class Scheduler(Schedulable):
...
@@ -109,6 +100,8 @@ class Scheduler(Schedulable):
"""
"""
Called when the scheduler is waiting for an action of the IHM
Called when the scheduler is waiting for an action of the IHM
"""
"""
if
not
self
.
paused
:
return
while
self
.
ihm_token
==
0
:
while
self
.
ihm_token
==
0
:
sleep
(
self
.
wait_delay
)
sleep
(
self
.
wait_delay
)
self
.
ihm_token
-=
1
self
.
ihm_token
-=
1
...
@@ -154,8 +147,7 @@ class Scheduler(Schedulable):
...
@@ -154,8 +147,7 @@ class Scheduler(Schedulable):
while
not
self
.
exit_bool
:
while
not
self
.
exit_bool
:
print
(
"
Cycle :
"
,
self
.
nbr_cycle
)
print
(
"
Cycle :
"
,
self
.
nbr_cycle
)
if
self
.
execution_policy
==
0
or
self
.
paused
:
self
.
wait_ihm
()
self
.
wait_ihm
()
if
self
.
exit_bool
:
if
self
.
exit_bool
:
break
break
...
@@ -176,5 +168,5 @@ class Scheduler(Schedulable):
...
@@ -176,5 +168,5 @@ class Scheduler(Schedulable):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
s
=
Scheduler
(
int
(
sys
.
argv
[
1
]),
str
(
sys
.
argv
[
2
]))
s
=
Scheduler
(
str
(
sys
.
argv
[
1
]))
s
.
run
()
s
.
run
()
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