Skip to content

2nd attempt at adding json exporting!#24

Closed
ArchooD2 wants to merge 8 commits into
mainfrom
json-exporter-v2
Closed

2nd attempt at adding json exporting!#24
ArchooD2 wants to merge 8 commits into
mainfrom
json-exporter-v2

Conversation

@ArchooD2

Copy link
Copy Markdown
Collaborator

Hope this looks right, still haven't added tests in the suite.

Copilot AI review requested due to automatic review settings June 16, 2025 02:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds JSON exporting functionality to the query tracking system, allowing log data to be written to a file if configured.

  • Introduces an export_log method in the core tracking class that exports log data as JSON.
  • Updates the configuration to include export_type and export_path options for JSON export.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pyquerytracker/core.py Adds JSON export functionality in the log tracking workflow.
pyquerytracker/config.py Introduces configuration settings for JSON export.
Comments suppressed due to low confidence (1)

pyquerytracker/core.py:102

  • Consider adding error handling for json.dump in case log_data includes non-serializable objects. This ensures that JSON export failures are caught and handled appropriately.
except Exception as e:

Comment thread pyquerytracker/core.py Outdated
@MuddyHope

MuddyHope commented Jun 16, 2025

Copy link
Copy Markdown
Owner

@ArchooD2, can you add a docstring or suppress the lint issue ? Also some test cases, once you are done.

@ArchooD2

Copy link
Copy Markdown
Collaborator Author

adding test cases

@MuddyHope

Copy link
Copy Markdown
Owner

There is another conflict. Will test it once you are done.

@ArchooD2

Copy link
Copy Markdown
Collaborator Author

Cool, added test case and reformatted with black and pylint testing 👍 Let me know if anything needs changing

@MuddyHope

MuddyHope commented Jun 16, 2025

Copy link
Copy Markdown
Owner

There are 2 files that have conflicts, can you resolve them? @ArchooD2

@ArchooD2

Copy link
Copy Markdown
Collaborator Author

Is that fully fixed?

Comment thread tests/test_core.py Outdated
Comment thread tests/test_core.py Outdated
export_path = tmp_path / "log.json"

# Monkeypatch the config to enable JSON export
config = get_config()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We won't be using get_config, we will be using configure, look at examples/core/with_config.py, can you modify the config.py also?

Comment thread pyquerytracker/core.py Outdated
Comment thread pyquerytracker/core.py Outdated
Comment thread pyquerytracker/core.py Outdated
Comment thread pyquerytracker/core.py Outdated
Moved json export testing to new file
Changed get_config patch in test to configure() call
No longer writes to os.path.dirname(None) (disables JsonExporter class entirely if None path supplied)
File writes should now be thread-safe
Changed export logic to use pathlib rather than os
Comment thread tests/exporter/test_json_exporter.py Outdated
@ArchooD2 ArchooD2 requested a review from MuddyHope June 16, 2025 23:25
@MuddyHope

Copy link
Copy Markdown
Owner

Thanks @ArchooD2, for you patience.

@MuddyHope

Copy link
Copy Markdown
Owner

Can you cherry-pick these commits by forking the repo and contributing?

image

@ArchooD2

Copy link
Copy Markdown
Collaborator Author

#36

@MuddyHope

Copy link
Copy Markdown
Owner

@ArchooD2, closing this PR.

@MuddyHope MuddyHope closed this Jun 17, 2025
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.

3 participants