Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/build_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ run-name: ${{ github.actor }} is building doc
on:
- push
- workflow_dispatch
- pull_request

jobs:
Sole_job_yet:
name: Build doc
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
defaults:
run:
shell: bash -el {0}
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
- name: Setup Miniforge3
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: climaf_test
use-mamba: true

- name: Cache Conda env
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key:
Expand All @@ -43,7 +44,7 @@ jobs:
- run: (cd doc && make -k html)

- name: Archive doc
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: doc
retention-days: 5
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ run-name: Test suite launched by ${{ github.actor }}
on:
- push
- workflow_dispatch
- pull_request

jobs:
Sole_job_yet:
name: Testing with ubuntu 20.04, conda and python 3.11
runs-on: ubuntu-20.04
name: Testing with ubuntu 24.04, conda and python 3.11
runs-on: ubuntu-24.04
strategy:
matrix:
#python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
Expand All @@ -17,18 +18,30 @@ jobs:
shell: bash -el {0}
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
- name: Setup Miniforge3
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: climaf_test
use-mamba: true

- name: Mettre à jour les paquets
run: sudo apt-get update

- name: Installer ImageMagick et pdftk
run: |
sudo apt-get install -y imagemagick pdftk

- name: Vérifier les installations
run: |
convert -version
pdftk --version

- name: Cache Conda env
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key:
Expand Down Expand Up @@ -57,7 +70,7 @@ jobs:
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "driver" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "dataloc" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "find_files" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "html" 0)
#- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "html" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "example_data_retrieval" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "example_index_html" 0)
- run: (cd tests && ./launch_tests_with_coverage.sh 1 3 "mcdo" 0)
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ examples/romain/
/lmdz/
/doc/_static/
/testing/last.out
NOTES
NOTES
/tests/a.pdf
last.out
/examples/climaf_tmp_*
2 changes: 1 addition & 1 deletion climaf/ESMValTool_diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def call_evt_script(climaf_name, script, ensembles, *operands, **parameters):
'write_netcdf': True,
'write_plots': True,
'quick_plot': {},
}
}

# Account for dynamical, un-controlled, script call parameters to update settings
settings.update(parameters)
Expand Down
252 changes: 131 additions & 121 deletions climaf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,121 +1,131 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Climaf is documented at ReadTheDocs : http://climaf.readthedocs.org/

"""
from __future__ import print_function, division, unicode_literals, absolute_import

import time
import os

# Created : S.Sénési - 2014

__all__ = ["cache", "classes", "dataloc", "driver", "netcdfbasics",
"operators", "period", "standard_operators", "cmacro", "chtml", "functions", "plot",
"projects", "derived_variables", "ESMValTool_diags"]


def tim(string=None):
"""
Utility function : print duration since last call
Init it by a call without arg
"""
if not string or not getattr(tim, 'last'):
tim.last = time.time()
else:
delta = time.time() - tim.last
tim.last = time.time()
# if ("dotiming" in vars() and dotiming) :
print_delta = False
if print_delta:
print("Duration %.1f for step %s" % (delta, string), file=sys.stderr)


already_inited = False
onrtd = os.environ.get('READTHEDOCS', None) in ['True', ]

if not already_inited and not onrtd:
import sys

#
already_inited = True
#
tim()
import atexit

tim("atexit")
#
from env.environment import *
print("CliMAF climaf_version = " + climaf_version, file=sys.stderr)
print("CliMAF install => " + "/".join(__file__.split("/")[:-2]), file=sys.stderr)

tim("softwares")
#
import env.clogging as clogging
import env.site_settings as site_settings
from . import cache
from . import standard_operators
from . import cmacro
from . import operators

tim("imports")
#
# Set default logging levels
clogging.logdir = logdir
clogging.clog(loglevel)
clogging.clog_file(logfilelevel)
tim("loggings")
#
# Decide for cache location
cachedir = default_cache # TODO: For compatibility, delete ones useless
cache.setNewUniqueCache(default_cache, raz=False)
print("Cache directory set to : " + default_cache + " (use $CLIMAF_CACHE if set) ", file=sys.stderr)
tim("set cache")
# Decide for cache location for remote data
print("Cache directory for remote data set to : " + default_remote_cache + " (use $CLIMAF_REMOTE_CACHE if set) ",
file=sys.stderr)
#
# Init dynamic CliMAF operators, and import projects and some funcs in main
tim("execs_projects")
exec("from climaf.classes import ds, eds, cens, fds", sys.modules['__main__'].__dict__)
tim("execs_classes")
exec("from climaf.operators import cscript", sys.modules['__main__'].__dict__)
tim("execs_cscript")
standard_operators.load_standard_operators()
tim("load_ops")
from . import projects
exec("from climaf.projects import %s" % ",".join(projects.__all__), sys.modules['__main__'].__dict__)
#
# Read and execute user config file
conf_file = os.path.expanduser("~/.climaf")
if os.path.isfile(conf_file):
exec(compile(open(conf_file).read(), conf_file, "exec"), sys.modules['__main__'].__dict__)
tim(".climaf")
#
# Load cache scalar values
cache.load_cvalues()
tim("load_cvalues")
#
# Init and load macros
macroFilename = os.environ.get("CLIMAF_MACROS", "~/.climaf.macros")
cmacro.read(macroFilename)
print("Available macros read from %s are : %s" % (macroFilename, repr(list(cmacros))),
file=sys.stderr)
tim("macros")
#
# Load cache index
cache.cload()
tim("cload")
#
atexit.register(cache.csync)
atexit.register(cache.sync_cvalues)
atexit.register(cmacro.write, macroFilename)
tim("atexit")
if cache.stamping:
# Check if exiv2 is installed
#
# graphic_formats = environment.get_variable("climaf_graphic_formats")
if (os.system("type exiv2 >/dev/null 2>&1") != 0) and 'eps' in graphic_formats:
graphic_formats.remove('eps')
print("exiv2 is not installed so you can not use 'eps' output format")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Climaf is documented at ReadTheDocs : http://climaf.readthedocs.org/

"""
from __future__ import print_function, division, unicode_literals, absolute_import

import time
import os

# Created : S.Sénési - 2014

__all__ = ["cache", "classes", "dataloc", "driver", "netcdfbasics",
"operators", "period", "standard_operators", "plot_operators",
"cmacro", "chtml", "functions", "plot",
"projects", "derived_variables", "ESMValTool_diags"]


def tim(string=None):
"""
Utility function : print duration since last call
Init it by a call without arg
"""
if not string or not getattr(tim, 'last'):
tim.last = time.time()
else:
delta = time.time() - tim.last
tim.last = time.time()
# if ("dotiming" in vars() and dotiming) :
print_delta = False
if print_delta:
print("Duration %.1f for step %s" %
(delta, string), file=sys.stderr)


already_inited = False
onrtd = os.environ.get('READTHEDOCS', None) in ['True', ]

if not already_inited and not onrtd:
import sys

#
already_inited = True
#
tim()
import atexit

tim("atexit")
#
from env.environment import *
print("CliMAF climaf_version = " + climaf_version, file=sys.stderr)
print("CliMAF install => " +
"/".join(__file__.split("/")[:-2]), file=sys.stderr)

tim("softwares")
#
import env.clogging as clogging
import env.site_settings as site_settings
from . import cache
from . import standard_operators
from . import plot_operators
from . import cmacro
from . import operators

tim("imports")
#
# Set default logging levels
clogging.logdir = logdir
clogging.clog(loglevel)
clogging.clog_file(logfilelevel)
tim("loggings")
#
# Decide for cache location
cachedir = default_cache # TODO: For compatibility, delete ones useless
cache.setNewUniqueCache(default_cache, raz=False)
print("Cache directory set to : " + default_cache +
" (use $CLIMAF_CACHE if set) ", file=sys.stderr)
tim("set cache")
# Decide for cache location for remote data
print("Cache directory for remote data set to : " + default_remote_cache + " (use $CLIMAF_REMOTE_CACHE if set) ",
file=sys.stderr)
#
# Init dynamic CliMAF operators, and import projects and some funcs in main
tim("execs_projects")
exec("from climaf.classes import ds, eds, cens, fds",
sys.modules['__main__'].__dict__)
tim("execs_classes")
exec("from climaf.operators import cscript",
sys.modules['__main__'].__dict__)
tim("execs_cscript")
standard_operators.load_standard_operators()
plot_operators.load_plot_operators()
tim("load_ops")
from . import projects
exec("from climaf.projects import %s" %
",".join(projects.__all__), sys.modules['__main__'].__dict__)
#
# Read and execute user config file
conf_file = os.path.expanduser("~/.climaf")
if os.path.isfile(conf_file):
exec(compile(open(conf_file).read(), conf_file, "exec"),
sys.modules['__main__'].__dict__)
tim(".climaf")
#
# Load cache scalar values
cache.load_cvalues()
tim("load_cvalues")
#
# Init and load macros
macroFilename = os.environ.get("CLIMAF_MACROS", "~/.climaf.macros")
cmacro.read(macroFilename)
print("Available macros read from %s are : %s" % (macroFilename, repr(list(cmacros))),
file=sys.stderr)
tim("macros")
#
# Load cache index
cache.cload()
tim("cload")
#
atexit.register(cache.csync)
atexit.register(cache.sync_cvalues)
atexit.register(cmacro.write, macroFilename)
tim("atexit")
if cache.stamping:
# Check if exiv2 is installed
#
# graphic_formats = environment.get_variable("climaf_graphic_formats")
if (os.system("type exiv2 >/dev/null 2>&1") != 0) and 'eps' in graphic_formats:
graphic_formats.remove('eps')
print("exiv2 is not installed so you can not use 'eps' output format")
Loading
Loading