Skip to content
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

Use scooby for Versions #792

Merged
merged 13 commits into from Feb 20, 2020
Merged

Use scooby for Versions #792

merged 13 commits into from Feb 20, 2020

Conversation

prisae
Copy link
Member

@prisae prisae commented Jul 1, 2019

Use scooby internally for Versions. Now that scooby exists (thanks @banesullivan ) we should use it to simplify our lives. This removes lots of code from SimPEG, and will make maintenance easier down the road.

It is a bit a shame this comes only a few days after https://github.com/simpeg/simpeg/releases/tag/0.11.5 - but the development of scooby came a bit unexpected and fast.

However, there is absolutely NO change to the API / for the user. Everything remains the same.

In the end, the work we did with Versions in SimPEG (and in empymod/emg3d) all led to scooby, so it was well invested time ;-)

@prisae
Copy link
Member Author

prisae commented Jul 1, 2019

Btw, what do you think about having the same in discretize too? Now it would just mean a few lines of code...

@prisae prisae requested a review from lheagy July 1, 2019 07:37
@banesullivan
Copy link
Member

banesullivan commented Jul 1, 2019

Or what if it were only in discretize (and SimPEG called discretize's function for backwards compatibility)?

@prisae
Copy link
Member Author

prisae commented Jul 1, 2019

I changed

**Parameters**

to

Parameters
----------

I assume SimPEG is moving to numpydoc-style too, right?

@prisae
Copy link
Member Author

prisae commented Jul 1, 2019

Or what if it were only in discretize (and SimPEG called discretize's function for backwards compatibility)?

No, I don't think that is good. SimPEG is the main package. So it should have it. It is where everything comes together. discretize could have it too, as it can be used standalone, but not necessary. Because always when you use discretize then you will use something else too; e.g. SimPEG, or emg3d, or similar. And those tools should have it, IMO.

@banesullivan
Copy link
Member

banesullivan commented Jul 1, 2019

That makes sense so that SimPEG could specify specific packages and hardware which might not be relevant to other packages leveraging discretize.

@codecov
Copy link

codecov bot commented Jul 1, 2019

Codecov Report

Merging #792 into simulation will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           simulation     #792   +/-   ##
===========================================
  Coverage       71.22%   71.22%           
===========================================
  Files             118      118           
  Lines           19092    19092           
===========================================
  Hits            13599    13599           
  Misses           5493     5493

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 743f380...0f83e38. Read the comment docs.

@prisae
Copy link
Member Author

prisae commented Jul 1, 2019

We might think of renaming it from Versions to Report. This would be backwards incompatible (again), so it would have to be before #786 .

The reason is that @banesullivan and I think/hope/expect that scooby will become more widely adapted, and in scooby it is called Report (in the end, it does a bit more than only showing the versions). So it might become common that modules have a module.Report()-instance, and then it might be useful if SimPEG follows that.

Just thinking out loud, ideas/opinions welcome.

Copy link
Member

@lheagy lheagy left a comment

Choose a reason for hiding this comment

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

Thanks @prisae and @banesullivan for making this happen 🎉

Just one comment wrt making it a soft dependency rather than putting it in the setup.py. Other than that, this looks great!

Also 👍 from me on renaming to be consistent with scooby going forwards. It is a straightforward change in people's code, so might as well take care of it right away

setup.py Outdated
@@ -43,6 +43,7 @@
'vectormath>=0.2.0',
'discretize>=0.4.0',
'geoana>=0.0.4'
'scooby>=0.3.0',
Copy link
Member

@lheagy lheagy Jul 2, 2019

Choose a reason for hiding this comment

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

What do you think of making this a soft dependency? Since it isn't strictly necessary for running simulations or inversions with SimPEG, I would be inclined to make it a soft rather than a hard dependency

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

Yes, I was thinking about making it a soft dependency just like matplotlib in discretize. I opted not to, as scooby is tiny compared to matplotlib.

I'll implement that! If not today than later in the week.

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

A very quick implementation, not really tested yet...

@banesullivan
Copy link
Member

banesullivan commented Jul 2, 2019

My input, FWIW: while yes, we are still house-training scooby as it's just a puppy of a project and you might not want users to be forced to install something like that, I went ahead and made scooby a hard dependency of PyVista and plan to make it so with other projects I work on.

Why?

Lately, PyVista has been gaining a lot of users that don't have a strong Python background and they've been happy to report bugs/generate issues but it was becoming an challenge to work with numerous users to report everything we needed to know about the environment and the computer. My solution: have scooby as a hard dependency so that as soon as a user reports a bug, we have them simply run pyvista.Report() and it'll just work (as having non-Python-aficionados install a new library was too cumbersome at times and they might not follow up on the issue).

So I guess scooby started as a reproducibility tool and has morphed into more of a bug-reporting tool for how I use it at least.

Edit: a minority of our users leverage anaconda, so that's really where the issue arose

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

@banesullivan thanks for the input. @lheagy I can leave the soft dependency in or make it hard again, depending on what you folks want. Maybe you can raise it today at the meeting?

Either way: The requires-function could be useful for other soft dependencies too, so it should not live in printinfo. I moved it into codeutils and renamed it to requires_module, as a requires exists already in the same file for variables.

Also, printinfo (the old Version), was quite large, so a separate file was justified. Now, with scooby, it is a tiny thing. So I moved it into codeutils too, removing the file printinfo.py altogether.

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

There is actually a much simpler way in this case than requires_module:

# scooby is a soft dependency for SimPEG
try:
    from scooby import Report as ScoobyReport
except ImportError:
    class ScoobyReport:
        def __init__(self, additional, core, optional, ncol, text_width, sort):
            print('\n  *ERROR*: `SimPEG.Report` requires `scooby`.'
                  '\n           Install it via `pip install scooby`.\n')

This is all that is needed to make it a soft dependency. And it prints the useful info.

Edit: I edited the implementation to avoid a name-clash with the actual Report class later.

@banesullivan
Copy link
Member

@prisae - I like that soft dependency implementation a lot! Maybe we should tag that for scooby's docs for whenever we get around to making those

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

Yes, like this it is very minimal. We could even put it on the README of scooby, what you think? Or later in the docs...

@banesullivan
Copy link
Member

Maybe just the docs - maybe make an issue over there so we don't forget about this?

@prisae
Copy link
Member Author

prisae commented Jul 2, 2019

Done: banesullivan/scooby#32

@prisae
Copy link
Member Author

prisae commented Jul 3, 2019

I believe the fail is ones again related to the Google Cloud SDK thingy...

@lheagy
Copy link
Member

lheagy commented Jul 14, 2019

Thanks for pushing on this! I am at a conference this week and am again behind on things... but I will jump back in in a week or two

@prisae
Copy link
Member Author

prisae commented Jul 24, 2019

Two warnings from the Travis-log (run 10 - docs) which might need some action?

WARNING: intersphinx inventory 'http://discretize.simpeg.xyz/en/latest/objects.inv' not fetchable due to <class 'requests.exceptions.HTTPError'>: 404 Client Error: Not Found for url: http://discretize.simpeg.xyz/en/latest/objects.inv
generating gallery...
WARNING: Duplicate file name(s) found. Having duplicate file names will break some links. List of files: ['../examples/04-grav/plot_inversion_linear.py']

@prisae
Copy link
Member Author

prisae commented Feb 7, 2020

@jcapriot , could this PR (or the branch scooby) be merged into the simulation branch?

@jcapriot
Copy link
Member

jcapriot commented Feb 7, 2020

I'm going to switch the merge request to the simulation branch, and merge those changes into here to check, but I don't think this will cause any issues.

A few things, cython is not technically a requirement for SimPEG, it is a requirement of discretize. The old Versions was the only place cython was ever actually used in SimPEG. I'll be removing it from SimPEG's setup.py shortly.

@jcapriot jcapriot changed the base branch from master to simulation February 7, 2020 22:06
@prisae
Copy link
Member Author

prisae commented Feb 8, 2020

Great, thanks @jcapriot !

# Conflicts:
#	SimPEG/__init__.py
#	SimPEG/utils/printinfo.py
#	docs/content/api_core/api_Utils.rst
#	examples/06-dc/plot_dc_schlumberger_array.py
#	examples/06-dc/read_plot_DC_data_with_IO_class.py
#	examples/07-fdem/plot_loop_loop_2Dinversion.py
#	examples/09-tdem/plot_inductive_src_permeable_target.py
#	requirements_dev.txt
@jcapriot jcapriot merged commit 61471da into simulation Feb 20, 2020
@jcapriot jcapriot deleted the scooby branch February 20, 2020 20:51
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.

None yet

4 participants