Skip to content

Commit 441aed5

Browse files
committed
rename methods
1 parent 7811dbb commit 441aed5

File tree

7 files changed

+44
-44
lines changed

7 files changed

+44
-44
lines changed

chia/_tests/plot_sync/test_plot_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ async def plot_sync_callback(self, peer_id: bytes32, delta: Optional[Delta]) ->
193193
assert path in delta.valid.additions
194194
plot = harvester.plot_manager.plots.get(Path(path), None)
195195
assert plot is not None
196-
assert plot.prover.get_filename_str() == delta.valid.additions[path].filename
196+
assert plot.prover.get_filename() == delta.valid.additions[path].filename
197197
assert plot.prover.get_size() == delta.valid.additions[path].size
198198
assert plot.prover.get_id() == delta.valid.additions[path].plot_id
199199
assert plot.prover.get_compression_level() == delta.valid.additions[path].compression_level
@@ -254,7 +254,7 @@ async def run_sync_test(self) -> None:
254254
assert expected.duplicates_delta.empty()
255255
for path, plot_info in plot_manager.plots.items():
256256
assert str(path) in receiver.plots()
257-
assert plot_info.prover.get_filename_str() == receiver.plots()[str(path)].filename
257+
assert plot_info.prover.get_filename() == receiver.plots()[str(path)].filename
258258
assert plot_info.prover.get_size() == receiver.plots()[str(path)].size
259259
assert plot_info.prover.get_id() == receiver.plots()[str(path)].plot_id
260260
assert plot_info.prover.get_compression_level() == receiver.plots()[str(path)].compression_level

chia/_tests/plot_sync/test_sync_simulated.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ async def run(
6969
initial: bool,
7070
) -> None:
7171
for plot_info in loaded:
72-
assert plot_info.prover.get_filename() not in self.plots
72+
assert plot_info.prover.get_filepath() not in self.plots
7373
for plot_info in removed:
74-
assert plot_info.prover.get_filename() in self.plots
74+
assert plot_info.prover.get_filepath() in self.plots
7575

7676
self.invalid = invalid
7777
self.keys_missing = keys_missing
7878
self.duplicates = duplicates
7979

80-
removed_paths: list[Path] = [p.prover.get_filename() for p in removed] if removed is not None else []
81-
invalid_dict: dict[Path, int] = {p.prover.get_filename(): 0 for p in self.invalid}
82-
keys_missing_set: set[Path] = {p.prover.get_filename() for p in self.keys_missing}
83-
duplicates_set: set[str] = {p.prover.get_filename_str() for p in self.duplicates}
80+
removed_paths: list[Path] = [p.prover.get_filepath() for p in removed] if removed is not None else []
81+
invalid_dict: dict[Path, int] = {p.prover.get_filepath(): 0 for p in self.invalid}
82+
keys_missing_set: set[Path] = {p.prover.get_filepath() for p in self.keys_missing}
83+
duplicates_set: set[str] = {p.prover.get_filename() for p in self.duplicates}
8484

