Skip to content

Third-party object types - #163

Open
JoanneBogart wants to merge 3 commits into
mainfrom
u/jrbogart/doc-third-party
Open

JoanneBogart wants to merge 3 commits into
mainfrom
u/jrbogart/doc-third-party

Conversation

@JoanneBogart

Copy link
Copy Markdown
Collaborator

Document use of third-party object types

@JoanneBogart JoanneBogart linked an issue Sep 1, 2026 that may be closed by this pull request

@jchiang87 jchiang87 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are a number of changes I'd like to see made.

Comment thread docs/usage_third_party.rst Outdated
Comment on lines +3 to +12
For simulations requiring only relatively small-scale catalogs of a new type,
the effort involved in creating and supporting that type in the production
repos ``skyCataglogs`` and ``skyCatalogs_creator``
may be prohibitive. There is an alternative, which is to write code satisfying

- the minimal interface needed by imSim's use of skyCatalogs
- requirements skyCatalogs has on non-native object types

The code may or may not depend on input files of some sort,
but in either case no changes to the skyCatalogs code will be needed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My original motivations for adding this facility was somewhat different than the desire for an easy way to implement "small-scale catalogs", and I think are more compelling. So I would replace lines 3-12 with

The required interface for using catalogs with imSim just entails implementing a few methods in
subclasses of the ``BaseObject`` and ``ObjectCollection`` classes.  Thus, it's fairly straight-forward to
implement new object types, and we've provided an interface to enable those object types to imported
and configured via a third party package.  Using a third party package has a couple of notable benefits:

- It avoids having to coordinate adding new object types to skyCatalogs itself;
- Relatedly, any additional software dependencies introduced by the new code will be isolated from skyCatalogs and so won't impose those dependencies on other skyCatalogs users.

In addition, some of the supporting infrastructure in skyCatalogs, e.g., reading parquet files with
pre-computed fluxes, can in principle, be available via subclassing.

@JoanneBogart JoanneBogart Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Most of your suggested text is fine with me. I'm not sure it's realistic for people to subclass anything other than perhaps ParquetReader (and of course BaseObject and ObjectCollection) so might rephrase the last paragraph.
We can leave out the mention of "small-scale catalogs", but I don't think we should be encouraging people to go the third-party route for large catalogs that others (not the developer) might want to use. The use of the interface might be appropriate, but the code should reside in the skyCatalogs and, optionally, skyCatalogs_creator repos.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Then I would just omit that last sentence from my text. Personally, I think skyCatalogs should be more of an interface package, and heavy duty implementation for specific catalogs should be spun off into separate packages. This helps keep the dependencies minimal, provides more stability for users, and would encourage the interfaces to be less specific to particular catalog implementations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Happy to omit it.
I would agree with you about separate packages if skyCatalogs + skyCatalogs_creator had been designed that way, with more of the infrastructure readily subclassable. As it is, there is a substantial amount of code for creating and reading data files and dealing with the configuration which is shared by different object types.

Comment thread docs/usage_third_party.rst Outdated
implement the routines ``get_observer_sed_component`` and
``get_gsobject_components``. A realistic implementation of the former would
return a galsim SED, computed from information read in on the fly or when the
object was created.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd replace the sentence A realistic ... was created. with

If the object types have multiple components with distinct SEDs, such as bulge and disk components in
a galaxy, then the ``.subcomponents`` property for the ``BaseObject`` subclass must be defined to return a 
list of the subcomponents for each object.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we still need something from the original version in addition to your text. The point I was trying to make was that returning None, as is done in the example, is not realistic. But I agree we also need something about subcomponents.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In that case, I'd add this after my sentence about subcomponents:

Of course, contrary to the test code, the ``get_observer_sed_component`` function should return a
``galsim.SED`` object for the specified component.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I left my part first, which I think is easier to parse since it refers to the routines in the order they appear in the previous sentence, then included essentially your text.

Comment thread docs/usage_third_party.rst Outdated
Comment thread docs/usage_third_party.rst Outdated
The example file ``external_skycat.yaml`` defines two object types to be
handled by the same code (indicated by the value of the ``module`` field),
but differentiated by the value of ``object_param``. (Alternatively one could
write different code for the two object types in different modules.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this parenthetical statement is unnecessary:

(Alternatively one could write different code for the two object types in different modules.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't see that it does any harm and there could be situations where that would be the better approach. What if the object types are different enough that the corresponding codes don't have much in common? And it's possible that someone, not necessarily the writer, is only interested in using one. Of course the code handling both would work perfectly well, but if the object types are unrelated and might be used independently or have different development cycles I'd say it's preferable to separate into two modules.

Comment thread docs/usage_third_party.rst Outdated
but differentiated by the value of ``object_param``. (Alternatively one could
write different code for the two object types in different modules.)
The minimum configuration needed would omit the second object type and
the ``object_param`` field from the remaining object type description.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think these lines are also unnecessary:

The minimum configuration needed would omit the second object type and
the ``object_param`` field from the remaining object type description.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it's useful for someone who otherwise has no information beyond what's in the example. They need to know what the fields are for, which are required and which are not.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In that case, I think it's better to state explicitly what's required rather than saying what can be omitted:

A minimal configuration would include just one object type and the area_partition and module fields, e.g.:

object_types:
  my_object_type:
    area_partition: None
    module: external_catalog

(BTW, it would be great if we could omit area_partition by setting it to None by default in the code.)

an object collection. In typical implementations, ``load_collection``
would use the configuration to find the file or files
containing data for the region and then use that to create the
collection.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add the sentence

For running with imSim, the ``.native_columns()`` property and ``.__len__()`` method must also be implemented.

@JoanneBogart JoanneBogart Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There are implementations in ObjectCollection which look like they would do for your example.
Possibly related - in ExternalCollection.init why don't you do
super().__init__(...)
followed by
self._param = param
?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll note that code was intended for unit testing purposes, so I just implemented the parts I needed to test third party interface, not to test the full skyCatalogs interface. If you find it so objectionable as an example, then we shouldn't use test code and provide example code with the features you want.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I used it because it's all there was. I don't find it objectionable but there are features it, quite understandably, doesn't exercise. I took the easy way out by trying to fill in the gaps. It would be better to use an example specifically designed as a teaching tool. I can try my hand at it. I expect, as designer of the facility, you could do a better job.
Initially in my comment I was just trying to understand why you thought it necessary to tell people they needed to be concerned about .native_columns() and .__len()__ when the implementations in the base class would probably do for most people.

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.

Documentation for third-party object types

2 participants