Skip to content

Commit

Permalink
Merge pull request #930 from ericaltendorf/release/v0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky authored Sep 21, 2021
2 parents 9ba0c24 + 70e8a48 commit 1b7dfba
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 33 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.3] - 2021-09-19
### Fixed
- Regression in v0.5.2 where plotting processes that lack log files caused a traceback.
([#926](https://github.com/ericaltendorf/plotman/pull/926))
- Create the directory for the new disk spaces log file.
([#929](https://github.com/ericaltendorf/plotman/pull/929))
- Better handle non-interactive uses that had trouble while detecting the (non-existant) terminal size.
([#918](https://github.com/ericaltendorf/plotman/pull/918))

## [0.5.2] - 2021-09-12
### Fixed
- Temp files are correctly identified for cleanup.
([#912](https://github.com/ericaltendorf/plotman/pull/913))
([#912](https://github.com/ericaltendorf/plotman/pull/912))
- Correct where trailing `/` on dst directories resulted in them being considered unused.
([#920](https://github.com/ericaltendorf/plotman/pull/920))
### Added
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.2
0.5.3
7 changes: 5 additions & 2 deletions src/plotman/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@


def analyze(
logfilenames: typing.List[str], clipterminals: bool, bytmp: bool, bybitfield: bool
logfilenames: typing.List[str],
clipterminals: bool,
bytmp: bool,
bybitfield: bool,
columns: int,
) -> None:
data: typing.Dict[str, typing.Dict[str, typing.List[float]]] = {}
for logfilename in logfilenames:
Expand Down Expand Up @@ -165,7 +169,6 @@ def analyze(

tab.add_row(row)

(rows, columns) = os.popen("stty size", "r").read().split()
tab.set_max_width(int(columns))
s = tab.draw()
print(s)
8 changes: 1 addition & 7 deletions src/plotman/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def setup(self) -> None:
os.makedirs(self.plots, exist_ok=True)
os.makedirs(self.transfers, exist_ok=True)
os.makedirs(os.path.dirname(self.application), exist_ok=True)
os.makedirs(os.path.dirname(self.disk_spaces), exist_ok=True)

def create_plot_log_path(self, time: pendulum.DateTime) -> str:
return self._create_log_path(
Expand All @@ -343,13 +344,6 @@ def create_transfer_log_path(self, time: pendulum.DateTime) -> str:
group="transfer",
)

def create_tdisk_space_log_path(self, time: pendulum.DateTime) -> str:
return self._create_log_path(
time=time,
directory=self.disk_spaces,
group="disk_space",
)

def _create_log_path(
self, time: pendulum.DateTime, directory: str, group: str
) -> str:
Expand Down
16 changes: 11 additions & 5 deletions src/plotman/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import time
from datetime import datetime
import sys
import typing

import attr
Expand Down Expand Up @@ -105,7 +106,7 @@ class Job:

plotter: "plotman.plotters.Plotter"

logfile: str = ""
logfile: typing.Optional[str] = None
job_id: int = 0
proc: psutil.Process

Expand Down Expand Up @@ -189,10 +190,11 @@ def get_running_jobs(
plotter=plotter,
logroot=logroot,
)
# TODO: stop reloading every time...
with open(job.logfile, "rb") as f:
r = f.read()
job.plotter.update(chunk=r)
if job.logfile is not None:
# TODO: stop reloading every time...
with open(job.logfile, "rb") as f:
r = f.read()
job.plotter.update(chunk=r)
jobs.append(job)

return jobs
Expand Down Expand Up @@ -254,6 +256,10 @@ def status_str_long(self) -> str:
# )

def print_logs(self, follow: bool = False) -> None:
if self.logfile is None:
print("no log file available for this plotting process", file=sys.stderr)
return

with open(self.logfile, "r") as f:
if follow:
line = ""
Expand Down
26 changes: 17 additions & 9 deletions src/plotman/plotman.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ def parse_args(self) -> typing.Any:
return args


def get_term_width() -> int:
try:
(rows_string, columns_string) = os.popen("stty size", "r").read().split()
columns = int(columns_string)
except:
columns = 120 # 80 is typically too narrow. TODO: make a command line arg.
def get_term_width(cfg: configuration.PlotmanConfig) -> int:
default_columns = 120 # 80 is typically too narrow.
if cfg.user_interface.use_stty_size:
try:
(rows_string, columns_string) = os.popen("stty size", "r").read().split()
columns = int(columns_string)
except:
columns = default_columns
else:
columns = default_columns
return columns


Expand Down Expand Up @@ -293,7 +297,11 @@ def main() -> None:
elif args.cmd == "analyze":

analyzer.analyze(
args.logfile, args.clipterminals, args.bytmp, args.bybitfield
args.logfile,
args.clipterminals,
args.bytmp,
args.bybitfield,
get_term_width(cfg),
)

#
Expand All @@ -317,7 +325,7 @@ def main() -> None:
result = reporting.json_report(jobs)
else:
result = "{0}\n\n{1}\n\nUpdated at: {2}".format(
reporting.status_report(jobs, get_term_width()),
reporting.status_report(jobs, get_term_width(cfg)),
reporting.summary(jobs),
datetime.datetime.today().strftime("%c"),
)
Expand All @@ -335,7 +343,7 @@ def main() -> None:
cfg.directories,
cfg.archiving,
cfg.scheduling,
get_term_width(),
get_term_width(cfg),
)
)

Expand Down
19 changes: 11 additions & 8 deletions src/plotman/resources/plotman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# https://github.com/ericaltendorf/plotman/wiki/Configuration#versions
version: [2]

logging:
# One directory in which to store all plot job logs (the STDOUT/
# STDERR of all plot jobs). In order to monitor progress, plotman
# reads these logs on a regular basis, so using a fast drive is
# recommended.
plots: /home/chia/chia/logs
# transfers:
# application:
#logging:
# # One directory in which to store all plot job logs (the STDOUT/
# # STDERR of all plot jobs). In order to monitor progress, plotman
# # reads these logs on a regular basis, so using a fast drive is
# # recommended.
# # For Linux, these paths default to a directory under ~/.local/share/plotman/
# plots: <directory>
# transfers: <directory>
# # For Linux, these paths default to a file at ~/.cache/plotman/log/
# application: <file>
# disk_spaces: <file>

# Options for display and rendering
user_interface:
Expand Down

0 comments on commit 1b7dfba

Please sign in to comment.