Commit f78dba5dfd4f862c408fc02d55062d814dcf5937

Authored by Alexis Koralewski
2 parents b37de1f5 e7016f79
Exists in dev

Merge branch 'dev' of https://gitlab.irap.omp.eu/pyros-irap/pyros into dev

.gitignore
... ... @@ -58,13 +58,6 @@ old/
58 58  
59 59 out.*
60 60  
61   -OLD/*
62   -*_OLD*
63   -*_ORIG*
64   -*.ORIG
65   -TMP/*
66   -
67   -client.log
68 61  
69 62 docker/*.env
70 63  
... ... @@ -102,5 +95,18 @@ TOKEN
102 95 *.modif.*
103 96 *.moi
104 97 *.moi.*
  98 +*.me.*
  99 +*.me
  100 +*.me?
  101 +*.old
  102 +*.OLD
  103 +OLD/*
  104 +*_OLD*
  105 +*_ORIG*
  106 +*.ORIG
  107 +*.ORIG?
  108 +TMP/*
  109 +___*
  110 +client.log
105 111  
106 112 #privatedev/plugin/agent/triton/triton/CATALOGUES
... ...
Dockerfile
... ... @@ -29,6 +29,7 @@ ARG uid
29 29 ################
30 30  
31 31 RUN apt-get update && apt-get upgrade -y
  32 +
32 33 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
33 34  
34 35 RUN apt-get install -y \
... ... @@ -45,12 +46,15 @@ RUN apt-get install -y \
45 46 ################
46 47 # Python & pip #
47 48 ################
  49 +
48 50 # For apt-add-repository :
49 51 RUN apt-get install -y software-properties-common
50   -# Needed for python 3.10
51   -RUN add-apt-repository ppa:deadsnakes/ppa
52 52 # Needed for INDI
53 53 RUN apt-add-repository ppa:mutlaqja/ppa
  54 +
  55 +# PYTHON
  56 +# Needed for python 3.10
  57 +RUN apt-add-repository ppa:deadsnakes/ppa
54 58 RUN apt-get install -y python3.10
55 59 RUN apt-get install -y python3.10-dev
56 60 RUN apt-get install -y python3.10-distutils
... ... @@ -64,7 +68,7 @@ RUN cd /usr/bin && ln -s python3 python
64 68 #RUN apt-get install -y python3-pip
65 69 RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
66 70 #RUN pip3 install --upgrade pip
67   -RUN python3.10 -m pip install --upgrade pip
  71 +RUN python3 -m pip install --upgrade pip
68 72  
69 73  
70 74  
... ... @@ -151,11 +155,11 @@ CMD ["x11vnc", "-create", "-forever"]
151 155  
152 156  
153 157  
154   -
155   -
156 158 # Get IRAP self signed certificate
157 159 RUN echo | openssl s_client -connect gitlab.irap.omp.eu:443 -servername gitlab.irap.omp.eu 2>/dev/null | openssl x509 > /etc/ssl/certs/gitlab.irap.omp.eu.crt
158 160  
  161 +
  162 +
159 163 #################################
160 164 # PyROS user (better than root) #
161 165 #################################
... ... @@ -174,8 +178,6 @@ USER pyros_user
174 178 # TODO: pourquoi numpy ??? A virer ?
175 179 #RUN pip install --user numpy
176 180  
177   -
178   -
179 181 # Copy local host machine files to image
180 182 COPY --chown=pyros_user:pyros_user . .
181 183 # Copy some aliases
... ... @@ -186,9 +188,12 @@ RUN cp .bash_aliases ..
186 188 # Adding local/bin to path to avoid pip warning
187 189 ENV PATH "$PATH:/home/pyros_user/.local/bin"
188 190  
  191 +
189 192 # Installing click on the image to prevent error on the first execution of the installation script
190   -RUN python3.10 -m pip install --user click
191   -RUN python3.10 -m pip install --user setuptools==58
  193 +RUN python3 -m pip install --user click
  194 +
  195 +RUN python3 -m pip install --user setuptools==58
  196 +
192 197 # (EP 23/3/2022) Installing pip-tools for the management of all the requirements*.txt files (python dependencies packages)
193 198 # NB :
194 199 # - pip-tools generates a smarter and smaller requirements.txt file than the traditional "pip freeze"
... ... @@ -196,14 +201,14 @@ RUN python3.10 -m pip install --user setuptools==58
196 201 # - Unfortunatly, it is difficult to use with several requirements*.txt files as it is the case for this software : pyros + sphinx + guitastro...
197 202 # - So we cannot yet use it completely and still have to use the traditional "pip install -r" anyway ...
198 203 # - But we can at least use it to generate all the requirements*.txt files in a far better format
199   -RUN python3.10 -m pip install --user pip-tools
  204 +RUN python3 -m pip install --user pip-tools
200 205  
201   -RUN pip-compile ./vendor/guitastro/install/requirements.in
202 206 # Installing packages required for Guitastro
203   -RUN python3.10 -m pip install --user -r ./vendor/guitastro/install/requirements.txt
  207 +RUN pip-compile ./vendor/guitastro/install/requirements.in
  208 +RUN python3 -m pip install --user -r ./vendor/guitastro/install/requirements.txt
204 209 # Maybe unnecessary because same requirements as for pyros requirements_dev (?)
205 210 #RUN pip install --user -r ./vendor/guitastro/install/requirements_dev.txt
206 211  
207 212 # Installing packages required for PyROS
208   -RUN python3.10 -m pip install --user -r ./install/requirements.txt
209   -RUN python3.10 -m pip install --user -r ./install/requirements_dev.txt
  213 +RUN python3 -m pip install --user -r ./install/requirements.txt
  214 +RUN python3 -m pip install --user -r ./install/requirements_dev.txt
... ...
docker/PYROS_DOCKER_INSTALL
1 1 #!/usr/bin/env bash
2 2  
3 3 # if no container is running
4   -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ]
5   -then
  4 +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
6 5 echo "pyros-db or pyros weren't running, starting them..."
7 6 ./PYROS_DOCKER_START.bat
8 7 fi
9 8  
10 9 # while db container isn't ready to execute queries, wait 5 seconds
11   -if ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy'
12   -then
  10 +#if ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' ; then
  11 +#fi
  12 +while ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' ; do
13 13 echo "db service isn't ready yet, waiting until it's ready..."
14   -fi
15   -while ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy'
16   -do
17 14 sleep 5
18 15 heal_status=$(docker inspect pyros-db --format='{{.State.Health.Status}}')
19 16 echo "Current status : $heal_status"
20 17 done
21 18  
22   -# db container is ready to execture queries, we can start the installation
  19 +# db container is ready to execture queries
  20 +# We can now start the installation
23 21 docker-compose exec pyros python3 pyros.py install
24 22  
... ...
docker/PYROS_DOCKER_RUN_WEBSERVER_ONLY
1 1 #!/usr/bin/env bash
2 2  
3 3 #if no container is running
4   -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ]
5   -then
  4 +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
6 5 echo "pyros-db or pyros weren't running, starting them..."
7 6 ./PYROS_DOCKER_START.bat
8 7 fi
9   -docker-compose exec pyros python3 pyros.py -d start webserver $@
  8 +
  9 +docker compose exec pyros python3 pyros.py -d start webserver $@
  10 +#docker-compose exec pyros python3 pyros.py -d start webserver $@
  11 +#docker compose exec pyros python3 pyros.py -d start -o tnc -fg webserver $@
10 12 #docker exec -it pyros python3 pyros.py start webserver $@
11 13 #docker exec -it pyros python3 pyros.py -d start -o tnc webserver $@
... ...
docker/docker-compose.yml
1 1 version: "3.9"
2 2  
3 3 services:
  4 +
  5 + #######################
  6 + # MYSQL - DBMS
  7 + #######################
4 8 db:
5 9 # if we're using mysql >= 8, some of sql queries aren't valid anymore, like for creating and grant an user at the same time
6 10 # This is fixed in pyros.py
  11 + container_name: pyros-db
7 12 image: mysql:8.0.28
8   - command: --default-authentication-plugin=mysql_native_password
9 13 restart: always
  14 + command: --default-authentication-plugin=mysql_native_password
  15 + environment:
  16 + # note : as db is an image of mysql, this root password will be set on the first installation on the image, if the value is changed, it will not be updated in the database
  17 + - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}"
  18 + - VNC_NO_PASSWORD=1
  19 + volumes:
  20 + - db:/var/lib/mysql/
10 21 deploy:
11 22 restart_policy:
12 23 condition: on-failure
... ... @@ -15,29 +26,26 @@ services:
15 26 limits:
16 27 cpus: '0.5'
17 28 memory: 1GB
18   - #pids: 1
19   - container_name: pyros-db
20   - environment:
21   - # note : as db is an image of mysql, this root password will be set on the first installation on the image, if the value is changed, it will not be updated in the database
22   - - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}"
23   - - VNC_NO_PASSWORD=1
24   - volumes:
25   - - db:/var/lib/mysql/
  29 + #pids: 1
26 30 # create network to allow images to communicate with other images within the same network
27 31 # networks:
28 32 # pyros-network:
29 33 # ipv4_address: 172.19.0.2
30   -
31 34 healthcheck:
32 35 test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ]
33 36 timeout: 10s
34 37 interval: 5s
35 38 retries: 20
36 39  
  40 + ######################################################
  41 + # REDIS - in memory communication bus (for websockets)
  42 + ######################################################
37 43 redis:
38 44 container_name: pyros-redis
39 45 image: redis:latest
40 46 restart: always
  47 + ports:
  48 + - "6379:6379"
41 49 deploy:
42 50 restart_policy:
43 51 condition: on-failure
... ... @@ -46,9 +54,7 @@ services:
46 54 limits:
47 55 cpus: '1'
48 56 memory: 1GB
49   - #pids: 1
50   - ports:
51   - - "6379:6379"
  57 + #pids: 1
52 58 healthcheck:
53 59 test: ["CMD", "redis-cli","ping"]
54 60 timeout: 10s
... ... @@ -58,22 +64,19 @@ services:
58 64 # pyros-network:
59 65 # ipv4_address: 172.19.0.5
60 66  
61   - # Service image of python, that lets users interact with python scripts such as pyros.
  67 + ######################################################
  68 + # PYROS (main image : docker_pyros) => defined in Dockerfile
  69 + # Ubuntu OS with Python3 and PyROS requirements installed
  70 + # PyROS will later be installed on this image with "pyros.py install" (PYROS_DOCKER_INSTALL)
  71 + ######################################################
62 72 pyros:
  73 + container_name: pyros
  74 + restart: always
63 75 #read_only: true
64 76 # app/pyros is equivalent to your PYROS_SOFT/PYROS/ directory
65 77 # Change "pyros" to whatever you want for the PYROS/ dir name (if you do not want "PYROS")
66 78 working_dir:
67 79 /home/pyros_user/app/pyros
68   - deploy:
69   - restart_policy:
70   - condition: on-failure
71   - max_attempts: 5
72   - resources:
73   - limits:
74   - cpus: '1'
75   - memory: 8GB
76   - #pids: 1
77 80 # path to the Dockerfile of this image
78 81 environment:
79 82 # environment variables only for Docker
... ... @@ -93,7 +96,6 @@ services:
93 96 uid: ${CURRENT_UID}
94 97 context: ..
95 98 #filename: Dockerfile
96   - container_name: pyros
97 99 hostname: ${COMPUTER_HOSTNAME}
98 100 # tty is the -t option in docker exec
99 101 tty: true
... ... @@ -112,28 +114,47 @@ services:
112 114 links:
113 115 - db
114 116 - redis
  117 + deploy:
  118 + restart_policy:
  119 + condition: on-failure
  120 + max_attempts: 5
  121 + resources:
  122 + limits:
  123 + cpus: '1'
  124 + memory: 8GB
  125 + #pids: 1
115 126 # create network to allow images to communicate with other images within the same network
116 127 # networks:
117 128 # pyros-network:
118 129 # ipv4_address: 172.19.0.3
119 130 #ipv4_address: "${IP_PYROS_USER}"
120   - restart: always
121 131 healthcheck:
122 132 test: ["CMD", "python3","-V"]
123 133 timeout: 10s
124 134 interval: 5s
125 135 retries: 20
126 136  
127   -
  137 + ######################################################
  138 + # PHPMYADMIN (to interact manually with mysql db)
  139 + # (dev only)
  140 + ######################################################
128 141 phpmyadmin:
129   - image: phpmyadmin/phpmyadmin
130 142 container_name: pyros-pma
  143 + image: phpmyadmin/phpmyadmin
  144 + restart: always
131 145 links:
132 146 - db
133 147 environment:
134 148 PMA_HOST: db
135 149 PMA_PORT: 3306
136 150 PMA_ARBITRARY: 1
  151 + env_file:
  152 + - .env
  153 + # networks:
  154 + # pyros-network:
  155 + # ipv4_address: 172.19.0.4
  156 + ports:
  157 + - "${PHPMYADMIN_PORT:-8081}:80"
137 158 deploy:
138 159 restart_policy:
139 160 condition: on-failure
... ... @@ -143,15 +164,6 @@ services:
143 164 cpus: '1'
144 165 memory: 1GB
145 166 #pids: 1
146   -
147   - env_file:
148   - - .env
149   - restart: always
150   - # networks:
151   - # pyros-network:
152   - # ipv4_address: 172.19.0.4
153   - ports:
154   - - "${PHPMYADMIN_PORT:-8081}:80"
155 167 healthcheck:
156 168 test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ]
157 169 timeout: 10s
... ... @@ -159,12 +171,16 @@ services:
159 171 retries: 20
160 172  
161 173  
162   -
163   -# declaring volumes
  174 +######################################################
  175 +# Declaring volumes
  176 +######################################################
164 177 volumes:
165 178 db:
166 179 driver: local
167   -# declaring networks
  180 +
  181 +######################################################
  182 +# Declaring networks
  183 +######################################################
168 184 # networks:
169 185 # pyros-network:
170 186 # #bridge is the default network driver
... ...
src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu deleted
... ... @@ -1,220 +0,0 @@
1   -
2   -@startuml
3   -
4   -!include <tupadr3/common>
5   -!include <tupadr3/font-awesome/server>
6   -
7   -
8   -
9   -/'
10   -UML class Diagram : can be displayed with PlantUML (plugin for Eclipse or for PyCharm)
11   -
12   -PlantUML:
13   -- How to install : https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#PlantUML
14   -- Eclipse plugin : http://plantuml.com/eclipse
15   -- class diagrams : http://plantuml.com/class-diagram
16   -- sequence diagrams : http://plantuml.com/sequence-diagram
17   -- state diagrams : http://plantuml.com/state-diagram
18   -- Use Case diagrams : http://plantuml.com/use-case-diagram
19   -- OLD Activity diagrams : http://plantuml.com/activity-diagram-legacy
20   -- NEW Activity diagrams : http://plantuml.com/activity-diagram-beta
21   -- Pre-processing (include...) : http://plantuml.com/preprocessing
22   -- GANTT diagrams : http://plantuml.com/gantt-diagram
23   -- REAL WORLD EXAMPLES !!! : https://real-world-plantuml.com/
24   -- For Python:
25   - - https://github.com/SamuelMarks/python-plantuml
26   - - https://pythonhosted.org/plantuml/
27   -
28   -UML diagrams theory : https://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/index.html
29   -'/
30   -
31   -title
32   -__**PyROS class diagram (AgentMajordome example)**__
33   -'<size:10><i>Version 16-10-2019</i></size>'
34   -
35   -end title
36   -
37   -
38   -
39   -/' Allow to mix object/class diagram with other symbols like a "server" symbol '/
40   -allowmixing
41   -
42   -FA_SERVER(sbig_device,SBIG detector) #Red
43   -FA_SERVER(gemini_device,Gemini telescope) #Red
44   -
45   -
46   -
47   -/' ======= AgentMajordome & AgentDevices ======= '/
48   -
49   -class AgentMajordome <<Singleton>> #yellow
50   -AgentMajordome -u-|> Agent
51   -AgentDevice -u-|> Agent
52   -
53   -/' Aliases to AgentDevices '/
54   -object AD_Telescope1
55   -object AD_FilterSelector1
56   -object AD_Shutter1
57   -object AD_Sensor1
58   -object AD_Shutter2
59   -
60   -/' Use l,r,u,d for left, right, up, or down row alignement '/
61   -AgentMajordome -d-> AD_Telescope1 : sends cmd to
62   -AgentMajordome -d-> AD_FilterSelector1 : sends cmd to
63   -AgentMajordome -d-> AD_Shutter1 : sends cmd to
64   -AgentMajordome -d-> AD_Sensor1 : sends cmd to
65   -AgentMajordome -d-> AD_Shutter2 : sends cmd to
66   -
67   -
68   -class DeviceController {
69   - ip, port
70   - channel: ClientChannel
71   - protocol: Protocol # abstract
72   - gen2nat_cmds: Gen2NatCmds # abstract
73   -}
74   -
75   -class DC_Mount {
76   - gen2nat_cmds: Gen2NatCmds # abstract
77   -}
78   -class DC_DetectorShutter {
79   - gen2nat_cmds: Gen2NatCmds # abstract
80   -}
81   -class DC_DetectorSensor {
82   - gen2nat_cmds: Gen2NatCmds # abstract
83   -}
84   -class DC_FilterSelector {
85   - gen2nat_cmds: Gen2NatCmds # abstract
86   -}
87   -
88   -
89   -
90   -
91   -/' ======= CHANNELS ======= '/
92   -
93   -DeviceController "1" o-r- "0..1" DeviceSimulator
94   -
95   -DeviceController o-d- ClientChannel
96   -class ClientChannelSerial #lightred
97   -class ClientChannelSocket #lightred
98   -class ClientChannelUSB #lightred
99   -ClientChannel <|-- ClientChannelSerial
100   -ClientChannel <|-- ClientChannelSocket
101   -ClientChannel <|-- ClientChannelUSB
102   -
103   -
104   -/' ======= GEMINI controllers (& sim) ======= '/
105   -
106   -class AgentDeviceGemini #lightblue
107   -AgentDeviceGemini -u--|> AgentDevice
108   -
109   -/' Components (only 1) '/
110   -AD_Telescope1 -d-> AgentDeviceGemini :alias of
111   -
112   -/'DC_Mount o-left- DS_Mount'/
113   -
114   -/'AgentDeviceGemini ---> DC_Gemini :use'/
115   -AgentDeviceGemini "1" o--- "1" DC_Gemini :use
116   -
117   -/' Controllers '/
118   -class DC_Gemini {
119   - (client)
120   - protocol: Protocol # gemini
121   - gen2nat_cmds: Gen2NatCmds # gemini
122   -}
123   -class DC_Gemini <<Singleton>> #lightblue
124   -DC_Gemini <.l> gemini_device : channel/\nsocket
125   -DC_Gemini ---|> DeviceController
126   -DC_Gemini "*" o-- "1" DC_Mount
127   -DC_Mount --|> DeviceController
128   -
129   -/' Simulators '/
130   -class DS_Gemini {
131   - (server)
132   - protocol: Protocol # gemini
133   - gen2nat_cmds: Gen2NatCmds # gemini
134   -}
135   -class DS_Gemini #lightblue
136   -DS_Gemini ---|> DeviceSimulator
137   -DC_Gemini "1" o- "1" DS_Gemini
138   -
139   -
140   -
141   -/' ======= SBIG controllers (& sim) ======= '/
142   -
143   -class AgentDeviceSBIG <<Singleton>> #lightgreen
144   -AgentDeviceSBIG -u--|> AgentDevice
145   -
146   -/' Components (3) '/
147   -AD_FilterSelector1 --> AgentDeviceSBIG :alias of
148   -AD_Shutter1 --> AgentDeviceSBIG :alias of
149   -AD_Sensor1 --> AgentDeviceSBIG :alias of
150   -
151   -AgentDeviceSBIG "1" o-d-> "1" DC_SBIG :use
152   -DC_SBIG "1" o- "1" DS_SBIG
153   -
154   -/' Controllers '/
155   -
156   -class DC_SBIG {
157   - (client)
158   - protocol: Protocol # sbig
159   - gen2nat_cmds: Gen2NatCmds # sbig
160   -}
161   -class DC_SBIG <<Singleton>> #lightgreen
162   -
163   -DC_SBIG <.r> sbig_device : channel/\nsocket
164   -DC_SBIG ---|> DeviceController
165   -DC_SBIG "*" o-down- "0..1" DC_DetectorSensor
166   -DC_SBIG "*" o-down- "0..1" DC_DetectorShutter
167   -DC_SBIG "*" o-down- "0..1" DC_FilterSelector
168   -
169   -DC_DetectorSensor --|> DeviceController
170   -DC_DetectorShutter --|> DeviceController
171   -DC_FilterSelector --|> DeviceController
172   -
173   -/' Simulators '/
174   -class DS_SBIG {
175   - (server)
176   - protocol: Protocol # sbig
177   - gen2nat_cmds: Gen2NatCmds # sbig
178   -}
179   -class DS_SBIG #lightgreen
180   -DS_SBIG ---|> DeviceSimulator
181   -
182   -
183   -/' ======= NOTES ======= '/
184   -
185   -skinparam noteFontSize 9
186   -
187   -note left of DeviceController
188   -Device <b>client</b> (pyros <b>generic commands</b> only):
189   -- Defines (or receives) its own protocol
190   - and "generic to native" commands dictionary (gen2nat_cmds)
191   -- Translates an agent <b>generic</b> command to a native command,
192   - and sends it to device (or DS)
193   -- Receives device's native answer, translates it to <b>generic</b>
194   - and returns it back to agent
195   -(//every DC can include a **DS of the same name**//)
196   - end note
197   -
198   -note bottom of DeviceSimulator
199   -Device placeholder <b>server</b> (<b>native commands</b> only):
200   -- Receives <b>native</b> commands from client
201   -- Returns (simulated) <b>native</b> answer to client
202   -(uses protocol and gen2nat_cmds given by its associated DC)
203   -(//abstract DS receive only generic commands and return generic answers//)
204   - end note
205   -
206   -
207   -
208   -/' ======= LEGEND ======= '/
209   -
210   -skinparam legendFontSize 9
211   -
212   -legend left
213   -<i>Version 06-11-2019</i>
214   -AD = <b>Agent Device</b> ; DC = <b>Device Controller</b> ; DS = <b>Device Simulator</b>
215   -Colors: <b>(light) yellow</b> : abstract classes ; <b>red</b> : real devices ; <b>blue</b> : Gemini concrete classes ; <b>green</b> : SBIG concrete classes
216   -endlegend
217   -'(E. Pallier)
218   -
219   -
220   -@enduml