[go: nahoru, domu]

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

Multiple pyexit #30

Closed

Conversation

MassimoGirondi
Copy link
Contributor

This is not completely finished yet, but let's start tracking the pending changes.

One may want to have multiple pyexit sections that are called when importing modules or when certain tags are given.
For instance, one may have a post processing pyexit that should be executed only some times.
It was not possible to do that in NPF (AFAIK).

Also, includes late_variables when running pyexit even in imported modules, otherwise it is not possible to access them. Pyexits are now executed in alphabetical order so one can have for instance "00-preprocess", ..., "99-averages", where in the last it calculated all the averages of the variables created/changed in the previous steps (useful if you want e.g. percentiles of time metrics). This functionality is not completely tested yet.

Finally, an initial version of a VIM syntax highlight for npf files.

One may want to conditionally include modules, PyExits in them should be
executed as well.

Also allow to have multiple PyExit in the same module to be executed in
sequence.
@tbarbette
Copy link
Owner

"Finally, an initial version of a VIM syntax highlight for npf files." +1000 !

Are the imports stuff actually run?

@MassimoGirondi
Copy link
Contributor Author
MassimoGirondi commented Jun 10, 2022

See the attached screenshot.
When running with the upstream version (top) the pyexit in the module is ignored, while with this patch it is executed.
The import script is executed in both cases (see the -MODULE results).
image

The code executed in the screenshot is the one in the integration/imports folder, with the pyexit names stripped down to be executed with the upstream npf:

main.npf:


%config
default_repo=local //No program under test
accept_zero={LOG} //Log may be "0" that is a valid number. By default NPF consider a test as failed is a value is 0
var_unit={RESULT: }
var_format={RESULT:%d}

%variables
N=[1-10]


%script
echo "RESULT-N $N"
echo "RESULT-LOG $(( log($N) ))"
echo "RESULT-EXP $(( pow(2,$N) ))"

%import module

%pyexit
print("RESULT_MAIN_PYEXIT")

module.npf

%script
echo "RESULT-N $N"
echo "RESULT-LOG-MODULE $(( log(2*$N) ))"
echo "RESULT-EXP-MODULE $(( pow(3,$N) ))"

%pyexit
print("This is pyexit in module!")
RESULTS["PYEXIT_MODULE_RESULT1"] = 7

@tbarbette
Copy link
Owner

Just fix the CI and then I'll merge :)

@tbarbette
Copy link
Owner

Rebasing in new PR

@tbarbette tbarbette closed this Jun 28, 2024
@tbarbette tbarbette mentioned this pull request Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants