Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Futures #153

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ conda env config vars set EVALUATION_SYSTEM_CONFIG_FILE=$PWD/compose/local-eval-
conda env config vars set EVALUATION_SYSTEM_CONFIG_DIR=$PWD/compose 1>/dev/null
conda env config vars set EVALUATION_SYSTEM_DRS_CONFIG_FILE=$PWD/compose/drs_config.toml 1>/dev/null
conda env config vars set EVALUATION_SYSTEM_PLUGINS=$PWD/src/evaluation_system/tests/mocks,dummy:$PWD/src/evaluation_system/tests/mocks,dummyfolder 1>/dev/null
conda env config vars set FREVA_FUTURE_DIR=$PWD/assets/futures
conda deactivate
conda activate freva-dev
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
graft ./assets/*
include ./assets/futures/*
include ./assets/drs_config.toml
include ./assets/evaluation_system.conf
include ./deploy.py
include src/freva/*.json
13 changes: 13 additions & 0 deletions assets/drs_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ drs_format = "cmip5"
project = "reanalysis"
product = "reanalysis"

[futures]
root_dir = "/usr/freva_output/data"
parts_dir = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add some user-data via

freva user-data add --institute "Andrej" --model "AndrejMod" --experiment AndrejExp --project foo paths /home/afast/Downloads/nc

It broke with:

freva - ERROR - Not all information could be retrieved. Please add the following key manually: 'hash'  

But I was not able to set the hash as it is missing in the parameters. Is it even desired that the user has to set the hash manually?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually put hash into the code in order to bypass this error message and to add my local data into the solr. This didn't work as hash is not part of the solr. Should it?

"hash", "project", "product", "institute", "model", "experiment", "time_frequency",
"realm", "cmor_table", "ensemble", "version", "variable", "file_name",
]
parts_file_name = [
"hash", "variable", "cmor_table", "model", "experiment", "ensemble", "time",
]
parts_time = "start_time-end_time"
drs_format = "futures"


[crawl_my_data]
root_dir = "/usr/freva_output/data"
parts_dir = [
Expand Down
148 changes: 148 additions & 0 deletions assets/futures/ClimdexCalc.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me a while: Those are the templates to create content from the futures, aren't they? Please put a separate README in there.

I tried multiple times to execute those notebook like an idiot..

"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "da58d5ea",
"metadata": {
"tags": [
"solr-parameters"
]
},
"outputs": [],
"source": [
"# Define the solr parameter\n",
"project=\"reanalysis\"\n",
"product=\"reanalysis\"\n",
"institute=\"ecmwf\"\n",
"model=\"ifs\"\n",
"experiment=\"era5\" \n",
"ensemble=\"reanalysis\"\n",
"time=\"200001010000-201012310000\"\n",
"time_frequency=\"mon\"\n",
"realm=\"atmos\"\n",
"variable=[\"tx10p\", \"tx90p\", \"tn10p\", \"tn90p\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad6886ba",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"ntasks=8\n",
"future_code = \"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0e174599",
"metadata": {},
"outputs": [],
"source": [
"from tempfile import TemporaryDirectory\n",
"import freva\n",
"_=freva.config(\"/home/wilfred/workspace/freva/compose/local-eval-system.conf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dbbd8c5a",
"metadata": {},
"outputs": [],
"source": [
"outdir = TemporaryDirectory()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2da586e1",
"metadata": {
"tags": [
"code"
]
},
"outputs": [],
"source": [
"from dateutil import parser\n",
"time_period=\",\".join((str(parser.parse(t).year) for t in time.split(\"-\")))\n",
"res = freva.run_plugin(\n",
" \"climdexcalc\",\n",
" project=project,\n",
" product=product,\n",
" institute=institute,\n",
" model=model,\n",
" experiment=experiment,\n",
" ensemble=ensemble,\n",
" timeperiod=time_period,\n",
" indices=\",\".join(variable),\n",
" ntasks=ntasks,\n",
" outputdir=outdir.name,\n",
" batchmode=True,\n",
")\n",
"res.wait()\n",
"output = res.get_result_paths()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f256fd7",
"metadata": {},
"outputs": [],
"source": [
"freva.add_user_data(\n",
" product,\n",
" *output,\n",
" how=\"move\",\n",
" _project=project,\n",
" institute=institute,\n",
" model=model,\n",
" experiment=experiment,\n",
" ensemble=ensemble,\n",
" realm=realm,\n",
" future=future_code\n",
")\n",
"outdir.cleanup()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7daf2cac",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
104 changes: 104 additions & 0 deletions assets/futures/future_template.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0e005d16",
"metadata": {},
"outputs": [],
"source": [
"import freva\n",
"from freva._futures import Futures"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "da58d5ea",
"metadata": {
"tags": [
"solr-parameters"
]
},
"outputs": [],
"source": [
"# Define the solr parameter\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad6886ba",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"# Define additional parameters to run the plugin\n",
"future_id = \"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2da586e1",
"metadata": {
"tags": [
"code"
]
},
"outputs": [],
"source": [
"# Run the plugin\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f256fd7",
"metadata": {},
"outputs": [],
"source": [
"# res.wait()\n",
"output = res.get_result_paths()\n",
"Futures.from_existing_code_hash(future_id).add_data(\n",
" project,\n",
" product,\n",
" *output,\n",
" history_id=res.id,\n",
" institute=institute,\n",
" model=model,\n",
" experiment=experiment,\n",
" ensemble=ensemble,\n",
" realm=realm,\n",
" time_frequency=time_frequency,\n",
" cmor_table=cmor_table,\n",
")"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
15 changes: 14 additions & 1 deletion compose/drs_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ parts_file_name = ["variable", "time_frequency", "model", "experiment", "ensembl
parts_time = "start_time-end_time"
drs_format="custom"

[futures]
root_dir = "/tmp/freva_futures"
drs_format="futures"
parts_dir = [
"future_id", "project", "product", "institute", "model", "experiment", "time_frequency",
"realm", "cmor_table", "ensemble", "version", "variable"
]
parts_file_name = [
"variable", "cmor_table", "model", "experiment", "ensemble", "time",
]
parts_time = "start_time-end_time"


[crawl_my_data]
root_dir = "/tmp/user_data"
parts_dir = [
Expand All @@ -16,7 +29,7 @@ parts_dir = [
]
drs_format="custom"
parts_file_name = [
"variable", "cmor_table", "model", "experiment", "ensemble", "time",
"hash", "variable", "cmor_table", "model", "experiment", "ensemble", "time",
]
parts_time = "start_time-end_time"

Expand Down
6 changes: 3 additions & 3 deletions compose/local-eval-system.conf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extra_options=--qos=test, --array=20
#python_path=${evaluation_system:root_dir}/plugin4freva/movieplotter/src
#module=movieplotter
#
#[plugin:climdexcalc]
#python_path=/home/wilfred/workspace/climdex-calc
#module=climdex_calc
[plugin:climdexcalc]
python_path=/home/wilfred/workspace/climdex-calc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local path which I don't have. I changed the path to locally checked out climdexcalc-plugin but the module name also does not correspond to the one online (climdex_calc vs climdexcalc)

module=climdex_calc
#
13 changes: 12 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "3.9"
services:
db:
db1:
image: mariadb:latest
environment:
MYSQL_USER: freva
Expand All @@ -11,6 +11,17 @@ services:
- "3306:3306"
volumes:
- ./compose/config/mysql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql:ro
db2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add a second database? I don't see any usage

image: mariadb:latest
environment:
MYSQL_USER: freva
MYSQL_PASSWORD: T3st
MYSQL_DATABASE: freva
MYSQL_ROOT_PASSWORD: test_password_please_ignore
ports:
- "3308:3306"
volumes:
- ./compose/config/mysql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql:ro
solr:
image: solr:latest
environment:
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ignore_missing_imports = True
[mypy-lazy_import.*]
ignore_missing_imports = True

[mypy-nbparameterise.*]
ignore_missing_imports = True


[mypy-PIL.*]
Expand Down
Loading