Skip to content

Commit

Permalink
Improve conflict resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-baseten committed Jun 14, 2024
1 parent bbeedd1 commit 5aa51a5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 179 deletions.
51 changes: 40 additions & 11 deletions docs/chains/doc_gen/generate_reference.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# type: ignore # This tool is only for Marius.
"""Script to auot-generate the API reference for Truss Chains."""

import inspect
import pathlib
import shutil
import subprocess
import tempfile
from pathlib import Path

import truss_chains as chains
Expand All @@ -26,8 +26,8 @@

BUILDER = "mdx_adapter" # "html"
NON_PUBLIC_SYMBOLS = [
"truss_chains.definitions.AssetSpec",
"truss_chains.definitions.ComputeSpec",
# "truss_chains.definitions.AssetSpec",
# "truss_chains.definitions.ComputeSpec",
"truss_chains.deploy.ChainService",
]

Expand Down Expand Up @@ -60,20 +60,49 @@ def _clean_build_directory(build_dir: Path) -> None:
def _apply_patch(
original_file_path: str, patch_file_path: str, output_file_path: str
) -> None:
original_file = Path(original_file_path)
patch_file = Path(patch_file_path)
output_file = Path(output_file_path)

with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_output_file_path = Path(temp_file.name)

try:
result = subprocess.run(
["patch", original_file_path, "-o", output_file_path, patch_file_path],
subprocess.run(
[
"patch",
str(original_file),
"-o",
str(temp_output_file_path),
str(patch_file),
],
check=True,
capture_output=True,
text=True,
)
print(result.stdout)

# Copy temp file to final output if no errors
shutil.copy(temp_output_file_path, output_file)

except subprocess.CalledProcessError as e:
print("Patch failed with the following output:")
print(e.stdout)
print(e.stderr)
print("Launching meld for manual resolution...")
subprocess.run(["meld", original_file_path, output_file_path])
reject_file = temp_output_file_path.with_suffix(".rej")
if reject_file.exists():
print(f"Conflicts found, saved to {reject_file}")
subprocess.run(
[
"meld",
str(original_file_path),
str(output_file),
str(temp_output_file_path),
],
check=True,
)
else:
print(f"Patch failed: {e.stderr}")

finally:
if temp_output_file_path.exists():
temp_output_file_path.unlink()


def generate_sphinx_docs(
Expand Down
50 changes: 4 additions & 46 deletions docs/chains/doc_gen/generated-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,7 @@ for more details on caching.
Returns parsed and validated assets.

* **Return type:**
[*AssetSpec*](#truss_chains.definitions.AssetSpec)

## *class* `truss_chains.definitions.AssetSpec`

Bases: `pydantic.BaseModel`

Parsed and validated assets. See `Assets` for more information.

**Parameters:**

| Name | Type | Description |
|------|------|-------------|
| `secrets` | *dict[str,str]* | |
| `cached` | *list[ModelCache]* | |


#### cached *: list[ModelCache]*

#### secrets *: dict[str, str]*
*AssetSpec*

## *class* `truss_chains.ChainletBase`

Expand Down Expand Up @@ -184,31 +166,7 @@ two ways:
#### get_spec()

* **Return type:**
[*ComputeSpec*](#truss_chains.definitions.ComputeSpec)

## *class* `truss_chains.definitions.ComputeSpec`

Bases: `BaseModel`

Parsed and validated compute. See `Compute` for more information.

**Parameters:**

| Name | Type | Description |
|------|------|-------------|
| `cpu_count` | *int* | |
| `predict_concurrency` | *int* | |
| `memory` | *str* | |
| `accelerator` | *AcceleratorSpec* | |


#### accelerator *: AcceleratorSpec*

#### cpu_count *: int*

#### memory *: str*

#### predict_concurrency *: int*
*ComputeSpec*

## `truss_chains.depends`

Expand Down Expand Up @@ -470,12 +428,12 @@ class MyChainlet(chains.ChainletBase):
#### get_asset_spec()

* **Return type:**
[*AssetSpec*](#truss_chains.definitions.AssetSpec)
*AssetSpec*

#### get_compute_spec()

* **Return type:**
[*ComputeSpec*](#truss_chains.definitions.ComputeSpec)
*ComputeSpec*

#### name *: str | None*

Expand Down
Loading

0 comments on commit 5aa51a5

Please sign in to comment.