Skip to content

Commit

Permalink
Merge pull request #77 from jzvolensky/codecarbon
Browse files Browse the repository at this point in the history
added support for codecarbon integration, integration examples, html …
  • Loading branch information
clausmichele authored Jan 20, 2025
2 parents e3c7ada + 4865d83 commit db73e54
Show file tree
Hide file tree
Showing 7 changed files with 991 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,22 @@ Choosing between subscription and on-demand models depends on various factors, i

### Cost of scalability

Direct examples of computing on a workflow
(todo: based on actual workflow)
Executing code, whether on your own computer or a cloud platform, comes with costs—both financial and environmental. Every computation step consumes resources and energy. While simple computations like sorting a small list are quick and resource-light, more complex workflows, such as training a machine learning model or processing large datasets, can be resource-intensive.

### Memory consumption
These resource-intensive workflows not only require significant energy but also take considerable time. Saving just a few seconds in a small workflow might seem insignificant, but in large-scale computations, those seconds can translate into hours or even days saved.

limitations and
It’s important to measure and understand the resource consumption of your workflows to minimize their environmental impact. Tools like `Codecarbon` can estimate the energy use of your code, providing a starting point for optimization. You can read more about the tool [online](https://codecarbon.io/) or on [GitHub](https://github.com/mlco2/codecarbon)
No tool is perfect, so interpreting results critically and understanding their limitations is essential. However, using such tools can help raise awareness and guide improvements.

On cloud platforms, optimizing resource usage doesn’t just reduce your carbon footprint—it can also save you money.

As you design and execute workflows, think about how you can reduce complexity, reuse existing resources, and streamline processes. By doing so, you’re contributing to a more sustainable approach to computing.

### Difference between platform usage and cloud directly

TODO: Is this covered already in the platform lesson? Yes
Using platforms removes complexity and adds abstraction layers


## What to avoid and what are the limitations

While scaling is providing many options and is essential for achieving results on a larger scale, there are some limitations to keep in mind and activities to even avoid.
Expand All @@ -137,11 +140,8 @@ Scaling Limits in the platform: While cloud platforms offer high scalability, th

To mitigate these challenges and limitations, it's advisable to thoroughly plan and architect your application for scalability, leverage cloud-native tools and services, monitor resource usage and costs, and regularly test and optimize your scaling strategies. Additionally, staying updated with the latest advancements in cloud technologies and best practices will help you navigate the complexities of cloud-native scaling more effectively.


#### Animated Content: Tiling and application (drag and drop)



## Quiz
What are cloud native data formats in EO and GIS

Expand Down Expand Up @@ -196,6 +196,20 @@ Solution:
- With compression, each month it's possible to spare 180 €.
- Since the compression process costs 2000 €, and each month costs 180 € less with it, it would take 2000 € / 180 €/month ~= 11 months to start to spare money.


Calculate the volume of data needed for the snow workflow according to the collections, time steps, bands, resolutions, spatial extent selected in the previous chapter, value types, format, compression estimate, etc. (this only if we define snow workflow already here) - Don't use snow workflow -> Set that information

## Resource Consumption Quiz

What does `CodeCarbon` measure in Python code? *Answer in exercise: 24_formats_and_performance.ipynb*

[( )] Code execution speed
[(X)] Energy consumption of code execution
[( )] Memory usage of variables
[( )] The number of lines in the code

Approximately how many meters of driving a Mars rover would consume the same amount of energy as our sample NDVI workflow? *Answer in exercise: 24_formats_and_performance.ipynb*

[(X)] 0-2 meter
[( )] 2-4 meters
[( )] 4-6 meters
[( )] 6-8 meters
1 change: 1 addition & 0 deletions lectures/2.4_formats_and_performance/assets/lightbulb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lectures/2.4_formats_and_performance/assets/marsrover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lectures/2.4_formats_and_performance/assets/smartwatch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions lectures/2.4_formats_and_performance/energy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Emission Equivalents for Latest Run</title>
</head>
<body>
<h2>Emission Equivalents for Latest Run</h2>
<div class="container">
<!-- Mars Rover Perseverance Metric -->
<div class="item">
<img src="../assets/marsrover.svg" alt="Mars Rover">
<p><strong>Mars Rover Perseverance distance:</strong><br>{{ rover_distance }} Meters</p>
<span class="tooltip">
This is equivalent to the amount of energy required to move the Perseverance rover {{ rover_distance }} meters.
</span>
</div>

<!-- LED Bulb Runtime Metric -->
<div class="item">
<img src="../assets/lightbulb.svg" alt="LED Bulb">
<p><strong>LED Bulb Runtime:</strong><br>{{ led_bulb }} </p>
<span class="tooltip">
This energy is equivalent to powering a standard 10W LED bulb for {{ led_bulb }} .
</span>
</div>

<!-- Smartwatch Runtime Metric -->
<div class="item">
<img src="../assets/smartwatch.svg" alt="Smartwatch">
<p><strong>Smartwatch Runtime idle use:</strong><br>{{ smartwatch_runtime_idle }} </p>
<p><strong>Smartwatch Runtime normal use:</strong><br>{{ smartwatch_runtime_normal }} </p>
<span class="tooltip">
The amount of energy used to run the code could power a smartwatch for {{ smartwatch_runtime_idle }} in idle mode and for {{ smartwatch_runtime_normal }} in regular use mode .
</span>
</div>
</div>
</body>
<style>
.container {
display: flex;
flex-wrap: wrap;
min-height: 300px;
}
.item {
flex: 1;
padding: 10px;
text-align: center;
box-sizing: border-box;
position: relative;
border: 2px solid transparent;
transition: border-color 0.3s;
}
.item img {
width: 100px;
height: 100px;
transition: transform 0.3s;
}
.item:hover {
border-color: #838383;
}
.item:hover img {
transform: scale(1.2);
}
.tooltip {
display: none;
color: #000000;
text-align: center;
margin-top: 10px;
border-radius: 5px;
padding: 5px;
background-color: #ffffff;
}
.item:hover .tooltip {
display: block;
}
body {
background-color: #121212;
color: #ffffff;
}
</style>
</html>
Loading

0 comments on commit db73e54

Please sign in to comment.