Please see the code of conduct for our playground rules and follow them during all your contributions.
We prefer that all changes to POCS have an associated GitHub Issue in the project that explains why it is needed. This allows us to debate the best approach to address the issue before folks spend a lot of time writing code. If you are unsure about a possible contribution to the project, please contact the project owners about your idea; of course, an issue is a good way to do this.
This is a summary of the process. See the POCS wiki for more info.
- Pre-requisites
- Ensure you have a github account.
- If the change you wish to make is not already an Issue in the project, please create one specifying the need.
- Process
- Create a fork of the repository and use a topic branch within your fork to make changes.
- All of our repositories have a default branch of
develop
when you first clone them, but your work should be in a separate branch. - Create a branch with a descriptive name, e.g.:
git checkout -b new-camera-simulator
git checkout -b issue-28
- All of our repositories have a default branch of
- Ensure that your code meets this project's standards (see Testing and Code Formatting below).
- Run
python setup.py test
from the$POCS
directory before pushing to github - Squash your commits so they only reflect meaningful changes.
- Submit a pull request to the repository, be sure to reference the issue number it addresses.
- Create a fork of the repository and use a topic branch within your fork to make changes.
- Follow instructions in the README as well as the Coding in PANOPTES document.
- All changes should have corresponding tests and existing tests should pass after your changes.
- For more on testing see the Coding in PANOPTES page.
- All Python should use PEP 8 Standards
- Line length is set at 100 characters instead of 80.
- It is recommended to have your editor auto-format code whenever you save a file rather than attempt to go back and change an entire file all at once.
- You can also use
yapf (Yet Another Python Formatter)
for which POCS includes a style file (.style.yapf). For example:
# cd to the root of your workspace. cd $(git rev-parse --show-toplevel) # Format the modified python files in your workspace. yapf -i $(git diff --name-only | egrep '\.py$')
- Do not leave in commented-out code or unnecessary whitespace.
- Variable/function/class and file names should be meaningful and descriptive.
- File names should be lower case and underscored, not contain spaces. For example,
my_file.py
instead ofMy File.py
. - Define any project specific terminology or abbreviations you use in the file you use them.
- Use root-relative imports (i.e. relative to the POCS directory). This means that rather
than using a directory relative imports such as:
Import from the top-down instead:
from ..base import PanBase from ..utils import current_time
The same applies to code inside offrom pocs.base import PanBase from panoptes.utils import current_time
peas
. - Test imports are slightly different because
pocs/tests
andpeas/tests
are not Python packages (those directories don't contain an__init__.py
file). For imports ofpocs
orpeas
code, use root-relative imports as described above. For importing test packages and modules, assume the test doing the imports is in the root directory.
Use appropriate logging:
- Log level:
- DEBUG (i.e.
self.logger.debug()
) should attempt to capture all run-time information. - INFO (i.e.
self.logger.info()
) should be used sparingly and meant to convey information to a person actively watching a running unit. - WARNING (i.e.
self.logger.warning()
) should alert when something does not go as expected but operation of unit can continue. - ERROR (i.e.
self.logger.error()
) should be used at critical levels when operation cannot continue.
- DEBUG (i.e.
- The logger supports variable information without the use of the
format
method. - There is a
say
method available on the mainPOCS
class that is meant to be used in friendly manner to convey information to a user. This should be used only for personable output and is typically displayed in the "chat box"of the PAWS website. These messages are also sent to the INFO level logger.
Note: These are meant to illustrate the logging calls and are not necessarily indicative of real operation
self.logger.info("PANOPTES unit initialized: {}", self.config['name'])
self.say("I'm all ready to go, first checking the weather")
self.logger.debug("Setting up weather station")
self.logger.warning('Problem getting wind safety: {}'.format(e))
self.logger.debug("Rain: {} Clouds: {} Dark: {} Temp: {:.02f}",
is_raining,
is_cloudy,
is_dark,
temp_celsius
)
self.logger.error('Unable to connect to AAG Cloud Sensor, cannot continue')
- You typically want to follow an active log file by using
tail -F
on the command line. - The
grc
(generic colouriser) can be used withtail
to get pretty log files.
(panoptes-env) $ grc tail -F $PANDIR/logs/pocs_shell.log
The following screenshot shows commands entered into a jupyter-console
in the top
panel and the log file in the bottom panel.