Skip to content
Snippets Groups Projects
Commit d1d47e08 authored by Guido Sterbini's avatar Guido Sterbini
Browse files

Adding examples

parent b14e7159
No related branches found
No related tags found
No related merge requests found
Showing
with 129 additions and 8 deletions
...@@ -37,13 +37,17 @@ This package is intended to create the corresponding folders of the "generations ...@@ -37,13 +37,17 @@ This package is intended to create the corresponding folders of the "generations
## Contributors ## Contributors
Philippe Belanger Philippe Belanger
Gianni Iadarola Gianni Iadarola
Sofia Kostoglou Sofia Kostoglou
Hamish Graham Hamish Graham
Guido Sterbini Guido Sterbini
Frederik Van Der Veken Frederik Van Der Veken
## Getting started
First you need to install this package in your (virtual) environment. Presently, the suggested way is to go for local folder installation:
```
git clone https://gitlab.cern.ch/abpcomputing/sandbox/tree_maker.git tree_maker
cd tree_maker
python -m pip install -e .
```
\ No newline at end of file
# This is my input
sum_a_b: 0 # this is the first element of the product
c: -1 # this is the second element of the product
result: 0
import json
import numpy as np
import ruamel.yaml
# load the configuration
with open('config.yaml', 'r') as file:
yaml = ruamel.yaml.YAML()
cfg = yaml.load(file)
# define the function (product of two numbers)
def my_function(my_x, my_y):
'Just a multiplication'
return my_x*my_y
# run the code
result = my_function(cfg['sum_a_b'], cfg['c'])
with open('output.yaml', 'w') as fp:
yaml = ruamel.yaml.YAML()
yaml.dump({'result': result}, fp)
\ No newline at end of file
#!/bin/bash
source /afs/cern.ch/eng/tracking-tools/python_installations/activate_default_python
python run.py
#initialdir = .
executable = run.sh
output = .output.txt
error = .err.txt
log = .log.txt
should_transfer_files = yes
when_to_transfer_output = on_exit
transfer_input_files = config.yaml, run.py
# The line below can be commented it necessary
#transfer_output_files = output.yaml
+JobFlavour = "espresso"
queue
# This is my input
a: 4.233 # this has to be sqrt'ed
\ No newline at end of file
result: 2.057425575810702
import json
import numpy as np
import ruamel.yaml
# load the configuration
with open('config.yaml', 'r') as file:
yaml = ruamel.yaml.YAML()
cfg = yaml.load(file)
# define the function (sqrt of a number)
def my_function(my_x):
'Just an addition'
return float(np.sqrt(np.abs(my_x)))
# run the code
result = my_function(cfg['a'])
with open('output.yaml', 'w') as fp:
yaml = ruamel.yaml.YAML()
yaml.dump({'result': result}, fp)
\ No newline at end of file
#!/bin/bash
source /afs/cern.ch/eng/tracking-tools/python_installations/activate_default_python
python run.py
#initialdir = .
executable = run.sh
output = .output.txt
error = .err.txt
log = .log.txt
should_transfer_files = yes
when_to_transfer_output = on_exit
transfer_input_files = config.yaml, run.py
# The line below can be commented it necessary
#transfer_output_files = output.yaml
+JobFlavour = "espresso"
queue
# This is my input
a: 0 # this is the first element of the sum
b: -1 # this is the second element of the sum
run_command: 'python run.py'
\ No newline at end of file
result: -1
import json
import numpy as np
import ruamel.yaml
# load the configuration
with open('config.yaml', 'r') as file:
yaml = ruamel.yaml.YAML()
cfg = yaml.load(file)
# define the function (sum of two numbers)
def my_function(my_x, my_y):
'Just an addition'
return my_x+my_y
# run the code
result = my_function(cfg['a'], cfg['b'])
with open('output.yaml', 'w') as fp:
yaml = ruamel.yaml.YAML()
yaml.dump({'result': result}, fp)
\ No newline at end of file
#!/bin/bash
source /afs/cern.ch/eng/tracking-tools/python_installations/activate_default_python
python run.py
#initialdir = .
executable = run.sh
output = .output.txt
error = .err.txt
log = .log.txt
should_transfer_files = yes
when_to_transfer_output = on_exit
transfer_input_files = config.yaml, run.py
# The line below can be commented it necessary
#transfer_output_files = output.yaml
+JobFlavour = "espresso"
queue
...@@ -32,9 +32,9 @@ REQUIREMENTS: dict = { ...@@ -32,9 +32,9 @@ REQUIREMENTS: dict = {
setup( setup(
name="tree_maker", name="tree_maker",
version="0.0.1", version="0.0.1",
author="Hamish Graham", author="Hamish Graham, Guido Sterbini",
author_email="hamish.graham@cern.ch", author_email="guido.sterbini@cern.ch",
description="Making a tree.", description="Using a tree topology to organize simulations.",
long_description=LONG_DESCRIPTION, long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="", url="",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment