Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

BugReport reporter #770

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
project = 'pyk'
author = 'Runtime Verification, Inc'
copyright = '2024, Runtime Verification, Inc'
version = '0.1.611'
release = '0.1.611'
version = '0.1.612'
release = '0.1.612'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.611
0.1.612
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pyk"
version = "0.1.611"
version = "0.1.612"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
30 changes: 25 additions & 5 deletions src/pyk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,17 @@ def abs_or_rel_to(path: Path, base: Path) -> Path:
return base / path


class BugReport:
class BugReportBase:
_bug_report: Path
_command_id: int
_defn_id: int
_file_remap: dict[str, str]

def __init__(self, bug_report: Path) -> None:
self._bug_report = bug_report.with_suffix('.tar')
self._bug_report = bug_report
self._command_id = 0
self._defn_id = 0
self._file_remap = {}
if self._bug_report.exists():
_LOGGER.warning(f'Bug report exists, removing: {self._bug_report}')
self._bug_report.unlink()

def add_file(self, finput: Path, arcname: Path) -> None:
if str(finput) not in self._file_remap:
Expand Down Expand Up @@ -524,3 +521,26 @@ def _remap_arg(_a: str) -> str:
shebang = '#!/usr/bin/env bash\nset -euxo pipefail\n'
self.add_file_contents(shebang + ' '.join(remapped_args) + '\n', arcname)
self._command_id += 1


class BugReport(BugReportBase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this hierarchy instead:

  • BugReportBase - abstract class without any actual implementation.
  • BugReport - same as before, but now implements BugReportBase.
  • BugReport2 - something that can instantiate a BugReporter for a prefix.
  • BugReporter - a BugReportBase that writes into a folder of an archive.

This is the easy part as so far, nothing breaks. The hard part is eliminating BugReport in favor of the new design, which will be a breaking change in pyk and in downstream projects.

We should only merge the PR with the new classes once we have a plan on how to manage the rest. To get the intuition of what needs to be changed, you can rename BugReport and see where the type checker complains.

def __init__(self, bug_report: Path) -> None:
bug_report = bug_report.with_suffix('.tar')
if bug_report.exists():
_LOGGER.warning(f'Bug report exists, removing: {bug_report}')
bug_report.unlink()
super().__init__(bug_report)

def reporter(self, prefix: str) -> BugReportBase:
class BugReporter(BugReportBase):
_prefix: Path

def __init__(self, bug_report: Path, prefix: Path) -> None:
super().__init__(bug_report)
self._prefix = prefix

def add_file(self, finput: Path, arcname: Path) -> None:
arcname = self._prefix / arcname
super().add_file(finput, arcname)

return BugReporter(self._bug_report, Path(prefix))
Loading