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

feat(event): add support for Earth seasons #24

Merged
merged 15 commits into from
Jun 20, 2021

Conversation

LiamNgn
Copy link
Contributor

@LiamNgn LiamNgn commented Jun 15, 2021

Q A
Bug fix? no
New feature? yes
Related issues Fix #23
Has BC-break no
License CeCILL-C

Copy link
Member

@Deuchnord Deuchnord left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!
Just made some change requests to enhance the general code maintainability. If you need help or have some remarks, feel free to ask :)

kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/enum.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
@Deuchnord Deuchnord changed the title I have added Earth Season Change event in events.py and enum.py. Find Earth seasons change event Jun 15, 2021
@Deuchnord Deuchnord added enhancement New feature or request event labels Jun 15, 2021
@LiamNgn
Copy link
Contributor Author

LiamNgn commented Jun 16, 2021

I have recently updated my code based on your feedback. If you find any change needed, just tell me. Thank you.

Copy link
Member

@Deuchnord Deuchnord left a comment

Choose a reason for hiding this comment

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

Thanks, we are on a good path!
Just making a few new comments :)

kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/events.py Outdated Show resolved Hide resolved
kosmorrolib/enum.py Outdated Show resolved Hide resolved
@Deuchnord
Copy link
Member

Didn't see it immediately, but since we are adding a new feature, your branch should be based on features, not on main. Can you rebase it?

@LiamNgn LiamNgn changed the base branch from main to features June 17, 2021 07:23
@LiamNgn
Copy link
Contributor Author

LiamNgn commented Jun 17, 2021

I have updated the code according to your suggestions. Regarding the Season Change, I have created a new enum class for these. Is that ok? Moreover, I'm unsure how to do rebase so I just edit the base branch on these issue. Is that correct? If not how can I rebase from my forked repository? Thank you.

@Deuchnord
Copy link
Member

Moreover, I'm unsure how to do rebase so I just edit the base branch on these issue. Is that correct? If not how can I rebase from my forked repository? Thank you.

It's actually not sufficient. Rebasing on features means that your branch's base has to be moved from main to features.

This is what we currently have:

                ------------------------------- features
              /
-------------o---------o--------------------- main
                        \
                         ---------------------- dragontunglam:LiamNg

And this is what we should have:

                                     ---------------------- dragontunglam:LiamNg
                                   /
                ------------------o------------- features
              /
-------------o---------o--------------------- main
                         

The goal of this is to ensure that new features come in x.y.0 releases, whereas bugfixes are done in the main branch directly and come in x.y.z (with z > 0) releases.

There are many ways to achieve this, but in your case, I think the simplest way would be to rename your branch to a temporary name, recreate a new one with the same name of your current branch but based on features and cherry-pick your commits to the new branch.

You should do these actions before making any new change to your work to ensure nothing is lost.

# Ensure you have the last version of the branches:
git remote add upstream https://github.com/kosmorro/lib.git
git fetch --all --prune

# Rename your branch:
git branch -m LiamNg tmp

# Switch to `features` branch, update it and recreate your branch:
git checkout features
git pull upstream features
git checkout -b LiamNg

# Cherry-pick your commits:
git cherry-pick 9d7240bb4ab54d0e13e81f5875e575c340129b4d
git cherry-pick 3704175c98c9453637f4d865bb51128df87c3842
git cherry-pick 95cbfc970dc73fbefdca0ae8e636ddf1254070cb
git cherry-pick 0425a3020446edc0f8ab2502c2f46255a6667275

# Force-push your new branch to update the PR:
git push -f origin LiamNg

Then, check that all your work (and only yours) is well on your PR, and that there are only your commits and finally, delete your temp branch (but only if all is good):

git branch -D tmp

Regarding the Season Change, I have created a new enum class for these. Is that ok?

This is definitely a very good idea! But the event_type field of Event should remain an EvenType (otherwise, it would introduce too much complexity for the end developers).
We then could reintroduce a SEASON_CHANGE in the EventType and put the new SeasonType in the details field of the Event class, which would become a dictionnary (it is currently a string).

So the actions would be:

  1. In the EventType, add an SEASON_CHANGE constant
  2. In the model.py module, line 157, change the type of the details parameter from str to dict
  3. In the event.py module, line 186, change the line to:
    details={'deg': elongation}
    (Bonus: this makes it much easier for the developers to use this data! 😄
  4. On your events.append(...) instruction, change the first parameter of the Event object to EventType.SEASON_CHANGE and add a details={'season': season}, where the season variable will be one of the constants in the SeasonType.

Note that this will be a breaking change, so let's make profit that we're still not v1.0 to do it! 😄

Copy link
Member

@Deuchnord Deuchnord left a comment

Choose a reason for hiding this comment

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

That looks very good, just a little change and we'll be good!
Can you just check that the tests in the documentation are up-to-date? Note that you can run them by invoking make doctests.

kosmorrolib/events.py Outdated Show resolved Hide resolved
@Deuchnord Deuchnord changed the title Find Earth seasons change event feat(event): add support for Earth seasons Jun 18, 2021
…osmorro#25)

* ci: remove Commitlint workflow (replaced by semantic-pull-request)

* ci: fix doctests not running correctly on some OS and Python versions
@coveralls
Copy link

coveralls commented Jun 20, 2021

Coverage Status

Coverage increased (+1.3%) to 82.959% when pulling d08e21c on LiamNgn:LiamNg into 2884da5 on Kosmorro:features.

@Deuchnord
Copy link
Member

Deuchnord commented Jun 20, 2021

This looks very good!
You only need to fix the legacy tests (they broke because we changed the details in the Event) and to fix Black's alerts (you can fix them quickly with make black), and we'll be good to merge! 😄

Btw, the Commit / Message validation job on the CI can be safely ignored, it is a legacy test I have recently removed.

@Deuchnord
Copy link
Member

Just made some very minor fixes to enhance the code quality.
Thank you for your contribution, it will be merged as soon as the CI passes! 😄

@Deuchnord Deuchnord disabled auto-merge June 20, 2021 12:43
@Deuchnord Deuchnord merged commit 5e537f6 into Kosmorro:features Jun 20, 2021
Deuchnord pushed a commit that referenced this pull request Oct 26, 2021
* chore: fix files to commit on tag

* fix(ephemerides): fix a bug that made the ephemerides calculations impossible for the Poles (#21)

* chore: fix the target branch on Dependabot's config

* ci: remove Commitlint workflow (replaced by semantic-pull-request) (#25)

* ci: remove Commitlint workflow (replaced by semantic-pull-request)

* ci: fix doctests not running correctly on some OS and Python versions

* Add season change event in events.py and enum.py

* Add minor change in season change event

* Add documentation, change enum constants, change output object of _search_earth_season_change

* Minor changes to _search_earth_season_change

* Update EventType enum, update class of details

* Fix minor bugs

* docs: Update docs for _search_earth_season_change and _search_conjunction.chore: make minor changes to _search_earth_season_change

* Update: minor changes to match Python coding style.

* Update: minor changes to match Python coding style. Docs: update docstring of _search_earth_season_change and _search_conjunction

* test:update legacy tests for events.py. update: update enum.py and events.py to match black coding style.

* Fix some minor issues with Black and Event.details field

Co-authored-by: Jérôme Deuchnord <jerome@deuchnord.fr>
Co-authored-by: Jérôme Deuchnord <Deuchnord@users.noreply.github.com>

BREAKING CHANGE: the `Event.details` field is now a dictionary (was previously a string).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request event
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Earth seasons changes
3 participants