Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
ch1187
plugins4freva
PET
Commits
38d07a36
Commit
38d07a36
authored
3 months ago
by
Mostafa Hadizadeh
Browse files
Options
Downloads
Patches
Plain Diff
added function to produce html and zip file in result
parent
c0d3b43e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!4
Add HTML and ZIP file to make the result section better
,
!2
Plugin template
Pipeline
#92741
passed
3 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pet-wrapper-api.py
+124
-0
124 additions, 0 deletions
pet-wrapper-api.py
src/pet/calculate_pet.sh
+1
-1
1 addition, 1 deletion
src/pet/calculate_pet.sh
with
125 additions
and
1 deletion
pet-wrapper-api.py
+
124
−
0
View file @
38d07a36
...
...
@@ -14,6 +14,7 @@ PET plugin API wrapper.
import
os
import
json
from
pathlib
import
Path
import
subprocess
# from evaluation_system.api.exceptions import PluginError
from
typing
import
List
,
Optional
...
...
@@ -192,6 +193,128 @@ class PET(plugin.PluginAbstract):
return
file_dict
def
prepare_html_output
(
self
,
path_output
):
result
=
subprocess
.
run
(
[
"
ls
"
,
"
-la
"
,
path_output
],
capture_output
=
True
,
text
=
True
)
ls_output
=
result
.
stdout
current_user
=
User
()
html_content
=
f
"""
<!DOCTYPE html>
<html>
<head>
<meta charset=
"
UTF-8
"
>
<meta name=
"
viewport
"
content=
"
width=device-width, initial-scale=1.0
"
>
<style>
body {{
font-family: -apple-system, BlinkMacSystemFont,
"
Segoe UI
"
, Roboto, sans-serif;
margin: 0;
padding: 20px;
line-height: 1.6;
background-color: #1a1a1a;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}}
.info-text {{
font-size: 16px;
max-width: 800px;
margin: 0 auto 20px auto;
background-color: white;
padding: 20px;
border-radius: 8px;
width: 100%;
box-sizing: border-box;
}}
.terminal {{
background-color: #2d2d2d;
border-radius: 8px;
box-shadow: 0 10px 20px rgba(0,0,0,0.3);
width: 100%;
max-width: 800px;
overflow: hidden;
}}
.terminal-header {{
background-color: #3d3d3d;
padding: 10px;
display: flex;
align-items: center;
}}
.terminal-buttons {{
display: flex;
gap: 8px;
}}
.terminal-button {{
width: 12px;
height: 12px;
border-radius: 50%;
}}
.terminal-button.close {{background-color: #ff5f56;}}
.terminal-button.minimize {{background-color: #ffbd2e;}}
.terminal-button.maximize {{background-color: #27c93f;}}
.terminal-title {{
color: #ababab;
font-size: 14px;
margin-left: 20px;
}}
.terminal-body {{
padding: 20px;
font-family:
"
Menlo
"
,
"
Monaco
"
,
"
Consolas
"
, monospace;
font-size: 14px;
line-height: 1.5;
color: #fff;
overflow-x: auto;
}}
.prompt {{
color: #98c379;
margin-bottom: 10px;
}}
.command {{
color: #61afef;
margin-left: 8px;
}}
.output {{
color: #abb2bf;
white-space: pre;
margin: 10px 0 20px 0;
}}
</style>
</head>
<body>
<div class=
"
info-text
"
>
You can directly download the produced data from the link above or login to levante and and proceed with the exploration of the data.
</div>
<div class=
"
terminal
"
>
<div class=
"
terminal-header
"
>
<div class=
"
terminal-buttons
"
>
<div class=
"
terminal-button close
"
></div>
<div class=
"
terminal-button minimize
"
></div>
<div class=
"
terminal-button maximize
"
></div>
</div>
<span class=
"
terminal-title
"
>Terminal</span>
</div>
<div class=
"
terminal-body
"
>
<div class=
"
prompt
"
>
local:~$ <span class=
"
command
"
>ssh
{
current_user
.
getName
()
}
@levante.dkrz.de</span>
</div>
<div class=
"
prompt
"
>
{
current_user
.
getName
()
}
@levante.dkrz.de:~$ <span class=
"
command
"
>cd
{
path_output
}
</span>
</div>
<div class=
"
prompt
"
>
{
current_user
.
getName
()
}
@levante.dkrz.de:
{
path_output
}
$ <span class=
"
command
"
>ls -la
{
path_output
}
</span>
</div>
<div class=
"
output
"
>
{
ls_output
}
</div>
</div>
</div>
</body>
</html>
"""
html_output_path
=
os
.
path
.
join
(
path_output
,
"
02_view.html
"
)
with
open
(
html_output_path
,
"
w
"
)
as
f
:
f
.
write
(
html_content
)
def
run_tool
(
self
,
config_dict
=
None
):
config_dict
[
"
files
"
]
=
self
.
find_files
(
config_dict
,
[
"
tasmax
"
,
"
tasmin
"
,
"
sfcWind
"
,
"
pvap
"
,
"
rsds
"
],
"
day
"
,
config_dict
[
"
start_date
"
]
+
"
to
"
+
config_dict
[
"
end_date
"
])
...
...
@@ -223,5 +346,6 @@ class PET(plugin.PluginAbstract):
f
"
{
tool_path
}
{
json_file
}
"
,
stderr
=
error_f
,
)
self
.
prepare_html_output
(
config_dict
[
"
output_dir
"
])
return
self
.
prepare_output
(
config_dict
[
"
output_dir
"
])
This diff is collapsed.
Click to expand it.
src/pet/calculate_pet.sh
+
1
−
1
View file @
38d07a36
...
...
@@ -294,5 +294,5 @@ for ((YEAR=$START_YEAR;YEAR<END_YEAR+1;YEAR+=1)); do
}
done
wait
cd
${
OUTPUT_DIR_VAR
}
&& zip -r
${
OUTPUT_DIR_VAR
}
/01_produced_data.zip . && cd -
echo '*** Calculation done ***'
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