Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Docker container support.
See the [docker configuration wiki page](https://github.com/ericaltendorf/plotman/wiki/Docker-Configuration) for help setting it up.
([#783](https://github.com/ericaltendorf/plotman/pull/783))
- Plot sizes other than k32 are handled.
([#803](https://github.com/ericaltendorf/plotman/pull/803))

## [0.4.1] - 2021-06-11
### Fixed
Expand Down
10 changes: 7 additions & 3 deletions src/plotman/_tests/plot_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ def test_columns() -> None:
[ 1 ],
[ 2 ] ] )

def test_list_k32_plots(fs: pyfakefs.fake_filesystem.FakeFilesystem) -> None:
def test_list_plots(fs: pyfakefs.fake_filesystem.FakeFilesystem) -> None:
fs.create_file('/t/plot-k32-0.plot', st_size=108 * GB)
fs.create_file('/t/plot-k32-1.plot', st_size=108 * GB)
fs.create_file('/t/.plot-k32-2.plot', st_size=108 * GB)
fs.create_file('/t/plot-k32-3.plot.2.tmp', st_size=108 * GB)
fs.create_file('/t/plot-k32-4.plot', st_size=100 * GB)
fs.create_file('/t/plot-k32-5.plot', st_size=108 * GB)

assert (plot_util.list_k32_plots('/t/') ==
fs.create_file('/t/plot-k33-6.plot', st_size=108 * GB)
fs.create_file('/t/plot-k33-7.plot', st_size=216 * GB)

assert (plot_util.list_plots('/t/') ==
[ '/t/plot-k32-0.plot',
'/t/plot-k32-1.plot',
'/t/plot-k32-5.plot' ] )
'/t/plot-k32-5.plot',
'/t/plot-k33-7.plot' ] )


def test_get_plotsize() -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/plotman/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def archive(dir_cfg: configuration.Directories, arch_cfg: configuration.Archivin
dst_dir = dir_cfg.get_dst_directories()
for d in dst_dir:
ph = dir2ph.get(d, job.Phase(0, 0))
dir_plots = plot_util.list_k32_plots(d)
dir_plots = plot_util.list_plots(d)
gb_free = plot_util.df_b(d) / plot_util.GB
n_plots = len(dir_plots)
priority = compute_priority(ph, gb_free, n_plots)
Expand Down
15 changes: 7 additions & 8 deletions src/plotman/plot_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ def df_b(d: str) -> int:
usage = shutil.disk_usage(d)
return usage.free

def get_k32_plotsize() -> int:
return get_plotsize(32)

def get_plotsize(k: int) -> int:
return (int)(_get_plotsize_scaler(k) * k * pow(2, k))

Expand Down Expand Up @@ -54,18 +51,20 @@ def split_path_prefix(items: typing.List[str]) -> typing.Tuple[str, typing.List[
remainders = [ os.path.relpath(i, prefix) for i in items ]
return (prefix, remainders)

def list_k32_plots(d: str) -> typing.List[str]:
'List completed k32 plots in a directory (not recursive)'
def list_plots(d: str) -> typing.List[str]:
'List completed plots in a directory (not recursive)'
plots = []
for plot in os.listdir(d):
if re.match(r'^plot-k32-.*plot$', plot):
matches = re.search(r"^plot-k(\d*)-.*plot$", plot)
if matches is not None:
grps = matches.groups()
plot_k = int(grps[0])
plot = os.path.join(d, plot)
try:
if os.stat(plot).st_size > (0.95 * get_k32_plotsize()):
if os.stat(plot).st_size > (0.95 * get_plotsize(plot_k)):
plots.append(plot)
except FileNotFoundError:
continue

return plots

def column_wrap(
Expand Down
2 changes: 1 addition & 1 deletion src/plotman/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def dst_dir_report(jobs: typing.List[job.Job], dstdirs: typing.List[str], width:
eldest_ph = dir2oldphase.get(d, job.Phase(0, 0))
phases = job.job_phases_for_dstdir(d, jobs)

dir_plots = plot_util.list_k32_plots(d)
dir_plots = plot_util.list_plots(d)
gb_free = int(plot_util.df_b(d) / plot_util.GB)
n_plots = len(dir_plots)
priority = archive.compute_priority(eldest_ph, gb_free, n_plots)
Expand Down