MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / RunState

Class RunState

plain2code_state.py:8–62  ·  view source on GitHub ↗

Contains information about the identifiable state of the rendering process.

Source from the content-addressed store, hash-verified

6
7
8class RunState:
9 """Contains information about the identifiable state of the rendering process."""
10
11 def __init__(self, spec_filename: str, replay_with: Optional[str] = None):
12 self.replay: bool = replay_with is not None
13 self.render_succeeded: bool = False
14 self.render_cancelled: bool = False
15 self.render_generated_code_path: Optional[str] = None
16 self.rendered_functionalities: int = 0
17 if replay_with:
18 self.render_id: str = replay_with
19 else:
20 self.render_id: str = str(uuid.uuid4())
21 self.spec_filename: str = spec_filename
22 self.call_count: int = 0
23 self.unittest_batch_id: int = 0
24 self.render_time_accumulated: int = 0
25 self.last_render_start_timestamp: float = time.monotonic()
26 # Mirrored from the render state machine for crash reporting; not authoritative.
27 self.current_module: Optional[str] = None
28 self.current_frid: Optional[str] = None
29 self.current_render_state: Optional[str] = None
30 self.user_email: Optional[str] = None
31
32 def increment_call_count(self):
33 self.call_count += 1
34
35 def increment_unittest_batch_id(self):
36 self.unittest_batch_id += 1
37
38 def set_render_succeeded(self, succeeded: bool):
39 self.render_succeeded = succeeded
40
41 def set_render_cancelled(self):
42 self.render_cancelled = True
43
44 def set_render_generated_code_path(self, generated_code_path: str):
45 self.render_generated_code_path = generated_code_path
46
47 def increment_rendered_functionalities(self):
48 self.rendered_functionalities += 1
49
50 def add_to_render_time(self):
51 self.render_time_accumulated += int(time.monotonic() - self.last_render_start_timestamp)
52
53 def set_last_render_start_timestamp(self):
54 self.last_render_start_timestamp = time.monotonic()
55
56 def to_dict(self):
57 return {
58 "render_id": self.render_id,
59 "call_count": self.call_count,
60 "replay": self.replay,
61 "spec_filename": self.spec_filename,
62 }

Callers 3

mainFunction · 0.90

Calls

no outgoing calls