-
Notifications
You must be signed in to change notification settings - Fork 24
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
Restructure and Reorganize project #185
base: master
Are you sure you want to change the base?
Conversation
This is currently failing for an interesting reason. $ pwd
.../envs/refl1d/lib/python3.11/site-packages/refl1d
$ ls
fitplugin.py __init__.py lib/ main.py names.py __pycache__/ view/ webview/ Maybe @bmaranville or @pkienzle has some insight? EDIT: resolved using |
It looks like package discovery is disabled if we manually provide a list of packages in the https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#automatic-discovery |
I feel like the primary use of the refl1d library is to construct an Experiment object, each of which requires a Sample object and a Probe object, so having experiment.py and probe.py at the same level inside refl1d/models and sample-building stuff in a subfolder refl1d/models/sample/ doesn't seem to match the hierarchy implied in the class construction. Why not experiment.py in refl1d/ and then tools for constructing samples in refl1d/sample/ and probes in refl1d/probe/ ? flowchart BT
Sample --> Experiment
Probe --> Experiment
|
so that's similar to what i had in mind with this PR. the idea behind what i have so far is that experiment, probe, and sample, are all models of "things" that make up a particular instance refl1d project, rather than a literal representation of what's made up of what else, and that sample is a directory is that there are multiple "subtypes" of sample, whereas experiment and probe (along with instrument and fitproblem) are represented by single files, so there's not really anything else that would go into experiment could live at the top level, it just made sense to classify it as a model in the context of "python model representing a 'thing'". but we can definitely move some things around as it makes sense to |
Also, The backend chooser is just there to select which version of the fast calculations is used in the various places around the library that need to go fast. |
ah interesting, ok. my assumption was that it was choosing which backend was ultimately used to run the calculations as part of the fitting process. in that case, it might even make sense to just live at the root directory |
I just noticed there's an additional requirements.txt in |
That file is directly referenced by |
Interesting. It's possible it's actually redundant, I see the version in the template includes sphinx and sphinx-rtd, and is referenced as "dependencies required to build the docs. But ours just includes things like bumps, numpy, etc. which I assume aren't actually required to build the docs themselves? (I may be missing something), and we have sphinx listed as a dev dependency in our pyproject.toml |
I think you're right, it is redundant. Probably the |
other than that, this is ready for re-re-review |
Commented out replacing Tests working, updated with main - should be ready for review |
@@ -16,7 +16,7 @@ | |||
|
|||
# from refl1d.uncertainty import show_errors | |||
from refl1d.models.experiment import Experiment, ExperimentBase, MixedExperiment | |||
import refl1d.models.probe | |||
from refl1d.models.probe.probe import PolarizedNeutronProbe |
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.
If you wanted, this could be:
from refl1d.models import PolarizedNeutronProbe
Similarly, previous line could be
from refl1d.models import Experiment, ExperimentBase, MixedExperiment
@bmaranville slightly unrelated. |
I think the piece that was using it was moved to the bumps codebase... and then we switched to a different library to do the same thing... so yes, removable. |
for more information, see https://pre-commit.ci
@bmaranville looking at doc/guide/index.rst L94: Same thing with the |
I would just replace the PTFit with something like the amoeba fitter class, but I don't really know what |
this is also not in refl1d, would that be |
how are we feeling about this at the moment? |
I started running existing models with the restructured code, and the biggest observation I made is that the majority of them use functions that are not in Some of these are unnecessary - So, the takeaway is that the majority of existing scripts would break with this change, and fixing them would be fairly easy for one of the developers, but a big pain in the neck for users. The main reason I haven't pushed harder to get this merged is that the new folder structure still doesn't completely map onto the graph of how the modules work and interact - it is hard to sort them in this way, and there are many interconnections, and I don't think any folder structure can accurately represent this. The practical grouping of e.g. "this module has to do with probe stuff (building, calculating, using...)" is the best we can do. Do you feel like this meets the initial goals of the PR? Is it worth the cost to the users, of having to modify old scripts in order to have them work, which many of them will not know how to do? |
I do feel strongly that some sort of sensible grouping of modules is important, it's pretty common for things in one folder to interact with things in another folder and that doesn't really break any sense of logic imo, but it does make sense to, like you said, group things together at the very least in some way, ie (these modules relate to the probe, these modules relate to the sample, etc etc). Breakage could be mitigated by adding whatever we need to to Personally, I'm ok with things breaking now and then if it's a side effect of improving the code base and making it more maintainable/easier to understand - these things do happen from time to time, what's more important is providing a helpful path forward for users/developers. But again, that's just one developers opinion |
Restructures refl1d to house files together in folders related to their function/purpose
To Do:
MODULES
list assumes all files are top level apparently)