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

Redesign Dashboard and Modularize Backend #6

Merged
merged 101 commits into from
Aug 28, 2020
Merged

Redesign Dashboard and Modularize Backend #6

merged 101 commits into from
Aug 28, 2020

Conversation

kngoyal
Copy link
Collaborator

@kngoyal kngoyal commented Aug 12, 2020

No description provided.

@kngoyal kngoyal requested a review from adijo August 24, 2020 19:24
output_dir (str): Directory path to which the experiment artifacts are saved. Saved to current directory
by default.
save_to_file (bool): Indicates if the emission artifacts should be logged to a file
:param project_name: Project name for current experiment run. Default value of "default"
Copy link
Member

Choose a reason for hiding this comment

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

I prefer the Google style docstrings that I had earlier, the type information is pretty helpful.

if cloud.is_on_private_infra
else ""
)
if cloud.is_on_private_infra:
Copy link
Member

Choose a reason for hiding this comment

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

This can be moved to a separate method, something like _prepare_persistence_data for example. This will make the stop() method shorter and more readable.

df: pd.DataFrame = self._data_source.get_cloud_emissions_data()

# TODO: deal with missing data
print(cloud.provider, cloud.region)
Copy link
Member

Choose a reason for hiding this comment

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

Remove print statements

return (
_get_country_emissions_energy_mix(
energy, geo, energy_mix_data_path=config.private_infra_energy_mix_path,
class Emissions:
Copy link
Member

Choose a reason for hiding this comment

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

I think pure functions are better here instead of this class. Reference. There is no real state here, I think data_source can just be another argument


country_energy_mix: Dict = energy_mix[geo.country_iso_code]

emissions_percentage: Dict[str, float] = {}
Copy link
Member

Choose a reason for hiding this comment

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

Prefer dict() instead of {}

posting to Json Box, saving to a database, sending a slack message etc.
"""

@abstractmethod
def flush(self, data: CO2Data):
def out(self, data: CO2Data):
Copy link
Member

Choose a reason for hiding this comment

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

I think flush() (which is used with the context of emptying a buffer) or persist() is more descriptive

@sashavor sashavor merged commit 8995e20 into master Aug 28, 2020
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.

5 participants