Skip to content
Snippets Groups Projects
Commit e006d733 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Merge branch 'skeleton' into 'main'

Skeleton

See merge request !1
parents ec53929e 402b1513
No related branches found
No related tags found
1 merge request!1Skeleton
Pipeline #94021 passed
precommit:
image: python:slim-bookworm
before_script:
- apt update && apt install -y --no-install-recommends git
- pip install -r requirements.txt
script:
- pre-commit run --all-files
\ No newline at end of file
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
# dool_plugins # dool_plugins
A collections of useful plugins for dool.
## Currently available plugins
## Getting started - perf
## Plugins to add
- pmt (https://git.astron.nl/RD/pmt)
- fmt (https://git.astron.nl/RD/fmt)
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files ## Getting started
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files To install dool you can follow the instruction at the repository https://github.com/scottchiefbaker/dool/tree/master
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
Once dool is installed you can just run
``` ```
cd existing_repo python install.py
git remote add origin https://git.astron.nl/RD/dool_plugins.git ```
git branch -M main or
git push -uf origin main ```
python3 install.py
``` ```
## Integrate with your tools and use the plugin in dool as in the example
- [ ] [Set up project integrations](https://git.astron.nl/RD/dool_plugins/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status ```
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. dool --perf instructions,cycles
```
#!/usr/bin/python3
###############################################################################
# Simple install script that copies files to various paths and sets
# permissions on files. Nothing fancy here, just copying files around
#
# 2022-09-28 - Scott Baker (github.com/scottchiefbaker/dool)
# 2024-09-26 - Mattia Mancini
###############################################################################
import sys
import glob
import os
import shutil
from argparse import ArgumentParser
base_dir = os.path.dirname(__file__)
base_dir = base_dir or "."
system_plugin_dir = "/usr/share/dool/"
user_plugin_dir = os.path.expanduser("~/.dool/")
def parse_args():
parser = ArgumentParser(description="Installer for dool_plugins")
parser.add_argument("--root", action="store_true")
parser.add_argument("--user", action="store_true")
parser.add_argument("--verbose", action="store_true")
args = parser.parse_args()
if args.root and args.user:
raise ValueError("user and root option are mutually exclusive")
return args
args = parse_args()
# Set some global variables
force_root_install = args.root
force_user_install = args.user
verbose = args.verbose
# Glob the files we need to install
plugins = glob.glob(base_dir + "/plugins/*.py")
can_write_on_system_path = os.access(system_plugin_dir, os.W_OK)
############################################################
def main():
if force_root_install or can_write_on_system_path:
print("You are %s, doing a local install\n" % color(9, "root"))
plugin_dir = system_plugin_dir
else:
print(
"You are a %s user, doing a local install\n" % color(227, "normal")
)
plugin_dir = user_plugin_dir
print("Installing plugins to %s" % color(15, plugin_dir))
copy_files(plugins, plugin_dir, 0o644)
############################################################
# Print a string wrapped in an ANSI color and RESET
def color(num, mystr):
reset = "\033[0;0m"
ret = "\033[38;5;" + str(num) + "m" + mystr + reset
return ret
# Copy an array of files to a destination dir and chmod each file to mode
def copy_files(files, dest_dir, mode):
ok = os.makedirs(dest_dir, exist_ok=True)
count = 0
for x in files:
basename = os.path.basename(x)
dest_file = os.path.join(dest_dir, basename)
# Copy file
ok = shutil.copyfile(x, dest_file)
# Chmod the file after it's copied
os.chmod(dest_file, mode)
if verbose:
print("%40s => %s" % (x, dest_file))
if ok:
count += 1
return ok
################################################################
if __name__ == "__main__":
main()
"""
class dool(ABC):
vars = None
name = None
nick = None
type = 'f'
types = ()
width = 5
scale = 1024
scales = ()
cols = 0
struct = None
def discover():
return True
"""
class dool_plugin(dool):
"""
Power usage using PMT
Usage:
dool --pmt-power -N <backend>
"""
def __init__(self):
self.nick = []
self.vars = []
self.width = 6
self.name = "pmt-perf"
self.scale = 0
def discover(self, *objlist):
metrics = op.plugin_params["perf"].split(",")
if not metrics:
raise ValueError("Please specify the events to monitor for perf")
self.cols = len(metrics)
self.nick = self.vars + list(metrics)
self.vars = self.vars + list(metrics)
self.types = ["s"] * len(self.nick)
self.scales = [0] * len(self.nick)
self.pid = (
op.plugin_params["pid-detail"]
if "pid-detail" in op.plugin_params
else None
)
self.val = {name: 0 for name in self.vars}
self.val["total"] = 0
print(self.nick, self.vars, self.val)
self._run_perf()
print("ran waiting for output")
def _run_perf(self):
cmd = "perf stat -I %s -e %s" % (op.delay * 1000, ",".join(self.vars))
if self.pid:
cmd += " -p " + self.pid
self.stdin, self.stdout, self.stderr = dpopen(cmd)
line = self.stderr.readline()
if b"Error" in line or b"error" in line:
print(self.stderr.read().decode())
raise Exception("Error executing perf stat")
def check(self):
pass
def extract(self):
for _ in range(len(self.vars)):
res = tuple(
self.stderr.readline()
.decode()
.rstrip("\n")
.split("#")[0]
.split()
)
if len(res) == 3:
time, val, name = res
else:
time, *val, name = res
val = " ".join(val)
val = val.replace(".", "").replace(",", ".")
var_index = self.vars.index(name)
if " " in val:
self.types[var_index] = "s"
elif "," in val:
self.types[var_index] = "f"
val = float(val)
elif "." in val:
self.types[var_index] = "d"
val = int(val)
self.val[name] = val
self.val["total"] = time
[project]
name = "dool_plugins"
requires-python = ">=3.5"
authors = [{name = "Mattia Mancini", email = "mancini@astron.nl"}]
readme = "README.md"
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: Apache Software License"]
dynamic = ["version", "description"]
[project.urls]
Home = "https://git.astron.nl/RD/dool_plugins"
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| \.yaml
| \.toml
)/
'''
pre-commit
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment