Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _save_html(self, html_data: str) -> str:
"""Save html data to a file."""
filename = f"{uuid.uuid4().hex}.html"
path = os.path.join(str(self._output_dir), filename)
with open(path, "w") as f:
with open(path, "w", encoding="utf-8") as f:
f.write(html_data)
return os.path.abspath(path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
# Load the previously recorded messages and responses from disk.
self.logger.info("Replay mode enabled.\nRetrieving session from: " + self.session_file_path)
try:
with open(self.session_file_path, "r") as f:
with open(self.session_file_path, "r", encoding="utf-8") as f:
self.records = json.load(f)
except Exception as e:
error_str = f"\nFailed to load recorded session: '{self.session_file_path}': {e}"
Expand Down Expand Up @@ -211,7 +211,7 @@ def finalize(self) -> None:
# Create the directory if it doesn't exist.
os.makedirs(os.path.dirname(self.session_file_path), exist_ok=True)
# Write the records to disk.
with open(self.session_file_path, "w") as f:
with open(self.session_file_path, "w", encoding="utf-8") as f:
json.dump(self.records, f, indent=2)
self.logger.info("\nRecorded session was saved to: " + self.session_file_path)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def finalize(self) -> None:
# Write the hash and other details to a file.
hash_str, num_files, num_subdirs = hash_directory(self.log_dir)
hash_path = os.path.join(self.log_dir, "hash.txt")
with open(hash_path, "w") as f:
with open(hash_path, "w", encoding="utf-8") as f:
f.write(hash_str)
f.write("\n")
f.write("{} files\n".format(num_files))
Expand Down Expand Up @@ -386,7 +386,7 @@ def flush(self, finished: bool = False) -> None:
return
# Create a call tree of the log.
call_tree_path = os.path.join(self.log_dir, self.name + ".html")
with open(call_tree_path, "w") as f:
with open(call_tree_path, "w", encoding="utf-8") as f:
f.write(_html_opening("0 Call Tree", finished=finished))
f.write(f"<h3>{self.name}</h3>")
f.write("\n")
Expand Down Expand Up @@ -498,7 +498,7 @@ def flush(self) -> None:
Writes the HTML page to disk.
"""
page_path = os.path.join(self.page_logger.log_dir, self.index_str + ".html")
with open(page_path, "w") as f:
with open(page_path, "w", encoding="utf-8") as f:
f.write(_html_opening(self.file_title, finished=self.finished))
f.write(f"<h3>{self.file_title}</h3>\n")
for line in self.lines:
Expand Down
2 changes: 1 addition & 1 deletion python/packages/autogen-studio/autogenstudio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def ui(

# Create temporary env file to share configuration with uvicorn workers
env_file_path = get_env_file_path()
with open(env_file_path, "w") as temp_env:
with open(env_file_path, "w", encoding="utf-8") as temp_env:
for key, value in env_vars.items():
temp_env.write(f"{key}={value}\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _update_configuration(self) -> None:

# Update alembic.ini
config_content = self._generate_alembic_ini_content()
with open(self.alembic_ini_path, "w") as f:
with open(self.alembic_ini_path, "w", encoding="utf-8") as f:
f.write(config_content)

# Update env.py
Expand Down Expand Up @@ -115,7 +115,7 @@ def _initialize_alembic(self) -> bool:

# Create initial config file for alembic init
config_content = self._generate_alembic_ini_content()
with open(self.alembic_ini_path, "w") as f:
with open(self.alembic_ini_path, "w", encoding="utf-8") as f:
f.write(config_content)

# Use the config we just created
Expand Down Expand Up @@ -187,7 +187,7 @@ def run_migrations_online() -> None:
else:
run_migrations_online()"""

with open(env_path, "w") as f:
with open(env_path, "w", encoding="utf-8") as f:
f.write(content)

def _generate_alembic_ini_content(self) -> str:
Expand Down Expand Up @@ -239,7 +239,7 @@ def update_script_template(self):
"""Update the Alembic script template to include SQLModel."""
template_path = self.alembic_dir / "script.py.mako"
try:
with open(template_path, "r") as f:
with open(template_path, "r", encoding="utf-8") as f:
content = f.read()

# Add sqlmodel import to imports section
Expand All @@ -248,7 +248,7 @@ def update_script_template(self):

content = content.replace(import_section, new_imports)

with open(template_path, "w") as f:
with open(template_path, "w", encoding="utf-8") as f:
f.write(content)

return True
Expand All @@ -265,7 +265,7 @@ def _update_env_py(self, env_path: Path) -> None:
self._create_minimal_env_py(env_path)
return
try:
with open(env_path, "r") as f:
with open(env_path, "r", encoding="utf-8") as f:
content = f.read()

# Add SQLModel import if not present
Expand Down Expand Up @@ -303,7 +303,7 @@ def _update_env_py(self, env_path: Path) -> None:
)""",
)

with open(env_path, "w") as f:
with open(env_path, "w", encoding="utf-8") as f:
f.write(content)
except Exception as e:
logger.error(f"Failed to update env.py: {e}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,5 +630,5 @@ def create_default_lite_team():
gallery = create_default_gallery()

# Save to file
with open("gallery_default.json", "w") as f:
with open("gallery_default.json", "w", encoding="utf-8") as f:
f.write(gallery.model_dump_json(indent=2))
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _setup_environment(self) -> str:
}

env_file_path = self._get_env_file_path()
with open(env_file_path, "w") as temp_env:
with open(env_file_path, "w", encoding="utf-8") as temp_env:
for key, value in env_vars.items():
temp_env.write(f"{key}={value}\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def is_valid_token(self, token: str) -> bool:
def from_yaml(cls, yaml_path: str) -> Self:
"""Create AuthManager from YAML config file."""
try:
with open(yaml_path, "r") as f:
with open(yaml_path, "r", encoding="utf-8") as f:
config_data = yaml.safe_load(f)
config = AuthConfig(**config_data)
return cls(config)
Expand Down