Monog DB test
This commit is contained in:
parent
28189bfeef
commit
e8f9c38340
8
IUM_07/Dockerfile
Normal file
8
IUM_07/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
RUN apt update && apt install -y \
|
||||
python3-pip \
|
||||
python3
|
||||
|
||||
RUN python3 -m pip install sacred pymongo
|
||||
|
13
IUM_07/Jenkinsfile
vendored
Normal file
13
IUM_07/Jenkinsfile
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
node {
|
||||
checkout scm
|
||||
//Pierwszy argument to tag, który zostania nadany zbudowanemu obrazowi
|
||||
//Jeśli chcemy użyć Dockerfile z innej ścieżki niż ./Dockerfile, możemy ją podać jako drugi argument
|
||||
def testImage = docker.build("sacred_pymongo", "./IUM_07/Dockerfile")
|
||||
|
||||
//Wszystkie polecenia poniżej wykonają się w kontenerze, z podmontowanym Workspace Jenkinsa
|
||||
testImage.inside {
|
||||
dir ("IUM_07"){
|
||||
sh 'python3 mongo_observer.py'
|
||||
}
|
||||
}
|
||||
}
|
37
IUM_07/mongo_observer.py
Normal file
37
IUM_07/mongo_observer.py
Normal file
@ -0,0 +1,37 @@
|
||||
from sacred.observers import MongoObserver
|
||||
from sacred import Experiment
|
||||
import random
|
||||
import time
|
||||
|
||||
ex = Experiment("sacred_scopes", interactive=True)
|
||||
ex.observers.append(MongoObserver(url='mongodb://mongo_user:mongo_password@localhost:27017',
|
||||
db_name='sacred')) # Tutaj podajemy dane uwierzytelniające i nazwę bazy skonfigurowane w pliku .env podczas uruchamiania bazy.
|
||||
# W przypadku instancji na Jenkinsie url będzie wyglądał następująco: mongodb://mongo_user:mongo_password_IUM_2021@localhost:27017
|
||||
@ex.config
|
||||
def my_config():
|
||||
recipient = "Świecie"
|
||||
greeting = "Witaj"
|
||||
|
||||
@ex.capture
|
||||
def prepare_message(recipient, greeting):
|
||||
return "{0} {1}!".format(greeting, recipient)
|
||||
|
||||
@ex.main
|
||||
def my_main(recipient, greeting, _run):
|
||||
print(prepare_message()) ## Nie musimy przekazywać wartości
|
||||
counter = 0
|
||||
while counter < 20:
|
||||
counter+=1
|
||||
value = counter
|
||||
ms_to_wait = random.randint(5, 5000)
|
||||
time.sleep(ms_to_wait/1000)
|
||||
noise = 1.0 + 0.1 * (random.randint(0, 10) - 5)
|
||||
# This will add an entry for training.loss metric in every second iteration.
|
||||
# The resulting sequence of steps for training.loss will be 0, 2, 4, ...
|
||||
if counter % 2 == 0:
|
||||
_run.log_scalar("training.loss", value * 1.5 * noise, counter)
|
||||
# Implicit step counter (0, 1, 2, 3, ...)
|
||||
# incremented with each call for training.accuracy:
|
||||
_run.log_scalar("training.accuracy", value * 2 * noise)
|
||||
|
||||
ex.run()
|
Loading…
Reference in New Issue
Block a user