Skip to content

Commit

Permalink
styling: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zt committed Nov 14, 2024
1 parent adbb4a5 commit 83c9363
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
62 changes: 32 additions & 30 deletions collect_script.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
import platform
import sys
import subprocess
import traceback
import sys


def get_os_info():
return {
'system': platform.system(),
'node': platform.node(),
'release': platform.release(),
'version': platform.version(),
'machine': platform.machine(),
'processor': platform.processor(),
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
"processor": platform.processor(),
}


def get_python_info():
return {
'implementation': platform.python_implementation(),
'version': platform.python_version(),
'compiler': platform.python_compiler(),
"implementation": platform.python_implementation(),
"version": platform.python_version(),
"compiler": platform.python_compiler(),
}


def get_pip_list():
try:
result = subprocess.run([sys.executable, '-m', 'pip', 'list'], capture_output=True, text=True)
if result.returncode == 0:
return result.stdout
else:
return f"Failed to get pip list: {result.stderr}"
except Exception as e:
return f"An error occurred: {str(e)}"

def write_to_log_file(content, filename='env_output.log'):
try:
with open(filename, 'w') as file:
file.write(content)
except Exception as e:
print(f"Error writing to file {filename}: {e}")
traceback.print_exc()
result = subprocess.run(
[sys.executable, "-m", "pip", "list"],
capture_output=True,
text=True,
check=False,
)
if result.returncode == 0:
return result.stdout

return f"Failed to get pip list: {result.stderr}"


def write_to_log_file(content, filename="env_output.log"):
with open(filename, "w") as file:
file.write(content)


def main():
os_info = get_os_info()
python_info = get_python_info()
pip_list = get_pip_list()


content = "Operating System Information:\n"
for key, value in os_info.items():
content += f"{key}: {value}\n"
Expand All @@ -56,10 +57,11 @@ def main():
content += pip_list

# stdout
print(content)
print(content) # noqa: T201

# file
write_to_log_file(content)


if __name__ == "__main__":
main()
main()
8 changes: 2 additions & 6 deletions examples/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ async def main() -> None:
)

# Use local pybox manager for development and testing
pybox_manager = LocalPyBoxManager(
profile_dir=DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR
)
pybox_manager = LocalPyBoxManager(profile_dir=DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR)

agent = create_tablegpt_graph(
llm=llm,
Expand All @@ -44,9 +42,7 @@ async def main() -> None:
attachment_msg = HumanMessage(
content="",
# The dataset can be viewed in examples/datasets/titanic.csv.
additional_kwargs={
"attachments": [Attachment(filename="examples/datasets/titanic.csv")]
},
additional_kwargs={"attachments": [Attachment(filename="examples/datasets/titanic.csv")]},
)
await agent.ainvoke(
input={
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@ exclude_lines = [
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
"ipython"
]
# Allow lines to be as long as 120.
line-length = 120
4 changes: 1 addition & 3 deletions src/tablegpt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import sys

DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR = os.path.join(
sys.prefix, "share/ipykernel/profile/tablegpt"
)
DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR = os.path.join(sys.prefix, "share/ipykernel/profile/tablegpt")

0 comments on commit 83c9363

Please sign in to comment.