{"id":16271075,"url":"https://github.com/okuvshynov/fewlines","last_synced_at":"2025-10-04T06:30:48.035Z","repository":{"id":177408512,"uuid":"659959152","full_name":"okuvshynov/fewlines","owner":"okuvshynov","description":"Create histograms, time series charts and dashboards in command-line output and log files.","archived":false,"fork":false,"pushed_at":"2024-06-03T16:08:54.000Z","size":218,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-06T17:55:31.924Z","etag":null,"topics":["cli","dashboard","distribution","histogram","logging","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okuvshynov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-29T00:11:52.000Z","updated_at":"2025-01-05T15:11:29.000Z","dependencies_parsed_at":"2024-12-10T19:56:37.264Z","dependency_job_id":null,"html_url":"https://github.com/okuvshynov/fewlines","commit_stats":null,"previous_names":["okuvshynov/fewlines"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okuvshynov%2Ffewlines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okuvshynov%2Ffewlines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okuvshynov%2Ffewlines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okuvshynov%2Ffewlines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okuvshynov","download_url":"https://codeload.github.com/okuvshynov/fewlines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235222571,"owners_count":18955330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","dashboard","distribution","histogram","logging","python"],"created_at":"2024-10-10T18:12:21.967Z","updated_at":"2025-10-04T06:30:40.767Z","avatar_url":"https://github.com/okuvshynov.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fewlines - log your dashboard\n\nWhether we like it or not, we debug things by putting print statements around.\n\n`fewlines` is a supplement for this, allowing to plot bar charts which only take few lines in a terminal output, but can be a very useful piece of information.\nIn a more extended form fewlines can be used for logging collections of charts in a dashboard-like form.\n\nCurrently python only.\nc++ version in progress and experimental.\n\nRequires Unicode block characters.\nHorizon-style color output requires terminal with 256 ANSI colors.\nMonochrome version can be used for logging distributions to text files. \n\nExample: plotting distribution of weights, gradients and activations for layers in LoRA neural net modules:\n\n```\n=== WEIGHTS ===\n~~~~~~~~~ -0.000912|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|0.000912\n               Q0.B|▃▇▅▄▄▃▃▃▃▂▂▂▃▂▂▂▂▂▂▂▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▂▃▃▂▂▂▂▃▃▃▃▄▄▆▇▃|\n               V0.B|▁▆▇▇▆▅▄▃▃▄▃▃▃▃▃▃▃▂▂▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▂▃▃▃▃▃▃▃▃▃▄▄▅▆▇▇▆▁|\n               Q1.B|▃▇▇▇▅▅▄▄▃▄▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▂▃▃▃▃▃▃▃▃▂▃▃▃▃▃▃▃▃▃▃▃▃▄▄▅▅▆▇▇▃|\n               V1.B|▂▇▇▆▅▄▄▃▃▂▂▂▂▂▂▂▂▁▂▂▁▂▁▁▁▁▁▁▁▁▁▁▁▂▁▁▁▂▁▂▂▁▁▂▂▂▂▂▂▂▂▂▃▄▅▅▆▇▇▂|\n               Q2.B|▂▆▇▆▅▄▃▃▃▃▃▃▃▃▃▃▂▃▃▃▃▂▃▃▂▂▂▂▂▃▂▂▃▂▃▃▂▃▃▂▃▃▃▃▃▃▃▃▃▃▃▃▃▄▄▅▆▇▇▂|\n               V2.B|▂▇▇▆▅▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▂▂▂▁▁▂▁▁▂▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▄▅▆▇▇▂|\n               Q3.B|▃▇▇▇▅▅▄▄▃▃▃▃▃▃▃▃▂▃▂▂▂▂▂▂▂▂▂▂▂▃▂▂▂▂▂▂▂▂▂▂▃▂▂▃▃▂▃▃▃▃▃▃▄▄▅▅▆▇▇▃|\n               V3.B|▃▇▇▆▅▄▃▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▃▄▄▆▇▇▃|\n               Q4.B|▂▆▇▇▅▅▄▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▂▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▄▅▅▆▇▆▂|\n               V4.B|▃▇▆▅▄▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▅▆▇▃|\n               Q5.B|▃▇▇▆▆▅▄▄▃▃▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▂▃▃▂▂▃▂▃▃▃▃▃▄▄▄▅▆▇▇▆▃|\n               V5.B|▃▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▃▄▅▆▇▄|\n               Q6.B|▃▇▇▆▅▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▂▂▂▂▂▁▁▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▄▅▆▇▇▃|\n               V6.B|▄▇▆▄▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▃|\n               Q7.B|▃▇▇▆▅▄▄▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▃▃▄▅▆▇▇▃|\n               V7.B|▄▇▆▄▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁   ▁▁      ▁   ▁  ▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▆▇▅|\n               Q8.B|▄▇▆▅▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▁▂▁▂▂▂▂▂▂▂▃▃▃▄▅▆▇▄|\n               V8.B|▅▇▅▄▃▂▂▁▁▁▁▁▁▁▁▁▁▁  ▁▁ ▁▁            ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▇▅|\n```\n\nAs we can see, it's very compact, can be put to log files with any other relevant info and gives a good insight into what do weights look like: bimodal, close to 1e-4, earlier layers move closer to center. \n\nWhile created originally to plot distributions of weights/gradients or ML models it is not restricted to ML use cases, obviously. Can be used to show latency distribution, for example.\n\npython installation:\n```\npip install fewlines\n```\n\n\n## Usage example\n\n### Basic charts\n\n```\nfrom fewlines import charts as fc\nimport numpy as np\n\nA = np.random.normal(size=100)\nprint('Just the list of numbers')\nfor l in fc.histogram_chart(A):\n    print(l)\nprint('the list of numbers with extra options')\nfor l in fc.histogram_chart((A, {'n_lines': 3})):\n    print(l)\nprint('the dict title -\u003e numbers')\nfor l in fc.histogram_chart({'series_A': A}):\n    print(l)\nprint('the dict title -\u003e numbers, options')\nfor l in fc.histogram_chart({'series_A': (A, {'n_lines': 3})}):\n    print(l)\n```\n\nOutput:\nNote that multi-line charts rendering might depend on terminal spacing settings. Here in markdown it is messed up, so I'm attaching it as image.\n\n\u003cimg width=\"516\" alt=\"Screenshot 2024-04-04 at 11 20 12 AM\" src=\"https://github.com/okuvshynov/fewlines/assets/661042/89c8d036-9e86-400c-83ff-47bc35affd59\"\u003e\n\n\n### Dashboards\n\n```\nfrom fewlines import metrics as fm\nfrom fewlines import dashboard as fd\nimport numpy as np\nimport time\n\n# logging data somewhere\nfor i, v in enumerate(np.random.lognormal(mean=1.0, sigma=0.7, size=1000)):\n    fm.add('ssd_read_latency', v, time.time() - i)\nfor i, v in enumerate(np.random.lognormal(mean=3.0, sigma=0.7, size=1500)):\n    fm.add('nw_recv_latency', v, time.time() - i)\n\nprint(\"\\n## Default one-line dashboards with wildcard\")\nfor s in fd.histograms('*latency'):\n    print(s)\n\nfor s in fd.timeseries('*latency'):\n    print(s)\n\nprint()\nprint('\\n## two histograms with separate scales with larger height and horizon colors')\nfor s in fd.dashboard({\"charts\": [('*latency', 'histogram')], \"n_lines\": 3, \"color\": 'green'}):\n    print(s) \n\nprint()\nprint('\\n## two histograms sharing the scale as they are part of the same group with larger height and horizon colors')\nfor s in fd.dashboard({\"charts\": [[('*latency', 'histogram')]], \"n_lines\": 3, \"color\": 'green'}):\n    print(s)\n\nprint()\nconf = {\n    \"title\": \"Custom Dashboard\",\n    \"charts\": [\n        ('ssd_read_latency', 'timeseries', {'n_lines': 3, 'color': None}),\n        [\n            ('ssd_read_latency', 'timeseries'),\n            ('ssd_read_latency', 'timeseries', {'agg': 'max'}),\n            ('ssd_read_latency', 'timeseries', {'agg': 'min'}),\n        ],\n        ('ssd_read_latency', 'histogram', {'n_lines': 4, 'color': 'green'}),\n        ('ssd_read_latency', 'histogram', {'n_lines': 4, 'color': 'gray'}),\n        ('ssd_read_latency', 'histogram', {'n_lines': 6, 'color': None}),\n    ],\n    \"time\": -600, # default -3600\n    \"bins\": 60, # default 60\n    \"title_width\": 40, # default 30\n    \"n_lines\": 3,\n    \"color\": None,\n}\nprint('\\n## detailed complicated config with different aggregations')\nfor s in fd.dashboard(conf):\n    print(s)\n```\n\nOutput:\n\n\u003cimg width=\"668\" alt=\"Screenshot 2024-04-04 at 11 18 33 AM\" src=\"https://github.com/okuvshynov/fewlines/assets/661042/5c95a06d-1182-44b8-a4af-9949ca8b68a7\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokuvshynov%2Ffewlines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokuvshynov%2Ffewlines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokuvshynov%2Ffewlines/lists"}