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

Observatory Dependency Injection #195

Merged
merged 3 commits into from
Dec 16, 2017
Merged

Conversation

wtgee
Copy link
Member

@wtgee wtgee commented Dec 15, 2017

Simple change to create the Observatory outside of POCS and require it as a first parameter.

This will allow for a lot easier use by Huntsman and other observatories.

@wtgee wtgee requested a review from a team December 15, 2017 23:48
@codecov
Copy link

codecov bot commented Dec 16, 2017

Codecov Report

Merging #195 into develop will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #195      +/-   ##
===========================================
- Coverage    81.32%   81.32%   -0.01%     
===========================================
  Files           37       37              
  Lines         2662     2661       -1     
  Branches       331      331              
===========================================
- Hits          2165     2164       -1     
  Misses         392      392              
  Partials       105      105
Impacted Files Coverage Δ
pocs/core.py 79.73% <100%> (-0.09%) ⬇️

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 2e029dc...678ca33. Read the comment docs.

@@ -15,6 +15,7 @@ from astropy.io import fits
from astropy.utils import console

from pocs import POCS
from pocs.observatory import Observatory
Copy link
Contributor

Choose a reason for hiding this comment

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

Please import package or module, not class. In this case, you'd say:
import pocs.observatory
And later:
observatory = pocs.observatory.Observatory(simulator=simulator)

Copy link
Member Author

@wtgee wtgee Dec 16, 2017

Choose a reason for hiding this comment

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

As I remarked in another PR, this was not something that we explicitly decided on, we only talked about using root relative syntax. Either style is correct and the thing that is usually stressed is to be consistent. Since 95% of the current code uses the from syntax, which is what we have been encouraging previously, I'm not sure what the arguments are for in favor of changing them all. It is slightly more obvious what package is being referred to so I could understand wanting to switch to it, but that is a conversation we have not had yet.

Copy link
Member Author

@wtgee wtgee Dec 16, 2017

Choose a reason for hiding this comment

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

I think you made a comment but disappeared. I looked at the google style code a bit more and see what they are getting at. It's not explicitly saying not to use the from style but to use just the module without prefix, which is not what I am doing. Will fix accordingly. From here

observatory,
state_machine_file='simple_state_table',
messaging=False,
**kwargs):

# Explicitly call the base classes in the order we want
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, this comment and the associated code seem to imply that we should use aggregation for PanStateMachine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be the comment that you missed, about the awkwardness of multiple inheritance.

@@ -9,14 +9,24 @@
from pocs import POCS
from pocs import _check_config
from pocs import _check_environment
from pocs.observatory import Observatory
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto on the import style.

def pocs(config):
def observatory():
observatory = Observatory(simulator=['all'])

Copy link
Contributor

Choose a reason for hiding this comment

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

Drop blank line.

pocs = POCS(simulator=['camera', 'mount', 'night'],
observatory.config['simulator'] = ['camera', 'mount', 'night']

pocs = POCS(observatory,
messaging=True, safe_delay=15)
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, looks like safe_delay is one of several undocumented parameters to POCS.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created issue #198

@jamessynge jamessynge merged commit 41dc689 into panoptes:develop Dec 16, 2017
@wtgee wtgee mentioned this pull request Dec 29, 2017
@wtgee wtgee deleted the observatory-di branch August 20, 2022 00:54
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.

2 participants