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

fix: Add parse_from_string method to BatchJob #1033

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

kwilsonmg
Copy link
Contributor

@kwilsonmg kwilsonmg commented Sep 30, 2024

BatchJob.parse_from_string() accomplishes the same function as parse_from_file() but takes the batch job result in-memory and uses that instead of having to have the intermediary step of writing the results to disk and reading them again.

This implements the feature request in #1031 .


Important

Adds parse_from_string() to BatchJob for parsing batch job results from a string.

  • New Method:
    • Adds parse_from_string() to BatchJob class in batch.py.
    • Parses batch job results from a string, similar to parse_from_file().
    • Returns a tuple of parsed results and error objects.
  • Feature Request:

This description was created by Ellipsis for 31d56db. 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 31d56db in 7 seconds

More details
  • Looked at 35 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. instructor/batch.py:81
  • Draft comment:
    The logic in parse_from_string is almost identical to parse_from_file. Consider refactoring to avoid code duplication by extracting the common logic into a separate method.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in parse_from_string and parse_from_file is almost identical, which suggests a potential for code reuse.
2. instructor/batch.py:100
  • Draft comment:
    Avoid using a broad except Exception clause. It can mask unexpected errors. Consider catching specific exceptions like KeyError, TypeError, or json.JSONDecodeError. This applies to parse_from_file as well.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The exception handling in parse_from_string is too broad, which can mask unexpected errors.
3. instructor/batch.py:81
  • Draft comment:
    The logic in parse_from_string is almost identical to parse_from_file. Consider refactoring to avoid code duplication, adhering to the DRY principle.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The code in parse_from_string and parse_from_file is almost identical, violating the DRY principle.

Workflow ID: wflow_ZT4GOYVDWY4iSRkb


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

@jxnl jxnl changed the title Add parse_from_string method to BatchJob fix: Add parse_from_string method to BatchJob Oct 4, 2024
BatchJob.parse_from_string() accomplishes the same function as parse_from_file() but takes the batch job result in-memory and uses that instead of having to have the intermediary step of writing the results to disk and reading them again.
@kwilsonmg
Copy link
Contributor Author

kwilsonmg commented Oct 6, 2024

@jxnl this was merged but this PR didn't go to "merged" status and remains open? Huh.

@jxnl jxnl merged commit aab61f5 into instructor-ai:main Oct 7, 2024
8 of 12 checks passed
@kwilsonmg kwilsonmg deleted the iss1031 branch October 7, 2024 04:56
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