-
Notifications
You must be signed in to change notification settings - Fork 5
test: copy_examples test
#65
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
Conversation
|
@sbillinge ready for review |
|
Looks good as long as all the edits were brought over correctly! |
|
@sbillinge compared them side-by-side and the two PRs are the same |
|
Let's then implement the method |
|
@sbillinge ready for review. All tests pass except one that captures the bad output. Im still figuring out how to capture the statement, but wanted to make a push so you can leave comments on function styling and such |
|
I've included a test for the forced overwrite copy of examples. |
|
this still seems to be failing tests |
|
@sbillinge Pytest is passing locally now but this is failing CI for some reason. I'm trying to debug on my fork cadenmyers13#8 and I can't quite figure out whats going on. There is a shell script that runs ( @Tieqiong Do you know what might be causing this? FYI, I forgot to pull from upstream before creating this branch so i had to merge the python 3.14 support 🤦♂️ |
|
@cadenmyers13 seems like tests for srreal and pyobjcryst didn't run, probably not compatible with python 3.14 resulting in installation issue. You can see the test env runs on 3.14, which roots from recent 3.14 update on |
|
We also are out of free credits. Even though CMI is open software, it turns out Mac and Windows builds are not free even then, and CMI running all it's examples burned through our allocation. This is also causing tests to fail, at least the merge to main tests |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
==========================================
+ Coverage 82.93% 83.27% +0.33%
==========================================
Files 13 12 -1
Lines 1313 1351 +38
==========================================
+ Hits 1089 1125 +36
- Misses 224 226 +2
🚀 New features to boost your workflow:
|
|
@Tieqiong Okay, i added
@sbillinge On another note, is this how the warning message should be handled/captured for the case when the user tries to copy to a pre-existing directory? |
|
warnings that are raised correctly should pass green in tests. We would like to write a test that tests that a warning is raised correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now except hte warning. We should think a bit about this. Let's say there is one file that is duplicate. Do we want the code to crash and not copy anything? Or do we want it to copy everything it can, but just not copy the duplicate and throw a warning? Which is better behavior?
@sbillinge I like copying everything it can and throw the warning. I like this because if the user wants a restart on a specific file, they can remove this file then run |
|
Ok, that is persuasive, I like it. Let's go with that. We just need all tests Green. We probably need a |
| False, | ||
| ), | ||
| ], | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an extra case to test if new files are copied and old files remain unchanged.
| if example_name == name: | ||
| return True | ||
| return False | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main update on recent push is the content below here.
I've also found this package called rich that allows you to print console outputs in color which is nice. This will be good for pretty printing for cmi print info because that will output a lot of text. Color will help separate the content.
|
@sbillinge ready for review. I've left some inline to highlight whats new on this recent push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good. Just a few comments.
| @pytest.mark.parametrize( | ||
| "expected_paths,force", | ||
| [ | ||
| ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please can you put comment lines here as # case 1: input is such and such. Expect so and so behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| Path("packA/ex2/solutions/script2.py"), | ||
| Path("packA/ex2/script3.py"), | ||
| ] | ||
| pm.copy_examples(["packA"], target_dir=case5dir, force=force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test looks good now.
src/diffpy/cmi/packsmanager.py
Outdated
| from pathlib import Path | ||
| from typing import List, Union | ||
|
|
||
| from rich.console import Console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be introducing a new dependency. Is it worth adding the bloat for this? Why not just print? If we can be convinced it is worth it we probably have to add rich to all the dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbillinge I was planning on using it for the print_info function (see image). it helps with separation. On second thought, I think we could also add it using ANSI color codes and get rid of the dependency. I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use rich if it is a nice package, but it is a bit like using pathlib.Path, if we like it, we may want to kind of start using it as a group standard. We could even choose nice colors!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbillinge I agree! here's examples of what the syntax would look like with and without rich.
with rich:
from rich.console import Console
console=Console()
console.print("[bold green]This text prints in bold green[/]")
without rich:
print("\033[32m This text prints in green \033[0m")
There's probably a way to print in bold with ANSI code too. I think rich has preset colors that are commonly used/are nice but we could probably add a config file to change these if we wanted. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind about the syntax, it is more whether we want to go there at all. Let's just do a print without any colors for now and merge the PR. We can make an issue to add rich formatting and have a discussion about it in the broader group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay done
|
@sbillinge ready for review. I removed
|
|
@sbillinge ready for review. removed colors |


cleaned up version of this PR: #60
closes: #56