From 313e9d11d78dc0ab55c505bee88e39e7575a5518 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 16:59:47 -0400 Subject: [PATCH 01/26] ignore virtual environments --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bee8a64b..01d7f95b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +venv \ No newline at end of file From 8eec28c3def43342b7b349adafdd17253263993b Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 18:26:38 -0400 Subject: [PATCH 02/26] basic refactoring for setup --- MANIFEST.in | 5 ++ VERSION | 1 + pyproject.toml | 3 ++ setup.cfg | 51 +++++++++++++++++++ src/plotman/__init__.py | 0 .../plotman/_tests/archive_test.py | 0 .../plotman/_tests/manager_test.py | 0 .../plotman/_tests/plot_util_test.py | 0 .../plotman/_tests/reporting_test.py | 0 analyzer.py => src/plotman/analyzer.py | 2 +- archive.py => src/plotman/archive.py | 4 +- interactive.py => src/plotman/interactive.py | 8 +-- job.py => src/plotman/job.py | 0 manager.py => src/plotman/manager.py | 6 +-- plot_util.py => src/plotman/plot_util.py | 0 plotman.py => src/plotman/plotman.py | 18 ++++--- reporting.py => src/plotman/reporting.py | 10 ++-- listlogs => util/listlogs | 0 18 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 MANIFEST.in create mode 100644 VERSION create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100644 src/plotman/__init__.py rename archive_test.py => src/plotman/_tests/archive_test.py (100%) rename manager_test.py => src/plotman/_tests/manager_test.py (100%) rename plot_util_test.py => src/plotman/_tests/plot_util_test.py (100%) rename reporting_test.py => src/plotman/_tests/reporting_test.py (100%) rename analyzer.py => src/plotman/analyzer.py (99%) rename archive.py => src/plotman/archive.py (98%) rename interactive.py => src/plotman/interactive.py (99%) rename job.py => src/plotman/job.py (100%) rename manager.py => src/plotman/manager.py (97%) rename plot_util.py => src/plotman/plot_util.py (100%) rename plotman.py => src/plotman/plotman.py (96%) rename reporting.py => src/plotman/reporting.py (98%) rename listlogs => util/listlogs (100%) mode change 100644 => 100755 diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..ebe64d50 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +CHANGELOG.md +config.sample.yaml +LICENSE +README.md +src/bash/listlogs \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6da28dde --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.1 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..07de284a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..0f2f6fc5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,51 @@ +[metadata] +name = plotman +version = file: VERSION +author = Eric Altendorf +author-email = PLACEHOLDER +home-page = https://github.com/ericaltendorf/plotman +description = Chia plotting manager +long-description = file: README.md +long_description_content_type = text/markdown +license = Apache 2.0 +license-file = LICENSE +platform = any +keywords = chia, blockchain, automation, process management +classifiers = + Development Status :: 3 - Alpha + Environment :: Console :: Curses + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: Information Technology + License :: OSI Approved :: Apache Software License + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python :: 3 + Topic :: Office/Business :: Scheduling + Topic :: System :: Monitoring + Topic :: System :: Systems Administration + Topic :: Utilities +project_urls = + Bug Tracker = https://github.com/ericaltendorf/plotman/issues + Changelog = https://github.com/ericaltendorf/plotman/blob/main/CHANGELOG.md + +[options] +package_dir= + =src +packages=find: +install_requires = + psutil + pyyaml + texttable + +[options.packages.find] +where=src + +[options.entry_points] +console_scripts = + plotman = plotman.plotman:main + + +[options.data_files] +config = config.yaml +bin = util/listlogs \ No newline at end of file diff --git a/src/plotman/__init__.py b/src/plotman/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/archive_test.py b/src/plotman/_tests/archive_test.py similarity index 100% rename from archive_test.py rename to src/plotman/_tests/archive_test.py diff --git a/manager_test.py b/src/plotman/_tests/manager_test.py similarity index 100% rename from manager_test.py rename to src/plotman/_tests/manager_test.py diff --git a/plot_util_test.py b/src/plotman/_tests/plot_util_test.py similarity index 100% rename from plot_util_test.py rename to src/plotman/_tests/plot_util_test.py diff --git a/reporting_test.py b/src/plotman/_tests/reporting_test.py similarity index 100% rename from reporting_test.py rename to src/plotman/_tests/reporting_test.py diff --git a/analyzer.py b/src/plotman/analyzer.py similarity index 99% rename from analyzer.py rename to src/plotman/analyzer.py index 8f1297b4..326a13bc 100644 --- a/analyzer.py +++ b/src/plotman/analyzer.py @@ -4,7 +4,7 @@ import sys import texttable as tt -import plot_util +from plotman import plot_util class LogAnalyzer: # Map from key (e.g. logdir or the like) to (map from measurement name to list of values) diff --git a/archive.py b/src/plotman/archive.py similarity index 98% rename from archive.py rename to src/plotman/archive.py index 4f69ea57..02e43498 100644 --- a/archive.py +++ b/src/plotman/archive.py @@ -10,8 +10,8 @@ import texttable as tt -import manager -import plot_util +from plotman import manager +from plotman import plot_util # TODO : write-protect and delete-protect archived plots diff --git a/interactive.py b/src/plotman/interactive.py similarity index 99% rename from interactive.py rename to src/plotman/interactive.py index 0395e6bd..dbce0402 100644 --- a/interactive.py +++ b/src/plotman/interactive.py @@ -7,10 +7,10 @@ import threading import yaml -from job import Job -import archive -import manager -import reporting +from plotman.job import Job +from plotman import archive +from plotman import manager +from plotman import reporting class Log: def __init__(self): diff --git a/job.py b/src/plotman/job.py similarity index 100% rename from job.py rename to src/plotman/job.py diff --git a/manager.py b/src/plotman/manager.py similarity index 97% rename from manager.py rename to src/plotman/manager.py index d7b8233f..e2afecf5 100644 --- a/manager.py +++ b/src/plotman/manager.py @@ -13,9 +13,9 @@ import sys # Plotman libraries -import job -import plot_util -import archive # for get_archdir_freebytes(). TODO: move to avoid import loop +from plotman import job +from plotman import plot_util +from plotman import archive # for get_archdir_freebytes(). TODO: move to avoid import loop # Constants MIN = 60 # Seconds diff --git a/plot_util.py b/src/plotman/plot_util.py similarity index 100% rename from plot_util.py rename to src/plotman/plot_util.py diff --git a/plotman.py b/src/plotman/plotman.py similarity index 96% rename from plotman.py rename to src/plotman/plotman.py index 4257b94a..12954b08 100755 --- a/plotman.py +++ b/src/plotman/plotman.py @@ -14,13 +14,13 @@ import yaml # Plotman libraries -from job import Job -import analyzer -import archive -import interactive -import manager -import plot_util -import reporting +from plotman.job import Job +from plotman import analyzer +from plotman import archive +from plotman import interactive +from plotman import manager +from plotman import plot_util +from plotman import reporting class PlotmanArgParser: def add_idprefix_arg(self, subparser): @@ -79,7 +79,7 @@ def get_term_width(): columns = 120 # 80 is typically too narrow. TODO: make a command line arg. return columns -if __name__ == "__main__": +def main(): random.seed() pm_parser = PlotmanArgParser() @@ -202,3 +202,5 @@ def get_term_width(): print('Resuming ' + job.plot_id) job.resume() +if __name__ == "__main__": + main() diff --git a/reporting.py b/src/plotman/reporting.py similarity index 98% rename from reporting.py rename to src/plotman/reporting.py index d1a27bd0..07649d94 100644 --- a/reporting.py +++ b/src/plotman/reporting.py @@ -1,12 +1,12 @@ import texttable as tt # from somewhere? import os import psutil - -import archive -import job -import manager import math -import plot_util + +from plotman import archive +from plotman import job +from plotman import manager +from plotman import plot_util def abbr_path(path, putative_prefix): if putative_prefix and path.startswith(putative_prefix): diff --git a/listlogs b/util/listlogs old mode 100644 new mode 100755 similarity index 100% rename from listlogs rename to util/listlogs From 18e771aefb711bd41a83d4b1a26dbbe0e42ec525 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 18:28:39 -0400 Subject: [PATCH 03/26] cleaning up imports with isort --- src/plotman/_tests/archive_test.py | 1 + src/plotman/_tests/manager_test.py | 5 +++-- src/plotman/_tests/plot_util_test.py | 6 +++--- src/plotman/_tests/reporting_test.py | 4 ++-- src/plotman/analyzer.py | 2 ++ src/plotman/archive.py | 11 +++++------ src/plotman/interactive.py | 6 +++--- src/plotman/job.py | 15 ++++++++------- src/plotman/manager.py | 18 +++++++++--------- src/plotman/plotman.py | 21 +++++++++------------ src/plotman/reporting.py | 11 +++++------ 11 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/plotman/_tests/archive_test.py b/src/plotman/_tests/archive_test.py index 0bff2f87..85b32d7e 100755 --- a/src/plotman/_tests/archive_test.py +++ b/src/plotman/_tests/archive_test.py @@ -1,6 +1,7 @@ import archive import manager + def test_compute_priority(): assert (archive.compute_priority( (3, 1), 1000, 10) > archive.compute_priority( (3, 6), 1000, 10) ) diff --git a/src/plotman/_tests/manager_test.py b/src/plotman/_tests/manager_test.py index 3e2c9ce8..d492c70e 100755 --- a/src/plotman/_tests/manager_test.py +++ b/src/plotman/_tests/manager_test.py @@ -1,9 +1,10 @@ # TODO: migrate away from unittest patch from unittest.mock import patch -import pytest -import manager import job +import manager +import pytest + @pytest.fixture def sched_cfg(): diff --git a/src/plotman/_tests/plot_util_test.py b/src/plotman/_tests/plot_util_test.py index 2585fced..8bec3edc 100755 --- a/src/plotman/_tests/plot_util_test.py +++ b/src/plotman/_tests/plot_util_test.py @@ -1,9 +1,9 @@ -from plot_util import GB - import os -import pyfakefs import plot_util +import pyfakefs +from plot_util import GB + def test_human_format(): assert (plot_util.human_format(3442000000, 0) == '3G') diff --git a/src/plotman/_tests/reporting_test.py b/src/plotman/_tests/reporting_test.py index 46cd0110..ee09203b 100644 --- a/src/plotman/_tests/reporting_test.py +++ b/src/plotman/_tests/reporting_test.py @@ -1,10 +1,10 @@ # TODO: migrate away from unittest patch -from unittest.mock import patch - import os +from unittest.mock import patch import reporting + def test_phases_str(): assert(reporting.phases_str([(1,2), (2,3), (3,4), (4,0)]) == '1:2 2:3 3:4 4:0') diff --git a/src/plotman/analyzer.py b/src/plotman/analyzer.py index 326a13bc..fd06df76 100644 --- a/src/plotman/analyzer.py +++ b/src/plotman/analyzer.py @@ -2,10 +2,12 @@ import re import statistics import sys + import texttable as tt from plotman import plot_util + class LogAnalyzer: # Map from key (e.g. logdir or the like) to (map from measurement name to list of values) all_measures = ['phase 1', 'phase 2', 'phase 3', 'phase 4', 'total time'] diff --git a/src/plotman/archive.py b/src/plotman/archive.py index 02e43498..5c4633b1 100644 --- a/src/plotman/archive.py +++ b/src/plotman/archive.py @@ -1,17 +1,16 @@ -from datetime import datetime -import subprocess import argparse import math import os -import psutil -import re import random +import re +import subprocess import sys +from datetime import datetime +import psutil import texttable as tt -from plotman import manager -from plotman import plot_util +from plotman import manager, plot_util # TODO : write-protect and delete-protect archived plots diff --git a/src/plotman/interactive.py b/src/plotman/interactive.py index dbce0402..3d17eae7 100644 --- a/src/plotman/interactive.py +++ b/src/plotman/interactive.py @@ -5,12 +5,12 @@ import os import subprocess import threading + import yaml +from plotman import archive, manager, reporting from plotman.job import Job -from plotman import archive -from plotman import manager -from plotman import reporting + class Log: def __init__(self): diff --git a/src/plotman/job.py b/src/plotman/job.py index 0aa327ee..6f326da8 100644 --- a/src/plotman/job.py +++ b/src/plotman/job.py @@ -1,18 +1,19 @@ # TODO do we use all these? -from datetime import datetime -from enum import Enum, auto -from subprocess import call import argparse - import contextlib import logging import os +import random import re +import sys import threading import time -import psutil # apt-get install python-psutil -import random -import sys +from datetime import datetime +from enum import Enum, auto +from subprocess import call + +import psutil # apt-get install python-psutil + def job_phases_for_tmpdir(d, all_jobs): '''Return phase 2-tuples for jobs running on tmpdir d''' diff --git a/src/plotman/manager.py b/src/plotman/manager.py index e2afecf5..37536362 100644 --- a/src/plotman/manager.py +++ b/src/plotman/manager.py @@ -1,21 +1,21 @@ -from datetime import datetime - import logging import operator import os +import random import re +import readline # For nice CLI +import subprocess +import sys import threading import time +from datetime import datetime + import psutil -import random -import readline # For nice CLI -import subprocess -import sys # Plotman libraries -from plotman import job -from plotman import plot_util -from plotman import archive # for get_archdir_freebytes(). TODO: move to avoid import loop +from plotman import \ + archive # for get_archdir_freebytes(). TODO: move to avoid import loop +from plotman import job, plot_util # Constants MIN = 60 # Seconds diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index 12954b08..3acd8df6 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -1,26 +1,23 @@ #!/usr/bin/env python3 -from datetime import datetime -from subprocess import call - import argparse import os -import re -import threading import random -import readline # For nice CLI +import re +import readline # For nice CLI import sys +import threading import time +from datetime import datetime +from subprocess import call + import yaml # Plotman libraries +from plotman import (analyzer, archive, interactive, manager, plot_util, + reporting) from plotman.job import Job -from plotman import analyzer -from plotman import archive -from plotman import interactive -from plotman import manager -from plotman import plot_util -from plotman import reporting + class PlotmanArgParser: def add_idprefix_arg(self, subparser): diff --git a/src/plotman/reporting.py b/src/plotman/reporting.py index 07649d94..2717ea4a 100644 --- a/src/plotman/reporting.py +++ b/src/plotman/reporting.py @@ -1,12 +1,11 @@ -import texttable as tt # from somewhere? +import math import os + import psutil -import math +import texttable as tt # from somewhere? + +from plotman import archive, job, manager, plot_util -from plotman import archive -from plotman import job -from plotman import manager -from plotman import plot_util def abbr_path(path, putative_prefix): if putative_prefix and path.startswith(putative_prefix): From 560831bb09bfe704f13612fbc390f3e8dad36c5f Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 18:45:27 -0400 Subject: [PATCH 04/26] adding [dev] and [test] extras, better isort conf --- setup.cfg | 17 ++++++++++++++++- src/plotman/_tests/archive_test.py | 3 +-- src/plotman/_tests/manager_test.py | 4 ++-- src/plotman/plotman.py | 3 +-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/setup.cfg b/setup.cfg index 0f2f6fc5..2877bc8e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,8 @@ project_urls = package_dir= =src packages=find: +setup_requires = + setuptools install_requires = psutil pyyaml @@ -45,7 +47,20 @@ where=src console_scripts = plotman = plotman.plotman:main +[options.extras_require] +dev = + %(test)s + isort +test = + pytest [options.data_files] config = config.yaml -bin = util/listlogs \ No newline at end of file +bin = util/listlogs + +[isort] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 \ No newline at end of file diff --git a/src/plotman/_tests/archive_test.py b/src/plotman/_tests/archive_test.py index 85b32d7e..6318045a 100755 --- a/src/plotman/_tests/archive_test.py +++ b/src/plotman/_tests/archive_test.py @@ -1,5 +1,4 @@ -import archive -import manager +from plotman import archive, manager def test_compute_priority(): diff --git a/src/plotman/_tests/manager_test.py b/src/plotman/_tests/manager_test.py index d492c70e..d7b199f7 100755 --- a/src/plotman/_tests/manager_test.py +++ b/src/plotman/_tests/manager_test.py @@ -1,10 +1,10 @@ # TODO: migrate away from unittest patch from unittest.mock import patch -import job -import manager import pytest +from plotman import job, manager + @pytest.fixture def sched_cfg(): diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index 3acd8df6..2017cd4c 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -14,8 +14,7 @@ import yaml # Plotman libraries -from plotman import (analyzer, archive, interactive, manager, plot_util, - reporting) +from plotman import analyzer, archive, interactive, manager, plot_util, reporting from plotman.job import Job From dfa6fcf60b8c31e956cfecac97cd4c748d40e939 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 19:03:14 -0400 Subject: [PATCH 05/26] slimming down MANIFEST.in --- MANIFEST.in | 4 +--- setup.cfg | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index ebe64d50..15548d38 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,3 @@ CHANGELOG.md -config.sample.yaml LICENSE -README.md -src/bash/listlogs \ No newline at end of file +README.md \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 2877bc8e..198c278e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,5 +62,4 @@ bin = util/listlogs multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 -use_parentheses=True line_length=88 \ No newline at end of file From 04d7e224f8dca59856cadd0a0d035cb337c1e968 Mon Sep 17 00:00:00 2001 From: Johannes Becker <31668498+jkbecker@users.noreply.github.com> Date: Wed, 31 Mar 2021 22:32:29 -0400 Subject: [PATCH 06/26] Update setup.cfg Co-authored-by: Kyle Altendorf --- setup.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 198c278e..cabad06b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,8 +33,6 @@ project_urls = package_dir= =src packages=find: -setup_requires = - setuptools install_requires = psutil pyyaml @@ -62,4 +60,4 @@ bin = util/listlogs multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 -line_length=88 \ No newline at end of file +line_length=88 From 396a45749a5dcf156e93b1f019932873e190c767 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 22:45:25 -0400 Subject: [PATCH 07/26] sorting test imports --- src/plotman/_tests/plot_util_test.py | 3 ++- src/plotman/_tests/reporting_test.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plotman/_tests/plot_util_test.py b/src/plotman/_tests/plot_util_test.py index 8bec3edc..d68941f9 100755 --- a/src/plotman/_tests/plot_util_test.py +++ b/src/plotman/_tests/plot_util_test.py @@ -2,7 +2,8 @@ import plot_util import pyfakefs -from plot_util import GB + +from plotman.plot_util import GB def test_human_format(): diff --git a/src/plotman/_tests/reporting_test.py b/src/plotman/_tests/reporting_test.py index ee09203b..c93e996f 100644 --- a/src/plotman/_tests/reporting_test.py +++ b/src/plotman/_tests/reporting_test.py @@ -2,7 +2,7 @@ import os from unittest.mock import patch -import reporting +from plotman import reporting def test_phases_str(): From 461690cc68b7c30fcf8fcdee69da42fc578e789d Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 22:46:18 -0400 Subject: [PATCH 08/26] pyfakefs required for tests --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 198c278e..8b5ae088 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,6 +53,7 @@ dev = isort test = pytest + pyfakefs [options.data_files] config = config.yaml From 251b36c8c2b36af3466586f1660cdc01a4e26a10 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Wed, 31 Mar 2021 22:47:23 -0400 Subject: [PATCH 09/26] sorting test imports --- src/plotman/_tests/plot_util_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plotman/_tests/plot_util_test.py b/src/plotman/_tests/plot_util_test.py index d68941f9..5b8ca2ad 100755 --- a/src/plotman/_tests/plot_util_test.py +++ b/src/plotman/_tests/plot_util_test.py @@ -1,8 +1,8 @@ import os -import plot_util import pyfakefs +from plotman import plot_util from plotman.plot_util import GB From 08acd294f429435fab553cc1cd80f74d41790a88 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 16:15:19 -0400 Subject: [PATCH 10/26] Implementing @altendky feedback --- setup.cfg | 4 +--- src/plotman/__main__.py | 10 ++++++++++ src/plotman/plotman.py | 3 --- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 src/plotman/__main__.py diff --git a/setup.cfg b/setup.cfg index 155b74df..5864fa7f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,6 @@ long-description = file: README.md long_description_content_type = text/markdown license = Apache 2.0 license-file = LICENSE -platform = any keywords = chia, blockchain, automation, process management classifiers = Development Status :: 3 - Alpha @@ -19,9 +18,8 @@ classifiers = Intended Audience :: Information Technology License :: OSI Approved :: Apache Software License Natural Language :: English - Operating System :: OS Independent + Operating System :: POSIX Programming Language :: Python :: 3 - Topic :: Office/Business :: Scheduling Topic :: System :: Monitoring Topic :: System :: Systems Administration Topic :: Utilities diff --git a/src/plotman/__main__.py b/src/plotman/__main__.py new file mode 100644 index 00000000..c6f25c3f --- /dev/null +++ b/src/plotman/__main__.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +from plotman import plotman + + +"""Plotman module launcher. +This is a shim that allows you to run plotman via + python3 -m plotman +""" +plotman.main() diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index 2017cd4c..43c9750d 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -197,6 +197,3 @@ def main(): elif args.cmd == 'resume': print('Resuming ' + job.plot_id) job.resume() - -if __name__ == "__main__": - main() From 5882b757ca9ff864f8ab3a34b245413cbdd07f61 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 16:39:33 -0400 Subject: [PATCH 11/26] adding version command --- src/plotman/plotman.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index 255fe938..34ad55b0 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -30,6 +30,8 @@ def parse_args(self): parser = argparse.ArgumentParser(description='Chia plotting manager.') sp = parser.add_subparsers(dest='cmd') + p_status = sp.add_parser('version', help='print the version') + p_status = sp.add_parser('status', help='show current plotting status') p_dirs = sp.add_parser('dirs', help='show directories info') @@ -86,6 +88,11 @@ def main(): pm_parser = PlotmanArgParser() args = pm_parser.parse_args() + + if args.cmd == 'version': + import pkg_resources + print(pkg_resources.get_distribution('plotman')) + exit() with open('config.yaml', 'r') as ymlfile: cfg = yaml.load(ymlfile, Loader=yaml.FullLoader) From afcd22010ed90886f1e3eb1210f4887e5e775a37 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 16:43:58 -0400 Subject: [PATCH 12/26] updating README --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e0a033e7..92b1055c 100644 --- a/README.md +++ b/README.md @@ -166,15 +166,25 @@ mode or the command line mode. There are many bugs and TODOs. -## Installation +Plotman will always look in the current directory for the `config.yaml` file +([see also](https://github.com/ericaltendorf/plotman/pull/61#issuecomment-812967363)). -This program requires `psutil`, `pyfakefs`, `pyyaml` and `texttable`. +## Installation Installation for Ubuntu 20.04: -``` -# Install Python package system -sudo apt-get install python3-pip +1. Plotman assumes that a functioning [Chia](https://github.com/Chia-Network/chia-blockchain) + installation is present on the system. Activate your `chia` environment by typing + `. /path/to/your/chia/install/activate`. +2. Then, clone the plotman repository (*note that these instructions are currently only + valid for the development branch*): -python3 -m pip install psutil pyfakefs pyyaml texttable -``` + git clone https://github.com/ericaltendorf/plotman.git -b development +3. Enter the Plotman directory + + cd plotman +4. Install plotman using pip: + + pip install . +5. That's it! You can now run Plotman by typing `plotman version` to verify its version. + Run `plotman --help` to learn about the available commands. From b181bd537d83149b8d5c654cc99dcfdf15e3ba53 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 16:44:18 -0400 Subject: [PATCH 13/26] adding install step to CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4754115..b712bc95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,10 @@ jobs: python -m pip install --upgrade pip setuptools wheel pip install tox + - name: Install Plotman + run: | + pip install . + - name: Prepare tox environment run: | tox --notest From ac53a5dcaa9cbeb6ddd2730d3aadd00a43e421b7 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 16:57:29 -0400 Subject: [PATCH 14/26] CI setup --- .github/workflows/ci.yml | 138 ++++++++++++++++++--------------------- tox.ini | 11 +--- 2 files changed, 68 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b712bc95..261dd114 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,68 +12,68 @@ defaults: shell: bash jobs: -# build: -# name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }} -# runs-on: ${{ matrix.os.runs-on }} -# strategy: -# fail-fast: false -# matrix: -# os: -# - name: Linux -# runs-on: ubuntu-latest -# python: -# - name: CPython 3.8 -# tox: py38 -# action: 3.8 -# task: -# - name: Build -# tox: build -# -# steps: -# - uses: actions/checkout@v2 -# with: -# ref: ${{ github.event.pull_request.head.sha }} -# - name: Set up ${{ matrix.python.name }} -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python.action }} -# -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip setuptools wheel -# python -m pip install build check-manifest twine -# -# - uses: twisted/python-info-action@v1 -# -# - name: Build -# run: | -# check-manifest --verbose . -# -# python -m build --sdist --outdir dist/ . -# -# mkdir empty/ -# cd empty -# -# tar -xvf ../dist/* -# cd * -# -# # build the wheel from the sdist -# python -m build --wheel --outdir ../../dist/ . -# cd ../../ -# -# twine check dist/* -# -# - name: Publish -# uses: actions/upload-artifact@v2 -# with: -# name: dist -# path: dist/ + build: + name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }} + runs-on: ${{ matrix.os.runs-on }} + strategy: + fail-fast: false + matrix: + os: + - name: Linux + runs-on: ubuntu-latest + python: + - name: CPython 3.8 + tox: py38 + action: 3.8 + task: + - name: Build + tox: build + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Set up ${{ matrix.python.name }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python.action }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install build check-manifest twine + + - uses: twisted/python-info-action@v1 + + - name: Build + run: | + check-manifest --verbose . + + python -m build --sdist --outdir dist/ . + + mkdir empty/ + cd empty + + tar -xvf ../dist/* + cd * + + # build the wheel from the sdist + python -m build --wheel --outdir ../../dist/ . + cd ../../ + + twine check dist/* + + - name: Publish + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/ test: name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }} runs-on: ${{ matrix.os.runs-on }} -# needs: -# - build + needs: + - build strategy: fail-fast: false matrix: @@ -111,11 +111,11 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} -# - name: Download package files -# uses: actions/download-artifact@v2 -# with: -# name: dist -# path: dist/ + - name: Download package files + uses: actions/download-artifact@v2 + with: + name: dist + path: dist/ - name: Set up ${{ matrix.python.name }} uses: actions/setup-python@v2 @@ -127,17 +127,9 @@ jobs: python -m pip install --upgrade pip setuptools wheel pip install tox - - name: Install Plotman - run: | - pip install . - - name: Prepare tox environment run: | - tox --notest - -# - name: Prepare tox environment -# run: | -# tox --notest --installpkg dist/*.whl + tox --notest --installpkg dist/*.whl - name: Runner info uses: twisted/python-info-action@v1 @@ -155,7 +147,7 @@ jobs: name: All runs-on: ubuntu-latest needs: -# - build + - build - test steps: - name: This diff --git a/tox.ini b/tox.ini index c174a6a8..42fecde6 100644 --- a/tox.ini +++ b/tox.ini @@ -3,15 +3,10 @@ envlist = test-py{36,37,38,39,py36,py37} [testenv] ;changedir = {envtmpdir} -skip_install = true [testenv:test-py{36,37,38,39,py36,py37}] -;extras = -; test -deps = - psutil - pyfakefs - pytest - texttable +extras = + test + commands = pytest --capture=no --verbose {toxinidir} From ff11e12f2f2d3e5329353dd2e0c5531b2d5e738d Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 17:02:34 -0400 Subject: [PATCH 15/26] Fixing MANIFEST.in (CI Build complaint) --- MANIFEST.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 15548d38..17e30f97 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,7 @@ -CHANGELOG.md -LICENSE -README.md \ No newline at end of file +include CHANGELOG.md +include LICENSE +include README.md +include *.md +include VERSION +include tox.ini +recursive-include src *.py \ No newline at end of file From 5686c3e606228682b64c9ec95b4d080eedca119a Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 17:06:53 -0400 Subject: [PATCH 16/26] mock is unhappy --- src/plotman/_tests/manager_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plotman/_tests/manager_test.py b/src/plotman/_tests/manager_test.py index ca9218a3..9048dc03 100755 --- a/src/plotman/_tests/manager_test.py +++ b/src/plotman/_tests/manager_test.py @@ -45,14 +45,14 @@ def test_permit_new_job_override_tmp_dir(sched_cfg, dir_cfg): [ (3, 1), (3, 2), (3, 3), (3, 6) ], '/mnt/tmp/04', sched_cfg, dir_cfg) -@patch('job.Job') +@patch('plotman.job.Job') def job_w_tmpdir_phase(tmpdir, phase, MockJob): j = MockJob() j.progress.return_value = phase j.tmpdir = tmpdir return j -@patch('job.Job') +@patch('plotman.job.Job') def job_w_dstdir_phase(dstdir, phase, MockJob): j = MockJob() j.progress.return_value = phase From 1cb15ffe37111c2034a1bb98c50ddc31a15d54d9 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Sun, 4 Apr 2021 17:11:56 -0400 Subject: [PATCH 17/26] stop mocking me --- src/plotman/_tests/reporting_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plotman/_tests/reporting_test.py b/src/plotman/_tests/reporting_test.py index 8c3f82df..b46dd873 100644 --- a/src/plotman/_tests/reporting_test.py +++ b/src/plotman/_tests/reporting_test.py @@ -24,7 +24,7 @@ def test_phases_str_none(): def test_job_viz_empty(): assert(reporting.job_viz([]) == '1 2 3 4 ') -@patch('job.Job') +@patch('plotman.job.Job') def job_w_phase(ph, MockJob): j = MockJob() j.progress.return_value = ph From 542a1841f8002c83d208f90b74cee8280749de61 Mon Sep 17 00:00:00 2001 From: Johannes Becker <31668498+jkbecker@users.noreply.github.com> Date: Mon, 5 Apr 2021 08:30:16 -0400 Subject: [PATCH 18/26] Update src/plotman/plotman.py typo, thx for noticing Co-authored-by: Kyle Altendorf --- src/plotman/plotman.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index 34ad55b0..a7515f93 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -30,7 +30,7 @@ def parse_args(self): parser = argparse.ArgumentParser(description='Chia plotting manager.') sp = parser.add_subparsers(dest='cmd') - p_status = sp.add_parser('version', help='print the version') + p_version = sp.add_parser('version', help='print the version') p_status = sp.add_parser('status', help='show current plotting status') From 1570e2ff5907acb826004fdea185ddb9fc2fecc6 Mon Sep 17 00:00:00 2001 From: Johannes Becker <31668498+jkbecker@users.noreply.github.com> Date: Mon, 5 Apr 2021 08:30:31 -0400 Subject: [PATCH 19/26] Update src/plotman/plotman.py Co-authored-by: Kyle Altendorf --- src/plotman/plotman.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plotman/plotman.py b/src/plotman/plotman.py index a7515f93..4e4ffe22 100755 --- a/src/plotman/plotman.py +++ b/src/plotman/plotman.py @@ -92,7 +92,7 @@ def main(): if args.cmd == 'version': import pkg_resources print(pkg_resources.get_distribution('plotman')) - exit() + return with open('config.yaml', 'r') as ymlfile: cfg = yaml.load(ymlfile, Loader=yaml.FullLoader) From 01d4d3fb04beefcf7f102cc1907f746be5eed5b7 Mon Sep 17 00:00:00 2001 From: Johannes Becker <31668498+jkbecker@users.noreply.github.com> Date: Mon, 5 Apr 2021 08:32:39 -0400 Subject: [PATCH 20/26] Update src/plotman/job.py Co-authored-by: Kyle Altendorf --- src/plotman/job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plotman/job.py b/src/plotman/job.py index 6f326da8..382c90b4 100644 --- a/src/plotman/job.py +++ b/src/plotman/job.py @@ -12,7 +12,7 @@ from enum import Enum, auto from subprocess import call -import psutil # apt-get install python-psutil +import psutil def job_phases_for_tmpdir(d, all_jobs): From 4f97bec65447e6051472bc293cace937583f6326 Mon Sep 17 00:00:00 2001 From: Johannes Becker <31668498+jkbecker@users.noreply.github.com> Date: Mon, 5 Apr 2021 08:36:42 -0400 Subject: [PATCH 21/26] no author-email Co-authored-by: Kyle Altendorf --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 5864fa7f..5499cdd4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,6 @@ name = plotman version = file: VERSION author = Eric Altendorf -author-email = PLACEHOLDER home-page = https://github.com/ericaltendorf/plotman description = Chia plotting manager long-description = file: README.md From 8b06c62c113c853b450de5fabc52d21cbac558f9 Mon Sep 17 00:00:00 2001 From: Johannes K Becker Date: Mon, 5 Apr 2021 09:08:57 -0400 Subject: [PATCH 22/26] Improved install procedure --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 92b1055c..5dae0f6f 100644 --- a/README.md +++ b/README.md @@ -176,15 +176,13 @@ Installation for Ubuntu 20.04: 1. Plotman assumes that a functioning [Chia](https://github.com/Chia-Network/chia-blockchain) installation is present on the system. Activate your `chia` environment by typing `. /path/to/your/chia/install/activate`. -2. Then, clone the plotman repository (*note that these instructions are currently only - valid for the development branch*): +2. Then, install Plotman using the following command: - git clone https://github.com/ericaltendorf/plotman.git -b development -3. Enter the Plotman directory + pip install git+https://github.com/ericaltendorf/plotman.git@development - cd plotman -4. Install plotman using pip: - - pip install . -5. That's it! You can now run Plotman by typing `plotman version` to verify its version. +3. That's it! You can now run Plotman by typing `plotman version` to verify its version. Run `plotman --help` to learn about the available commands. + +### Development note: + +If you are forking Plotman, simply replace the installation step with `pip install .[dev]` from the project root directory to install *your* version of plotman with test and development extras. \ No newline at end of file From 9810e3434fd0cee492801131cb5ca58a287173d5 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 5 Apr 2021 17:57:25 -0700 Subject: [PATCH 23/26] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5dae0f6f..3597e9f5 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ Plotman will always look in the current directory for the `config.yaml` file ## Installation -Installation for Ubuntu 20.04: +Installation for Linux: 1. Plotman assumes that a functioning [Chia](https://github.com/Chia-Network/chia-blockchain) installation is present on the system. Activate your `chia` environment by typing @@ -185,4 +185,4 @@ Installation for Ubuntu 20.04: ### Development note: -If you are forking Plotman, simply replace the installation step with `pip install .[dev]` from the project root directory to install *your* version of plotman with test and development extras. \ No newline at end of file +If you are forking Plotman, simply replace the installation step with `pip install .[dev]` from the project root directory to install *your* version of plotman with test and development extras. From ecd9d5b052d8eca45fb9e2c8a539fde8a274cc0b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 5 Apr 2021 20:58:44 -0400 Subject: [PATCH 24/26] add trailing EOLs --- .gitignore | 2 +- MANIFEST.in | 2 +- VERSION | 2 +- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 01d7f95b..82adb58b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ __pycache__ -venv \ No newline at end of file +venv diff --git a/MANIFEST.in b/MANIFEST.in index 17e30f97..169df8c4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,4 +4,4 @@ include README.md include *.md include VERSION include tox.ini -recursive-include src *.py \ No newline at end of file +recursive-include src *.py diff --git a/VERSION b/VERSION index 6da28dde..17e51c38 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.1 \ No newline at end of file +0.1.1 diff --git a/pyproject.toml b/pyproject.toml index 07de284a..9787c3bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" From 65797c0198d6be377d6967bd1135e9dce42e6091 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 5 Apr 2021 21:09:51 -0400 Subject: [PATCH 25/26] add a stubby setup.py for compatibility such as with --editable installation --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..056ba45d --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +import setuptools + + +setuptools.setup() From 34000cfac76418188a00c43d9f75239d9541b12c Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 6 Apr 2021 17:15:15 -0400 Subject: [PATCH 26/26] Update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3597e9f5..0ef599e4 100644 --- a/README.md +++ b/README.md @@ -175,14 +175,16 @@ Installation for Linux: 1. Plotman assumes that a functioning [Chia](https://github.com/Chia-Network/chia-blockchain) installation is present on the system. Activate your `chia` environment by typing - `. /path/to/your/chia/install/activate`. + `source /path/to/your/chia/install/activate`. 2. Then, install Plotman using the following command: - pip install git+https://github.com/ericaltendorf/plotman.git@development - -3. That's it! You can now run Plotman by typing `plotman version` to verify its version. + pip install git+https://github.com/ericaltendorf/plotman@development +3. Plotman will look for `config.yaml` in your current working directory when you run it. + You can find [an example configuration file](./config.yaml) in the project source that can be used + as a starting point. +5. That's it! You can now run Plotman by typing `plotman version` to verify its version. Run `plotman --help` to learn about the available commands. ### Development note: -If you are forking Plotman, simply replace the installation step with `pip install .[dev]` from the project root directory to install *your* version of plotman with test and development extras. +If you are forking Plotman, simply replace the installation step with `pip install --editable .[dev]` from the project root directory to install *your* version of plotman with test and development extras.