8585
# Inject invalid plots into `PlotManager` of the harvester so that the callback calls below can use them
8686
# to sync them to the farmer.
@@ -91,7 +91,7 @@ async def run(
9191
# Inject duplicated plots into `PlotManager` of the harvester so that the callback calls below can use them
9292
# to sync them to the farmer.
9393
for plot_info in loaded:
94-
plot_path = Path(plot_info.prover.get_filename())
94+
plot_path = Path(plot_info.prover.get_filepath())
9595
self.harvester.plot_manager.plot_filename_paths[plot_path.name] = (str(plot_path.parent), set())
9696
for duplicate in duplicates_set:
9797
plot_path = Path(duplicate)
@@ -123,39 +123,39 @@ async def sync_done() -> bool:
123123
await time_out_assert(60, sync_done)
124124

125125
for plot_info in loaded:
126-
self.plots[plot_info.prover.get_filename()] = plot_info
126+
self.plots[plot_info.prover.get_filepath()] = plot_info
127127
for plot_info in removed:
128-
del self.plots[plot_info.prover.get_filename()]
128+
del self.plots[plot_info.prover.get_filepath()]
129129

130130
def validate_plot_sync(self) -> None:
131131
assert len(self.plots) == len(self.plot_sync_receiver.plots())
132132
assert len(self.invalid) == len(self.plot_sync_receiver.invalid())
133133
assert len(self.keys_missing) == len(self.plot_sync_receiver.keys_missing())
134134
for _, plot_info in self.plots.items():
135-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.invalid()
136-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.keys_missing()
137-
assert plot_info.prover.get_filename_str() in self.plot_sync_receiver.plots()
138-
synced_plot = self.plot_sync_receiver.plots()[plot_info.prover.get_filename_str()]
139-
assert plot_info.prover.get_filename_str() == synced_plot.filename
135+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.invalid()
136+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.keys_missing()
137+
assert plot_info.prover.get_filename() in self.plot_sync_receiver.plots()
138+
synced_plot = self.plot_sync_receiver.plots()[plot_info.prover.get_filename()]
139+
assert plot_info.prover.get_filename() == synced_plot.filename
140140
assert plot_info.pool_public_key == synced_plot.pool_public_key
141141
assert plot_info.pool_contract_puzzle_hash == synced_plot.pool_contract_puzzle_hash
142142
assert plot_info.plot_public_key == synced_plot.plot_public_key
143143
assert plot_info.file_size == synced_plot.file_size
144144
assert uint64(int(plot_info.time_modified)) == synced_plot.time_modified
145145
for plot_info in self.invalid:
146-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.plots()
147-
assert plot_info.prover.get_filename_str() in self.plot_sync_receiver.invalid()
148-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.keys_missing()
149-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.duplicates()
146+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.plots()
147+
assert plot_info.prover.get_filename() in self.plot_sync_receiver.invalid()
148+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.keys_missing()
149+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.duplicates()
150150
for plot_info in self.keys_missing:
151-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.plots()
152-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.invalid()
153-
assert plot_info.prover.get_filename_str() in self.plot_sync_receiver.keys_missing()
154-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.duplicates()
151+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.plots()
152+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.invalid()
153+
assert plot_info.prover.get_filename() in self.plot_sync_receiver.keys_missing()
154+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.duplicates()
155155
for plot_info in self.duplicates:
156-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.invalid()
157-
assert plot_info.prover.get_filename_str() not in self.plot_sync_receiver.keys_missing()
158-
assert plot_info.prover.get_filename_str() in self.plot_sync_receiver.duplicates()
156+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.invalid()
157+
assert plot_info.prover.get_filename() not in self.plot_sync_receiver.keys_missing()
158+
assert plot_info.prover.get_filename() in self.plot_sync_receiver.duplicates()
159159

160160

161161
@dataclass
@@ -417,16 +417,16 @@ async def test_sync_reset_cases(
417417
# Inject some data into `PlotManager` of the harvester so that we can validate the reset worked and triggered a
418418
# fresh sync of all available data of the plot manager
419419
for plot_info in plots[0:10]:
420-
test_data.plots[plot_info.prover.get_filename()] = plot_info
420+
test_data.plots[plot_info.prover.get_filepath()] = plot_info
421421
plot_manager.plots = test_data.plots
422422
test_data.invalid = plots[10:20]
423423
test_data.keys_missing = plots[20:30]
424424
test_data.plot_sync_receiver.simulate_error = simulate_error # type: ignore[attr-defined]
425425
sender: Sender = test_runner.test_data[0].plot_sync_sender
426426
started_sync_id: uint64 = uint64(0)
427427

428-
plot_manager.failed_to_open_filenames = {p.prover.get_filename(): 0 for p in test_data.invalid}
429-
plot_manager.no_key_filenames = {p.prover.get_filename() for p in test_data.keys_missing}
428+
plot_manager.failed_to_open_filenames = {p.prover.get_filepath(): 0 for p in test_data.invalid}
429+
plot_manager.no_key_filenames = {p.prover.get_filepath() for p in test_data.keys_missing}
430430

431431
async def wait_for_reset() -> bool:
432432
assert started_sync_id != 0

chia/_tests/plotting/test_plot_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def refresh_callback(self, event: PlotRefreshEvents, refresh_result: PlotRefresh
115115
for value in actual_value:
116116
if type(value) is PlotInfo:
117117
for plot_info in expected_list:
118-
if plot_info.prover.get_filename() == value.prover.get_filename():
118+
if plot_info.prover.get_filename() == value.prover.get_filepath():
119119
values_found += 1
120120
continue
121121
else:
@@ -507,7 +507,7 @@ async def test_plot_info_caching(environment, bt):
507507
await refresh_tester.run(expected_result)
508508
for path, plot_info in env.refresh_tester.plot_manager.plots.items():
509509
assert path in plot_manager.plots
510-
assert plot_manager.plots[path].prover.get_filename() == plot_info.prover.get_filename()
510+
assert plot_manager.plots[path].prover.get_filepath() == plot_info.prover.get_filepath()
511511
assert plot_manager.plots[path].prover.get_id() == plot_info.prover.get_id()
512512
assert plot_manager.plots[path].prover.get_memo() == plot_info.prover.get_memo()
513513
assert plot_manager.plots[path].prover.get_size() == plot_info.prover.get_size()

chia/_tests/plotting/test_prover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class TestProver:
1212
def test_v2_prover_init_with_nonexistent_file(self) -> None:
1313
prover = V2Prover("/nonexistent/path/test.plot2")
1414
assert prover.get_version() == PlotVersion.V2
15-
assert prover.get_filename() == Path("/nonexistent/path/test.plot2")
16-
assert prover.get_filename_str() == "/nonexistent/path/test.plot2"
15+
assert prover.get_filepath() == Path("/nonexistent/path/test.plot2")
16+
assert prover.get_filename() == "/nonexistent/path/test.plot2"
1717

1818
def test_v2_prover_get_size_raises_error(self) -> None:
1919
prover = V2Prover("/nonexistent/path/test.plot2")

chia/plot_sync/sender.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _convert_plot_info_list(plot_infos: list[PlotInfo]) -> list[Plot]:
3939
for plot_info in plot_infos:
4040
converted.append(
4141
Plot(
42-
filename=plot_info.prover.get_filename_str(),
42+
filename=plot_info.prover.get_filename(),
4343
size=plot_info.prover.get_size(),
4444
plot_id=plot_info.prover.get_id(),
4545
pool_public_key=plot_info.pool_public_key,

chia/plotting/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ def process_file(file_path: Path) -> Optional[PlotInfo]:
386386
with self.plot_filename_paths_lock:
387387
paths: Optional[tuple[str, set[str]]] = self.plot_filename_paths.get(file_path.name)
388388
if paths is None:
389-
paths = (str(Path(cache_entry.prover.get_filename()).parent), set())
389+
paths = (str(Path(cache_entry.prover.get_filepath()).parent), set())
390390
self.plot_filename_paths[file_path.name] = paths
391391
else:
392-
paths[1].add(str(Path(cache_entry.prover.get_filename()).parent))
392+
paths[1].add(str(Path(cache_entry.prover.get_filepath()).parent))
393393
log.warning(f"Have multiple copies of the plot {file_path.name} in {[paths[0], *paths[1]]}.")
394394
return None
395395

@@ -423,7 +423,7 @@ def process_file(file_path: Path) -> Optional[PlotInfo]:
423423
plots_refreshed: dict[Path, PlotInfo] = {}
424424
for new_plot in executor.map(process_file, plot_paths):
425425
if new_plot is not None:
426-
plots_refreshed[Path(new_plot.prover.get_filename())] = new_plot
426+
plots_refreshed[Path(new_plot.prover.get_filepath())] = new_plot
427427
self.plots.update(plots_refreshed)
428428

429429
result.duration = time.time() - start_time

chia/plotting/prover.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class PlotVersion(IntEnum):
2222

2323
class ProverProtocol(ABC):
2424
@abstractmethod
25-
def get_filename(self) -> Path:
25+
def get_filepath(self) -> Path:
2626
"""Returns the filename for the plot"""
2727

2828
@abstractmethod
29-
def get_filename_str(self) -> str:
29+
def get_filename(self) -> str:
3030
"""Returns the filename string for the plot"""
3131

3232
@abstractmethod
@@ -73,10 +73,10 @@ class V2Prover(ProverProtocol):
7373
def __init__(self, filename: str):
7474
self._filename = filename
7575

76-
def get_filename(self) -> Path:
76+
def get_filepath(self) -> Path:
7777
return Path(self._filename)
7878

79-
def get_filename_str(self) -> str:
79+
def get_filename(self) -> str:
8080
return str(self._filename)
8181

8282
def get_size(self) -> uint8:
@@ -122,10 +122,10 @@ class V1Prover(ProverProtocol):
122122
def __init__(self, disk_prover: DiskProver) -> None:
123123
self._disk_prover = disk_prover
124124

125-
def get_filename(self) -> Path:
125+
def get_filepath(self) -> Path:
126126
return Path(self._disk_prover.get_filename())
127127

128-
def get_filename_str(self) -> str:
128+
def get_filename(self) -> str:
129129
return str(self._disk_prover.get_filename())
130130

131131
def get_size(self) -> uint8:

0 commit comments

Comments
 (0)