Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use skyvern temp to save tempfiles #1262

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

LawyZheng
Copy link
Collaborator

@LawyZheng LawyZheng commented Nov 26, 2024

Important

Refactor temporary file handling to use a configurable path in config.py, replacing tempfile usage with custom functions across the codebase.

  • Configuration:
    • Add TEMP_PATH to Settings in config.py for defining temporary file storage location.
    • Remove STREAMING_FILE_BASE_PATH from Settings.
  • File Handling:
    • Replace tempfile.NamedTemporaryFile with create_named_temporary_file() in files.py, s3.py, and block.py.
    • Replace tempfile.mkdtemp with make_temp_directory() in files.py, s3.py, and browser_factory.py.
    • Use get_skyvern_temp_dir() in local.py and s3.py for constructing file paths.
  • Functions:
    • Add create_folder_if_not_exist(), get_skyvern_temp_dir(), make_temp_directory(), and create_named_temporary_file() to files.py for managing temporary files and directories.

This description was created by Ellipsis for a7904a2. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to a7904a2 in 1 minute and 14 seconds

More details
  • Looked at 223 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. skyvern/forge/sdk/api/files.py:25
  • Draft comment:
    Consider adding error handling when writing to the temporary file to handle potential FileNotFoundError or PermissionError. This will make the function more robust.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. skyvern/forge/sdk/artifact/storage/s3.py:64
  • Draft comment:
    Consider adding error handling when writing to the temporary file to handle potential FileNotFoundError or PermissionError. This will make the function more robust. This comment also applies to similar usage in files.py.
  • Reason this comment was not posted:
    Marked as duplicate.
3. skyvern/forge/sdk/workflow/models/block.py:1059
  • Draft comment:
    Consider adding error handling when writing to the temporary file to handle potential FileNotFoundError or PermissionError. This will make the function more robust. This comment also applies to similar usage in files.py and s3.py.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_wZ1ixIYLOQ0T2giL


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped PR review on 38d94ce because no changed files had a supported extension. If you think this was in error, please contact us and we'll fix it right away.

@LawyZheng LawyZheng merged commit af25aee into main Nov 26, 2024
2 checks passed
@LawyZheng LawyZheng deleted the lawy/use-skyvern-temp-to-save-tempfile branch November 26, 2024 04:28
@n-sviridenko
Copy link

@LawyZheng


  File "/app/run_streaming.py", line 38, in <module>
    typer.run(main)

  File "/app/run_streaming.py", line 34, in main
    asyncio.run(run())

  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^

  File "/app/run_streaming.py", line 16, in run
    png_file_path = f"{SettingsManager.get_settings().STREAMING_FILE_BASE_PATH}/{file_name}"
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 856, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')

AttributeError: 'Settings' object has no attribute 'STREAMING_FILE_BASE_PATH'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants