Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grid SEPTREFHUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
VIPS
Models
GRID
Grid SEPTREFHUM
Commits
f3c0a9f7
Commit
f3c0a9f7
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Handle deps with Miniconda
parent
a6c394b9
Branches
Branches containing commit
No related tags found
1 merge request
!1
Cdo 2.4 miniconda
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
conda_environment.yml
+9
-0
9 additions, 0 deletions
conda_environment.yml
run_SEPTREFHUM.sh
+36
-20
36 additions, 20 deletions
run_SEPTREFHUM.sh
with
46 additions
and
20 deletions
.gitignore
+
1
−
0
View file @
f3c0a9f7
...
...
@@ -4,3 +4,4 @@
.env
.venv
mapfile/*.map
last_run_timestamp
This diff is collapsed.
Click to expand it.
conda_environment.yml
0 → 100644
+
9
−
0
View file @
f3c0a9f7
name
:
SEPTREFHUM
channels
:
-
conda-forge
dependencies
:
-
cdo=2.4.0
-
Jinja2
-
netCDF4
-
pytz
-
python-dotenv
\ No newline at end of file
This diff is collapsed.
Click to expand it.
run_SEPTREFHUM.sh
+
36
−
20
View file @
f3c0a9f7
...
...
@@ -18,42 +18,55 @@
# Configures environment and logging before running the model
# @author: Tor-Einar Skog <tor-einar.skog@nibio.no>
# Defines HOME_DIR
source
.env
# First: Test that we have CDO and GDAL installed
if
!
command
-v
cdo &> /dev/null
# Check for HOME_DIR
if
[
-z
"
${
HOME_DIR
}
"
]
then
echo
"ERROR:
CDO could not be found. Ex
itin
g.
"
echo
"ERROR:
\$
HOME_DIR is not set. Please declare
it
in
an .env file
"
exit
fi
# Paths to scripts and requirements
LOG_FILE
=
${
HOME_DIR
}
log/SEPTREFHUM.log
REQUIREMENTS
=
${
HOME_DIR
}
requirements.txt
CDO_VERSION
=
2.4.0
# Test that we have GDAL and Miniconda installed
if
!
command
-v
gdal_merge.py &> /dev/null
then
echo
"ERROR: GDAL is either not installed, or not built with Python support. Exiting."
exit
fi
# Defines HOME_DIR
source
.env
# Check for HOME_DIR
if
[
-z
"
${
HOME_DIR
}
"
]
if
!
command
-v
conda &> /dev/null
then
echo
"ERROR:
\$
HOME_DIR is not set
. Plea
s
e
declare it in an .env file
"
echo
"ERROR:
Miniconda is not installed
. Plea
r
e
read: https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda
"
exit
fi
# Paths to scripts and requirements
LOG_FILE
=
${
HOME_DIR
}
log/SEPTREFHUM.log
REQUIREMENTS
=
${
HOME_DIR
}
requirements.txt
cd
$HOME_DIR
# Create and activate the virtual environment
python3
-m
venv .venv
.
.venv/bin/activate
python3
-m
pip
install
-q
--upgrade
pip
pip
install
-q
-r
$REQUIREMENTS
# Check if we need to create the virtual environment
eval
"
$(
conda shell.bash hook
)
"
now
=
$(
date
+%s
)
if
!
conda
env
list |
grep
-q
"SEPTREFHUM "
;
then
echo
"Conda env not found, creating it"
conda
env
create
-f
conda_environment.yml
conda activate SEPTREFHUM
else
# Make sure we catch/update changes in dependencies
if
[
-e
last_run_timestamp
]
;
then
last_run_timestamp
=
$(
<last_run_timestamp
)
last_modified_env_file
=
$(
stat
-c
"%Y"
conda_environment.yml
)
if
[
$((
last_run_timestamp
-
last_modified_env_file
))
-lt
0
]
;
then
echo
"conda_environment.yml file has been updated. Updating the conda env. This may take a while"
conda
env
update
--prune
-f
conda_environment.yml
fi
fi
conda activate SEPTREFHUM
fi
# Run the model
echo
"====
`
date
`
: Running model"
&>>
"
$LOG_FILE
"
...
...
@@ -61,4 +74,7 @@ python3 ${HOME_DIR}SEPTREFHUM.py &>> "$LOG_FILE"
echo
"====
`
date
`
: DONE running model"
&>>
"
$LOG_FILE
"
# Deactivate the virtual environment
deactivate
conda deactivate
# Log this to compare with changes in conda_environment.yml
echo
$now
>
last_run_timestamp
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