-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: decorator is back on (sadly), started export command refactoring
- Loading branch information
1 parent
b0b67fb
commit 812043f
Showing
5 changed files
with
113 additions
and
44 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
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 |
---|---|---|
@@ -1,32 +1,48 @@ | ||
"""Decorator module.""" | ||
|
||
# import functools | ||
import functools | ||
|
||
# from perun import config, log | ||
# from perun.configuration import read_custom_config, read_environ, save_to_config | ||
# from perun.perun import monitor_application | ||
from perun import config, log | ||
from perun.configuration import read_custom_config, read_environ, save_to_config | ||
from perun.perun import Perun | ||
|
||
# def monitor( | ||
# configuration: str = "./.perun.ini", | ||
# **conf_kwargs, | ||
# ): | ||
# """Decorate function to monitor its energy usage.""" | ||
|
||
# def inner_function(func): | ||
# @functools.wraps(func) | ||
# def func_wrapper(*args, **kwargs): | ||
# # Get custom config and kwargs | ||
# read_custom_config(None, None, configuration) | ||
# for key, value in conf_kwargs.items(): | ||
# save_to_config(key, value) | ||
def monitor( | ||
configuration: str = "./.perun.ini", | ||
**conf_kwargs, | ||
): | ||
"""Decorate function to monitor its energy usage. | ||
# read_environ() | ||
# log.setLevel(f"{config.get('debug', 'log_lvl')}") | ||
Parameters | ||
---------- | ||
configuration : str, optional | ||
Path to configuration file, by default "./.perun.ini" | ||
# func_result = monitor_application(func, args, kwargs) | ||
Returns | ||
------- | ||
_type_ | ||
Function with perun monitoring enabled | ||
""" | ||
|
||
# return func_result | ||
def inner_function(func): | ||
@functools.wraps(func) | ||
def func_wrapper(*args, **kwargs): | ||
# Get custom config and kwargs | ||
|
||
# return func_wrapper | ||
read_environ() | ||
|
||
# return inner_function | ||
read_custom_config(None, None, configuration) | ||
for key, value in conf_kwargs.items(): | ||
save_to_config(key, value) | ||
|
||
log.setLevel(f"{config.get('debug', 'log_lvl')}") | ||
|
||
perun = Perun(config) | ||
|
||
func_result = perun.monitor_application(func, args, kwargs) | ||
|
||
return func_result | ||
|
||
return func_wrapper | ||
|
||
return inner_function |
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
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
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