Repository navigation
Csv refactor - #75
Csv refactor#75
Conversation
|
Karla Saur (@ksaur) This is a draft for early feedback on my solution. I will fix the merge conflicts and rebase my branch to main later today. |
Yes this is what we need, thank you! :) |
@microsoft-github-policy-service agree company="Microsoft" |
|
Karla Saur (@ksaur) Finally rebased main and refactored my commons module to fit with the new structure. Reran all tests locally. |
| except Exception as e: | ||
| self.logger.error(f"Error reading {path} {e}") | ||
| continue | ||
| try: |
There was a problem hiding this comment.
Since the utility function list_perf_event_log_files already checks for files that end in perf_event_log, this check (i.e. if statement) is redundant and no longer needed.
| csv_paths = list(self.data_dir.glob("**/*.csv")) | ||
| if csv_paths == []: | ||
| csv_paths = list_perf_event_log_files(self.data_dir) | ||
| if not csv_paths: |
There was a problem hiding this comment.
Nit. Changed the if statement to be more pythonic (i.e. empty lists are considered False).
There was a problem hiding this comment.
Thanks. FWIW, a handful of these got fixed in #85. I think if you merge main in you should see them get updated.
We also setup black formatting to handle some other items.
You could try to following to rebase your changes:
# get the latest configs from uptsream
git remote add upstream https://github.com/microsoft/vasim
git fetch upstream
git restore --source=upstream/main pyproject.toml setup.py .pre-commit-config.yaml
# get the new deps
pip install -U -e ".[dev]"
# reformat the files
isort .
black .
pydocstringformatter .
git commit -a -m "reformatting"
# now try and merge main and handle the hopefully smaller set of conflicts
git merge upstream/mainThere was a problem hiding this comment.
also, if you want one of us can tackle this part ...
There was a problem hiding this comment.
Brian Kroth (@bpkroth) Just read your comment. Thanks for the git commands; they make sense. I'll use them to set up my dev environment so that future PR's can catch any quality checks early and locally.
| raise FileNotFoundError(f'Error reading csvs from {self.data_dir}. Your csv_paths are empty.') | ||
|
|
||
| # Process data | ||
| # Read all data from file |
There was a problem hiding this comment.
Moving this comment further down to the line of code that I think where scale becomes an issue. Also created a new issue in GitHub to track this: #93
Karla Saur (ksaur)
left a comment
There was a problem hiding this comment.
Thanks so much for this PR, it will really help the users since the CSV stuff is the easiest thing to screw up! I think there is a license header that is missing, but once you pass the CI you are good to merge!
Anna Pavlenko (apavlen)
left a comment
There was a problem hiding this comment.
LGTM! please rebase and you might need to fix a few issues for merged linters (adding headers, maybe formatters)
| self.logger.error('Error: no csvs found in data_dir {}'.format(self.data_dir)) | ||
| raise SystemExit('Error: no csvs found in data_dir {}'.format(self.data_dir)) | ||
| if not list_perf_event_log_files(self.data_dir): | ||
| err_msg = f'Error: no csvs found in data_dir {self.data_dir}' |
There was a problem hiding this comment.
might fail with new linter rule of using %s format for logging instead of f-strings
Karla Saur (@ksaur) Looks like that I don't have permissions to merge PR's. Moreover, could you approve the workflows? |
|
The checks are failings with pylint formatting errors. Most likely you committed your changes before pre-commit hooks were pushed, so you didn't see warnings locally, but now it fails your build on GitHub. Can you please check output and update? |
|
let me see if there is a setting to approve the workflows so you can run them yourself, sorry about that! |
Karla Saur (@ksaur) , the current setup is that they run automatically after first contribution. |
Since changes were committed prior to merge that included those updated checks, you might also have to run the full suite like so: pre-commit run -aApologies for the extra steps. You started before we'd incorporated some of these. It should be easier/better in the future though. Let us know if you want help at all. Happy to take a stab at it. |
Mark Bonicillo (@bonicim) I tackled these for you. They were pretty minor. Karla Saur (@ksaur), Anna Pavlenko (@apavlen) I think this should be ready to merge now. |
thanks, Brian Kroth (@bpkroth). I would have fixed this myself, but I was stuck in meetings all this morning (East coast time). Appreciate the assist. |
No problem. Partially my fault for pushing all the coding practice stuff so I figure I can pitch in to help fix it. Thanks for your contribution! Cheers, |
Pull Request
Refactor how CSV's are processed (#18)
Add CSV reader utility function; refactor how classes process CSV files
Description
This PR adds a utility function that gets a list of all CSV files ending in
perf_event_loggiven a directory as aPathobject. Consequently, it replaces all the duplicate code that processes CSV files with that utility function.Type of Change
Indicate the type of change by choosing one (or more) of the following:
Testing
Tests were created for the utility function to handle three cases: 1) CSV files ending in
perf_event_log2) an empty directory and 3) a directory with JSON and CSV files not ending inperf_event_log. Also reran existing tests locally and they passed.Additional Notes (optional)
Add any additional context or information for reviewers.