# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['perun', 'perun.backend', 'perun.extras']

package_data = \
{'': ['*']}

install_requires = \
['PyYAML>=6.0,<7.0',
 'click>=8.1.3,<9.0.0',
 'h5py>=3.7.0,<4.0.0',
 'mpi4py>=3.1.3,<4.0.0',
 'numpy>=1.23.2,<2.0.0',
 'py-cpuinfo>=8.0.0,<9.0.0',
 'pynvml>=11.4.1,<12.0.0']

entry_points = \
{'console_scripts': ['perun = perun.cli:main']}

setup_kwargs = {
    'name': 'perun',
    'version': '0.1.0b11',
    'description': '',
    'long_description': '<div align="center">\n  <img src="https://raw.githubusercontent.com/Helmholtz-AI-Energy/perun/main/doc/images/perun.svg">\n</div>\n\nHave you ever wondered how much energy is used when training your neural network on the MNIST dataset? Want to get scared because of impact you are having on the evironment while doing "valuable" research? Are you interested in knowing how much carbon you are burning playing with DALL-E just to get attention on twitter? If the thing that was missing from your machine learning workflow was existential dread, this is the correct package for you!\n\n## Installation\n\nFrom PyPI:\n\n```$ pip install perun```\n\nFrom Github:\n\n```$ pip install git+https://github.com/Helmholtz-AI-Energy/perun```\n\n### Parallel h5py\n\nTo build h5py with mpi support:\n\n```CC=mpicc HDF5_MPI="ON" pip install --no-binary h5py h5py```\n\n## Usage\n\n### Command line\n\nTo get a quick report of the power usage of a python script simply run\n\n```$ perun monitor --format yaml path/to/your/script.py [args]```\n\nOr\n\n```$ python -m perun monitor --format json -o results/ path/to/your/script.py [args]```\n\n\n#### Subcommands\n\nPerun subcommands have some shared options that are typed before the subcommands.\n\n```\nUsage: perun [OPTIONS] COMMAND [ARGS]...\n\n  Perun: Energy measuring and reporting tool.\n\nOptions:\n  --version                       Show the version and exit.\n  -c, --configuration FILE\n  -f, --format [txt|yaml|yml|json]\n                                  report print format\n  -f, --frequency FLOAT           sampling frequency (in Hz)\n  --format [txt|yaml|yml|json]    report print format\n  --data_out DIRECTORY            experiment data output directory\n  -l, --log_lvl [DEBUG|INFO|WARN|ERROR|CRITICAL]\n                                  Loggging level\n  --pue FLOAT                     Data center Power usage efficiency\n  --location TEXT                 Data center location\n  --help                          Show this message and exit.\n\nCommands:\n  monitor      Gather power consumption from hardware devices while...\n  postprocess  Apply post-processing to EXP_HDF5 experiment file.\n  report       Print consumption report from EXP_HDF5 on the command line...\n  showconf     Print current perun configuration in INI format.\n```\n\n**monitor**\n\nMonitor energy usage of a python script.\n\n```\nUsage: perun monitor [OPTIONS] SCRIPT [SCRIPT_ARGS]...\n\n  Gather power consumption from hardware devices while SCRIPT [SCRIPT_ARGS] is\n  running.\n\n  SCRIPT is a path to the python script to monitor, run with arguments\n  SCRIPT_ARGS.\n\nOptions:\n  --help                        Show this message and exit.\n```\n\n**report**\n\nPrint a report from previous monitoring results.\n\n```\nUsage: perun report [OPTIONS] EXP_HDF5\n\n  Print consumption report from EXP_HDF5 on the command line on the desired\n  format.\n\n  EXP_HDF5 is an hdf5 file generated by perun after monitoring a script,\n  containing data gathered from hardware devices.\n\nOptions:\n  --help                          Show this message and exit.\n```\n\n**postprocess**\n\nApply postprocessing to existing perun experiment data.\n\n```\nUsage: perun postprocess [OPTIONS] EXP_HDF5\n\n  Apply post-processing to EXP_HDF5 experiment file.\n\n  EXP_HDF5 is an hdf5 file generated by perun after monitoring a script,\n  containing data gathered from hardware devices.\n\nOptions:\n  --help  Show this message and exit.\n```\n\n**showconf**\n\nPrints the current option configurations based on the global, local configurations files and command line options.\n\n\'\'\'\nUsage: perun showconf [OPTIONS]\n\n  Print current perun configuration in INI format.\n\nOptions:\n  --default  Print default configuration\n  --help     Show this message and exit.\n\'\'\'\n\n### Decorator\n\nOr decorate the function that you want analysed\n\n```python\nimport perun\n\n@perun.monitor(outDir="results/", format="txt")\ndef training_loop(args, model, device, train_loader, test_loader, optimizer, scheduler):\n    for epoch in range(1, args.epochs + 1):\n        train(args, model, device, train_loader, optimizer, epoch)\n        test(model, device, test_loader)\n        scheduler.step()\n```\n\n\nOptional Arguments:\n\n|   |   |\n|---|---|\n|frequency: FLOAT             |sampling frequency (in Hz) |\n|format: [txt|yaml|yml|json]  |report print format |\n|outdir DIRECTORY:            |experiment data output directory |\n\n\n## Configuration\n\nThere are multiple ways to configure perun, with a different level of priorities.\n\n1. CMD Line options and Env Variables\n\nThe highest priority is given to command line options and environmental variables. The options are shown in the command line section. The options can also be passed as environmental variables by adding the prefix \'PERUN\' to them. Ex. "--format txt" -> PERUN_FORMAT=txt\n\n2. Local INI file\n\nPerun will look into the cwd for ".perun.ini" file, where options can be fixed for the directory.\n\nExample:\n```ini\n[report]\nformat = txt\npue = 1.58\nlocation = DE\n\n[monitor]\nfrequency = 1\ndata_out = ./results\n\n[perun]\nlog_lvl = WARN\n```\n\nThe location of the file can be changed using the option "-c" or "PERUN_CONFIGURATION".\n\n3. Global INI file\n\nIf the file ~/.config/perun.ini is found, perun will override the default configuration with the contents of the file.\n\n\n### Priority\n\nCMD LINE and ENV > Local INI > Global INI > Default options\n\n## Experiment data\n\nRaw data is saved in a hdf5 file, where results over multiple runs are accumulated.\n\nAt the top level, the root group containts groups for all individual runs, as well as information about creation date and total energy consumption over multiple runs.\n\nExperiments contain the information about a single run of the python script, and has information about nodes, devices per node, total runtime and avgerage power draw.\n\nThe same applies at the node level.\n\nAt the lowest group level, datasets with sample data from individual devices is collected, with the dataset attributes providing the device metadata, like id, measurement unit and magnitude, and possible value range.\n\n- exp_name (Root group)\n  - exp_0 (Group)\n    - node_name_0 (Group)\n      - device_0 (Dataset)\n        - units (Attribute)\n        - mag (Attribute)\n        - long_name (Attribute)\n        - ...\n      - device_1 (Dataset)\n      - ...\n    - node_name_1 (Group)\n    - ...\n  - exp_1 (Group)\n  - ...\n',
    'author': 'Gutiérrez Hermosillo Muriedas, Juan Pedro',
    'author_email': 'juanpedroghm@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/Helmholtz-AI-Energy/perun',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
