Skip to content

Commit

Permalink
Fix: Use correct ignore file for beta9 and beam cli commands (#818)
Browse files Browse the repository at this point in the history
Previously, commands would always get the default sdk settings. This was
caused because importing `sync.py` caused the default settings to be
loaded no matter what. Now, we don't set `_settings` in `sync.py` and
instead access it indirectly so that importing sync doesn't initialize
settings with defaults. When "beam" is included in the modules, we load
the beam config instead of the default beta9 config.

Old behavior:
```bash
~/Dev/beam/bs/endpoint ❯ beam deploy app.py:handler                                        
=> Building image 
=> Using cached image 
=> Syncing files 
Reading .beta9ignore file  # WRONG
```

New behavior: 
```bash
~/Dev/beam/bs/endpoint ❯ beam deploy app.py:handler                                     
=> Building image 
=> Using cached image 
=> Syncing files 
Reading .beamignore file  # CORRECT
```
  • Loading branch information
dleviminzi authored Dec 31, 2024
1 parent bc1a50e commit c7ad9cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "beta9"
version = "0.1.141"
version = "0.1.142"
description = ""
authors = ["beam.cloud <[email protected]>"]
packages = [
Expand Down
21 changes: 13 additions & 8 deletions sdk/src/beta9/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from .config import get_settings
from .env import is_local

_settings = get_settings()
_sync_lock = threading.Lock()

# Global workspace object id to signal to any other threads that the workspace has already been synced
Expand All @@ -44,9 +43,15 @@ def get_workspace_object_id() -> str:


CHUNK_SIZE = 1024 * 1024 * 4
IGNORE_FILE_NAME = f".{_settings.name}ignore".lower()
IGNORE_FILE_CONTENTS = f"""# Generated by {_settings.name} SDK
.{_settings.name.lower()}ignore


def ignore_file_name() -> str:
return f".{get_settings().name}ignore".lower()


def ignore_file_contents() -> str:
return f"""# Generated by {get_settings().name} SDK
.{get_settings().name.lower()}ignore
pyproject.toml
.git
.idea
Expand Down Expand Up @@ -93,7 +98,7 @@ def __init__(

@property
def ignore_file_path(self) -> Path:
return self.root_dir / IGNORE_FILE_NAME
return self.root_dir / ignore_file_name()

def _init_ignore_file(self) -> None:
if not is_local():
Expand All @@ -102,15 +107,15 @@ def _init_ignore_file(self) -> None:
if self.ignore_file_path.exists():
return

terminal.detail(f"Writing {IGNORE_FILE_NAME} file")
terminal.detail(f"Writing {ignore_file_name()} file")
with self.ignore_file_path.open(mode="w") as f:
f.writelines(IGNORE_FILE_CONTENTS)
f.writelines(ignore_file_contents())

def _read_ignore_file(self) -> list:
if not is_local():
return []

terminal.detail(f"Reading {IGNORE_FILE_NAME} file")
terminal.detail(f"Reading {ignore_file_name()} file")

patterns = []

Expand Down

0 comments on commit c7ad9cb

Please sign in to comment.