diff --git a/.gitignore b/.gitignore index 1633c94..231d5ed 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,3 @@ coverage *.njsproj *.sln *.sw? - -api/constants.py diff --git a/api/api.py b/api/api.py index 2c7532f..e26a33f 100644 --- a/api/api.py +++ b/api/api.py @@ -48,7 +48,7 @@ async def upload_file(request: Request, datafiles: List[UploadFile] = File(...), @app.post("/uploadFileJson") -async def upload_file(request: Request, datafiles: List[UploadFile] = File(...), docker: str = Form(...), username: str = Form(...), password: str = Form(...)): +async def upload_file(request: Request, datafiles: List[UploadFile] = File(...), docker: str = Form(...), username: str = Form(default=None), password: str = Form(default=None)): filelist = [] for datafile in datafiles: @@ -82,13 +82,11 @@ def run_simulation(request: Request, input=None, ftype=None, parentfolder="work" while os.path.exists(os.path.join(workdir, name_job)): name_job = generate_random_folder() - if ftype == "fileJson": + if ftype == "fileJson" or ftype == "Json": name_configfile = "config.json" elif ftype == "fileBin": name_configfile = "config.bin" - elif ftype == "Json": - name_configfile = "config.json" - + if container: simulate_docker(parentfolder, name_configfile, name_job, ftype, datafile) else: @@ -100,21 +98,20 @@ def run_simulation(request: Request, input=None, ftype=None, parentfolder="work" startscript += "bsub -q 'BatchXL' -J '" + name_job + "' batchscript.csh\n" startscript += "cd ..\n" - client = paramiko.SSHClient() - client.load_system_host_keys() - client.connect(FTP_SERVER, 22, "alubojanski", "%.30fpgM") #username, passwd) + client = paramiko.SSHClient() + client.load_system_host_keys() + client.connect(FTP_SERVER, 22, username, passwd) - folderlist.append(name_job) + with client.open_sftp() as sftp: + sftp.chdir("work") - if not container: - with client.open_sftp() as sftp: - sftp.chdir("work") + with sftp.open("startskript.csh", "at") as sftp_file: + sftp_file.write(startscript) + sftp_file.close() + sftp.chmod("startskript.csh", stat.S_IRWXU) + sftp.close() - with sftp.open("startskript.csh", "at") as sftp_file: - sftp_file.write(startscript) - sftp_file.close() - sftp.chmod("startskript.csh", stat.S_IRWXU) - sftp.close() + folderlist.append(name_job) if not external: return templates.TemplateResponse("submitted.html", {"request": request, "container_list": folderlist}) diff --git a/api/constants.py b/api/constants.py new file mode 100644 index 0000000..698613a --- /dev/null +++ b/api/constants.py @@ -0,0 +1,4 @@ +IMAGE_TAG = "inretensys:0.3-gurobi" +CONTAINER_NAME = "inret-ensys-testcontainer" + +FTP_SERVER = "csdata.tu-ilmenau.de" diff --git a/api/templates/base.html b/api/templates/base.html index c127e8a..5e5355b 100644 --- a/api/templates/base.html +++ b/api/templates/base.html @@ -13,6 +13,14 @@ + +
@@ -25,55 +33,61 @@
+

-

-
+
-
-
-
Logindaten Universitätsrechenzentrum
-
- - -
-
- - -
-
+
Daten des Energiesystems

-
Ausführungsmethode
-
- - -
-
- - +
+
Ausführungsmethode
+
+ + +
+
+ + +

+

- +
-
+