-
Notifications
You must be signed in to change notification settings - Fork 218
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
Refactor/tests #1191
Refactor/tests #1191
Conversation
Codecov Report
@@ Coverage Diff @@
## devel #1191 +/- ##
==========================================
- Coverage 84.40% 83.66% -0.75%
==========================================
Files 65 66 +1
Lines 5497 5511 +14
Branches 1263 1265 +2
==========================================
- Hits 4640 4611 -29
- Misses 557 598 +41
- Partials 300 302 +2
Continue to review full report at Codecov.
|
I believe what @Midnighter meant in #974 was to move |
Okay. However, that will cause a bit of a problem since importing/using this in cobra without the source directory (as it is installed by a package) would be difficult. Two options for this are
I can use Docker to check it to make sure it is present and workable, including data, but I'd like a decision from the other devs on location please, if that's possible. |
Indeed, my goal there was to have a The load_model function should be the replacement for |
I think I see. |
It's a valid concern. I'm not against packaging some models, also so that users have the exact models that examples were run with. Please note that in normal use |
Is there any way to setup the package so that some example models are already loaded in the cache? I don't think so, and it might not be a good idea. Alternatively, a possible (but not great) idea is to add some edge cases to load_model, so if it gets "textbook", which isn't in any of the repositories, it will load it locally from cobra data. I'm just trying to think of users that are very new to cobrapy, and want to load some models to see behavior. |
It can be done as a post-installation step but it's a bad idea, I think, because it assumes that the cache directory can be written to (this is not always the case). Adding a utility function and distributing the models with the package is the best option, IMO. The only question is then if they should be in SBML or pickle format. |
I think we could get rid of the pickle ones because those are a pain to maintain anyways. I think having some manually validated JSON and YAML ones would be good though to reproduce bugs etc. I agree with using load_model just have to make sure it's a new release (not backwards compatible). The test models could act like a new provider "local" or "cobrapy" similar to the bio models one. |
Are the mini models validated? Or I could copy the mini models manually to src/data, and those would be examples. So, load_models should have a repository like BiggModels which will be cobrapy, and that will use import_resources to import files. I think import_resources makes sure that however the users install the package, the data files are available. |
I fixed all the usages of create_test_model in the code examples. I'd be happy to fix the python notebooks, but can you please tell me what needs to happen? Thank you |
9350013
to
0acc4c9
Compare
Dear @akaviaLab, I would love to get this one and your other works merged. I tried to send you an email in order to set up a call to discuss this and the compartments PR but it came back with access denied. Can you please write to me or head over to https://gitter.im/opencobra/cobrapy where we can talk a bit more disconnected from code. |
@Midnighter Can we maybe take this opportunity to have our how-to Jupyter notebooks hosted on Binder ? I believe this will let new users to play around easily with cobrapy without hitting Python and related hurdles (we have seen quite a few 😅).
@cdiener Would that be a good reason to have a separate repository for them or do we continue with as it is now? |
Yes, can't remember where but Binder was mentioned and approved before by everyone involved. Just™️ need to do it 😉 |
Okay then I can take a stab at it in a few days 😁 |
@Midnighter Posted on gitter |
f32f611
to
fd359c1
Compare
All the notebook files done, except for faq.ipynb, which had functions I couldn't figure out. |
Yes of course. I would have waited anyway to get this PR merged. 😄 |
@synchon Great! |
documentation_builder/faq.ipynb
Outdated
"import cobra.test\n", | ||
"model = cobra.test.create_test_model()\n", | ||
"import cobra.io\n", | ||
"model = cobra.io.load_model(\"iYS1720\")\n", | ||
"\n", | ||
"for metabolite in model.metabolites:\n", | ||
" metabolite.id = \"test_\" + metabolite.id\n", |
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.
Would be nice to use f-string here to keep up with modern Python.
@akaviaLab One comment about the section Also, this line Any other enhancements, can be tackled later in a different PR later. |
fd359c1
to
bc0781b
Compare
Fixed comments. Set it up to be based on the most recent version of #1208 so it can be merged afterwards. If anything else is merged before this is done. I will rebase it. |
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.
Looks good. Thanks for the effort!
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.
Fixed your comments. When the review is done, I will merge the changes to the mat file and resolve conflict - not doing it now, since it will break conversations.
9c47562
to
b4bc3a6
Compare
No, that actually sounds good to me. |
I see now that you moved things to |
Check a few commits down
First I moved to stc/tests and then I moved to /tests
…On Fri., Apr. 29, 2022, 6:25 a.m. Moritz E. Beber, ***@***.***> wrote:
I see now that you moved things to /src/tests rather than /tests. Would
it have a huge impact on the other commits if you changed that now?
—
Reply to this email directly, view it on GitHub
<#1191 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQYYZXZSTSCVSC3YRCKP7DVHO2I5ANCNFSM5ROKAPJQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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.
Phew, thank you so much for tackling this 🙂 I have a few more suggestions but overall it looks very good.
One bigger point is the exact models that we want to distribute with COBRApy. Seems like only the SBML files are needed there but maybe I overlooked something.
We should also look at including jupytext because those notebooks diffs are just painful. That's not for this PR, though.
@@ -79,8 +79,8 @@ where = src | |||
|
|||
[options.package_data] | |||
cobra = | |||
io/*.json | |||
test/data/* | |||
data/* |
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 would like to reduce the models that we distribute with the package. Most of those are only really useful for testing and should be part of the repository but not the distributed Python package, I 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.
Essentially, keep all SBML models for the examples and the others should be moved into a tests/data
directory or so.
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.
Hmm. I kept yaml, json, pickle and mat in the mini model format, just so we can show what they're supposed to look like.
I can definitely delete iJO1366.pickle.
As for the mini models - I'll agree to what you want.
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.
Fair enough, they hardly hurt. Then just remove the pickle file, please.
Co-authored-by: Moritz E. Beber <midnighter@posteo.net>
using tmp_path instead of py.test (need to remove os.join in later PR)
Looks good to me now. As soon as @synchon is happy, we can merge it. Cheers @akaviaLab |
Might need to remove test_all
I was waiting in that
…On Fri., Apr. 29, 2022, 10:30 a.m. Moritz E. Beber, < ***@***.***> wrote:
Looks good to me now. As soon as @synchon <https://github.com/synchon> is
happy, we can merge it. Cheers @akaviaLab <https://github.com/akaviaLab>
—
Reply to this email directly, view it on GitHub
<#1191 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQYYZTT5UFVEO4PGEAPYWTVHPW7DANCNFSM5ROKAPJQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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.
Perfect! Let's merge this. 🎉
@Midnighter can we make a release after merging this PR? |
Sure
Yep, please do. |
Move the test suite from src/cobra/test to src/tests. Also removed init.py from the test suite.
Moved the test suite out of the source tree
Looks like this broke the test suite. Odd. Tox worked on my computer.