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 plugins and named extensions for trace headers #83

Open
abingham opened this issue Feb 6, 2018 · 3 comments
Open

Use plugins and named extensions for trace headers #83

abingham opened this issue Feb 6, 2018 · 3 comments

Comments

@abingham
Copy link
Contributor

abingham commented Feb 6, 2018

After running segpy over all of the SEGY files we've got, I've a better sense of why we need to let users specify different trace headers in different situations. Our new, strict header definitions don't work for some of our SEGY, but slightly looser definitions would work. So I was thinking about how to let users define and select which header definition to use.

One approach that worked well for cosmic ray is plugins and named extensions. In short, each header definition would be registered (e.g. using stevedore) with a given name, and these extensions would be provided by plugins. We could package several with segpy itself: Rev1-strict, Rev1-relaxed, etc. Stevedore would allow users to provide their own if they wanted/needed.

The other part of the puzzle would be deciding how we let them select a header. One option would be on the command line, another would be with a config file, and we could also combine these approaches if that made the most sense.

I just wanted to get this idea out there. It's worked pretty well for Cosmic Ray, so it might be appropriate for segpy as well.

@rob-smallshire
Copy link
Contributor

create_reader() and write_segy() already accept an optional trace_header_format argument. It should be a simple matter to have them also accept an optional binary_reel_header_format` argument.

It's not obvious to me why a plugin mechanism is necessary though. Segpy is designed to be used as a library rather than a framework, so whatever executive program invokes Segpy is responsible for handing it appropriate header format definition classes (or at least knowingly accepting the defaults). This executive program could be one of the command-line programs (although the ones we ship are just illustrative examples), or could be some more elaborate application.

This is the opposite of Cosmic-Ray because in that case, it is the executive program (and framework), and so needs to have the means to discover and invoke extensions itself.

In summary, I'm not sure why we can't just include various header format definition classes as we already do, and allow clients to specify them when they invoke the API. If client programs need automatic discoverability for header format definition classes they can layer that on top of the capabilities that Segpy already provides, without Segpy needing to take on position on the mechanism used.

Of course, it's possible I've overlooked some important use-case!

@rob-smallshire
Copy link
Contributor

What's the failure mode when Segpy fails because of an incompatible header definition. Do you get a reasonable error, or something internal and obscure?

@abingham
Copy link
Contributor Author

abingham commented Feb 6, 2018 via email

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

No branches or pull requests

2 participants