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

Issue #85: Set initial storage level #87

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

LorenzzoQM
Copy link
Contributor

Description

Closes #85

An extra argument was added to the _set_storage_unit method in the ContinuousImagingDynModel class to allowing the user to specify the initial storage level.

How should this pull request be reviewed?

  • By commit
  • All changes at once

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit tests (General Environment only) pytest --cov bsk_rl/envs/general_satellite_tasking --cov-report term-missing tests/unittest
  • Integrated tests (General Environment only) pytest --cov bsk_rl/envs/general_satellite_tasking --cov-report term-missing tests/integration

Test Configuration

  • Python: [3.11.5]
  • Basilisk: [2.2.1]
  • Platform: [MacOs 13.6.2]

Checklist:

  • My code follows the style guidelines of this project (passes Black, ruff, and isort)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Commit messages are atomic, are in the form Issue #XXX: Message and have a useful message
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@LorenzzoQM LorenzzoQM self-assigned this Nov 28, 2023
@LorenzzoQM LorenzzoQM marked this pull request as draft November 28, 2023 19:27
@LorenzzoQM LorenzzoQM requested a review from Mark2000 November 28, 2023 21:04
@LorenzzoQM LorenzzoQM force-pushed the feature/85_set_initial_data_storage branch 2 times, most recently from 5bca45f to 418cc1a Compare November 28, 2023 21:08
@LorenzzoQM LorenzzoQM marked this pull request as ready for review November 28, 2023 21:09
Copy link
Contributor

@Mark2000 Mark2000 left a comment

Choose a reason for hiding this comment

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

Some questions about things that I think are fine but don't know for certain. Also suggested a variable name change. Other than that looks good. Agree on testing sufficiently covering this, important stuff is handled with BSK tests.

"""
self.storageUnit = simpleStorageUnit.SimpleStorageUnit()
self.storageUnit.ModelTag = "storageUnit" + self.satellite.id
self.storageUnit.storageCapacity = dataStorageCapacity # bits
self.storageUnit.addDataNodeToModel(self.instrument.nodeDataOutMsg)
self.storageUnit.addDataNodeToModel(self.transmitter.nodeDataOutMsg)
self.storageUnitValidCheck = storageUnitValidCheck
self.storageUnit.setDataBuffer(setStorageInit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does BSK properly handle range checking (negative storage? setStorageInit>dataStorageCapacity?)? Is there any sort of warning if that's violated? Or do you not think that's necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The storage module doesn't allow the storage to go lower than zero or higher than the limit using the setDataBuffer. So, in case the data amount passed to setDataBuffer violates one of those cases, the module won't perform the addition/subtraction. Since these cases won't happen, I don't think warnings are really necessary.

@default_args(dataStorageCapacity=20 * 8e6, storageUnitValidCheck=True)
@default_args(
dataStorageCapacity=20 * 8e6, storageUnitValidCheck=True, setStorageInit=0
)
def _set_storage_unit(
self,
dataStorageCapacity: int,
priority: int = 699,
storageUnitValidCheck: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this still work how we wanted with the change to integers? I think so, but not sure if the floating point error was part of that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. The storage is not supposed to go over its limit anymore due to changes in the baseStorageUnit module (using integers and how it checks for free space). But storageValidCheck will still check if the storage unit is at its maximum capacity. So, I believe it still has the expected behavior.

def _set_storage_unit(
self,
dataStorageCapacity: int,
priority: int = 699,
storageUnitValidCheck: bool = True,
setStorageInit=0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a type hint (i.e. storageInit: int=0) and change the name to follow the convention of not including set in the variable names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok!

@LorenzzoQM LorenzzoQM force-pushed the feature/85_set_initial_data_storage branch from 418cc1a to ff2f976 Compare November 28, 2023 22:08
@Mark2000
Copy link
Contributor

lgtm!

@LorenzzoQM LorenzzoQM merged commit b8b34e1 into develop Nov 28, 2023
8 checks passed
@LorenzzoQM LorenzzoQM deleted the feature/85_set_initial_data_storage branch November 28, 2023 22:32
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.

Set initial storage level in ContinuousImagingDynModel
2 participants