-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add setup script and exemplary notebook
- Loading branch information
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "TypeError", | ||
"evalue": "'module' object is not callable", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[5], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01msetup\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43msetup\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", | ||
"\u001b[0;31mTypeError\u001b[0m: 'module' object is not callable" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# setup to allow importing from law, order, cmsdb, hbw, and columnflow\n", | ||
"from setup import setup\n", | ||
"setup()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"-99999.0\n", | ||
"{'Jet.eta', 'Jet.pt', 'Jet.mass', 'Jet.phi'}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# check that imports are working\n", | ||
"import law\n", | ||
"import order as od\n", | ||
"import cmsdb\n", | ||
"from columnflow.columnar_util import EMPTY_FLOAT\n", | ||
"from hbw.util import four_vec\n", | ||
" \n", | ||
"print(EMPTY_FLOAT)\n", | ||
"print(four_vec(\"Jet\"))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "NameError", | ||
"evalue": "name 'tf' is not defined", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[16], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# import tensorflow as tf\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(ak\u001b[38;5;241m.\u001b[39m__version__, np\u001b[38;5;241m.\u001b[39m__version__, \u001b[43mtf\u001b[49m\u001b[38;5;241m.\u001b[39m__version__)\n", | ||
"\u001b[0;31mNameError\u001b[0m: name 'tf' is not defined" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# check that the most important packages are included\n", | ||
"import awkward as ak\n", | ||
"import numpy as np\n", | ||
"import tensorflow as tf\n", | ||
"\n", | ||
"print(ak.__version__, np.__version__, tf.__version__)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "test2", | ||
"language": "python", | ||
"name": "test2" | ||
}, | ||
"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.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# coding: utf-8 | ||
|
||
def setup(): | ||
import sys | ||
import os | ||
|
||
# add paths to sys to allow importing hbw, columnflow, cmsdb, law, and order | ||
this_dir = os.getcwd() | ||
hbw_dir = os.path.abspath(os.path.join("../../")) | ||
cf_dir = os.path.abspath(os.path.join("../../modules/columnflow")) | ||
db_dir = os.path.abspath(os.path.join("../../modules/cmsdb")) | ||
law_dir = os.path.abspath(os.path.join("../../modules/columnflow/modules/law")) | ||
od_dir = os.path.abspath(os.path.join("../../modules/columnflow/modules/order")) | ||
LAW_CONFIG_FILE = f"{hbw_dir}/law.cfg" | ||
|
||
for _dir in (hbw_dir, cf_dir, db_dir, law_dir, od_dir): | ||
if _dir not in sys.path: | ||
sys.path.append(_dir) | ||
|
||
import law | ||
# setup the law config such that hbw can be imported | ||
law.config.add_section("analysis") | ||
law.config.set("analysis", "default_analysis", "hbw.analysis.hbw_sl.hbw_sl") | ||
law.config.set("analysis", "default_config", "c17") | ||
law.config.set("analysis", "default_dataset", "ggHH_kl_1_kt_1_sl_hbbhww_powheg") | ||
law.config.set("analysis", "default_columnar_sandbox", "bash::$CF_BASE/sandboxes/venv_columnar.sh") |