Skip to content

Commit

Permalink
Activate NL, FI & BE
Browse files Browse the repository at this point in the history
Update vularable packages
  • Loading branch information
AydinMirMohammadi committed Jun 16, 2024
1 parent 3f3b7cc commit d3e70c6
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<UserSecretsId>a0dbe6a0-f759-49d0-bfb3-9fc6287d2ab3</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Graph" Version="4.50.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public class DataEndAtExample : OpenApiExample<DateTimeOffset?>
{
public override IOpenApiExample<DateTimeOffset?> Build(NamingStrategy namingStrategy = null)
{
Examples.Add(OpenApiExampleResolver.Resolve("In five hours", DateTimeOffset.Now.AddHours(1).PadSeconds(), namingStrategy));
Examples.Add(OpenApiExampleResolver.Resolve("In five hours", DateTimeOffset.Now.AddHours(5).PadSeconds(), namingStrategy));
Examples.Add(OpenApiExampleResolver.Resolve("In ten hours", DateTimeOffset.Now.AddHours(10).PadSeconds(), namingStrategy));
return this;
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddSingleton<CarbonAwareDataProvider, CarbonAwareDataProviderOpenData>();
builder.Services.AddSingleton<CarbonAwareDataProvider, CarbonAwareDataProviderOpenData>(p => new CarbonAwareDataProviderOpenData());
builder.Services.AddOptions<ApplicationSettings>()
.Configure<IConfiguration>((settings, configuration) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.8.0" />
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.1" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.8.0" />
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.1" />
<PackageReference Include="FunicularSwitch" Version="4.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,6 @@ namespace CarbonAwareComputing.ForecastUpdater.EnergyCharts;

public static class EnergyChartsTransform
{
public static Result<EmissionsForecast> ImportForecast(List<EnergyChartRoot> roots, string country)
{
try
{
var location = country;
var generatedAt = DateTimeOffset.Now;
var result = CreateTimeAxis(roots, country);
return result.Bind<List<EmissionsData>>(
forecast =>
{
foreach (var root in roots)
{
if (root.Date.HasValue)
{
generatedAt = DateTimeOffset.FromUnixTimeMilliseconds(root.Date.Value);
}

var values = root.Data.ToArray();

for (int i = 0; i < values.Length; i++)
{
var value = values[i];
if (value != null)
{
forecast[i] = forecast[i] with
{
Rating = 100 - value.Value
};
}
}
}
return forecast.Values.ToList();
}).Bind<EmissionsForecast>(
emissions => new EmissionsForecast
{
GeneratedAt = generatedAt,
Location = new Location { Name = location },
ForecastData = emissions
}
);
}
catch (Exception ex)
{
return Result.Error<EmissionsForecast>(ex.Message);
}
}
public static Result<EmissionsForecast> ImportForecast(EnergyChartCarbonGridIntensityRoot root, string country)
{
try
Expand All @@ -76,7 +30,7 @@ public static Result<EmissionsForecast> ImportForecast(EnergyChartCarbonGridInte
};
}
}
return forecast.Values.ToList();
return forecast.Values.Where(f => f.Rating > 0).ToList();
}).Bind<EmissionsForecast>(
emissions => new EmissionsForecast
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.2.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="Azure.Identity" Version="1.11.0" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Graph" Version="4.50.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
Expand Down
2 changes: 1 addition & 1 deletion src/CarbonAwareComputing/CarbonAwareComputing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>CarbonAwareComputing</PackageId>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<Authors>Implemented with 💙 by bluehands</Authors>
<Company>bluehands GmbH &amp; Co.mmunication KG</Company>
<PackageTags>bluehands; Carbon Aware Computing; Grid Carbon Intensity; Sustainability; Green Software</PackageTags>
Expand Down
25 changes: 22 additions & 3 deletions src/CarbonAwareComputing/ComputingLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ public static class ComputingLocations
public static CloudRegion GCP_Europe_West6 { get; } = new("europe-west6", "ch");
public static ComputingLocation France { get; } = new("fr");
public static CloudRegion Azure_France_Central { get; } = new("francecentral", "fr");
public static CloudRegion Azure_West_Europe { get; } = new("westeurope", "nl");
public static CloudRegion GCP_Europe_West9 { get; } = new("europe-west9", "fr");
public static CloudRegion GCP_Europe_North1 { get; } = new("europe-north1", "fi");
public static CloudRegion GCP_Europe_West1 { get; } = new("europe-west1", "be");
public static CloudRegion GCP_Europe_West10 { get; } = new("europe-west10", "de");
public static CloudRegion GCP_Europe_West4 { get; } = new("europe-west4", "nl");
public static CloudRegion AWS_EU_West3 { get; } = new("eu-west-3", "fr");
public static CloudRegion AWS_EU_North1 { get; } = new("eu-north-1", "fi");
public static ComputingLocation Austria { get; } = new("at");
public static ComputingLocation Netherlands { get; } = new("nl");
public static ComputingLocation Finland { get; } = new("fi");
public static ComputingLocation Belgium { get; } = new("be");


private static Dictionary<string, ComputingLocation> Active { get; } = new(StringComparer.InvariantCultureIgnoreCase)
{
Expand All @@ -33,26 +43,38 @@ public static class ComputingLocations
{"Austria",Austria},
{"Switzerland",Switzerland},
{"UnitedKingdom",UnitedKingdom},
{"Netherlands",Netherlands},
{"Finland",Finland},
{"Belgium",Belgium},
{"London",UnitedKingdomLondon},
{"SouthWales",UnitedKingdomSouthWales},
{"GermanyWestCentral",Azure_Germany_WestCentral},
{"SwitzerlandNorth",Azure_Switzerland_North},
{"FranceCentral",Azure_France_Central},
{"UKSouth",Azure_UK_South},
{"UKWest",Azure_UK_West},
{"WestEurope",Azure_West_Europe},
{"eu-central-1",AWS_EU_Central1},
{"eu-central-2",AWS_EU_Central2},
{"eu-north-1",AWS_EU_North1},
{"eu-west-3",AWS_EU_West3},
{"europe-west1",GCP_Europe_West1},
{"europe-west3",GCP_Europe_West3},
{"europe-west4",GCP_Europe_West4},
{"europe-west6",GCP_Europe_West6},
{"europe-west9",GCP_Europe_West9},
{"europe-west10",GCP_Europe_West10},
{"europe-north1",GCP_Europe_North1},
};
public static List<ComputingLocation> All { get; } = new()
{
Germany,
France,
Austria,
Switzerland,
Belgium,
Finland,
Netherlands,
UnitedKingdom,
UnitedKingdomLondon,
UnitedKingdomSouthWales,
Expand All @@ -69,14 +91,12 @@ public static class ComputingLocations
GCP_Europe_West9,
new InactiveComputingLocation("az"),
new InactiveComputingLocation("ba"),
new InactiveComputingLocation("be"),
new InactiveComputingLocation("by"),
new InactiveComputingLocation("cy"),
new InactiveComputingLocation("cz"),
new InactiveComputingLocation("dk"),
new InactiveComputingLocation("ee"),
new InactiveComputingLocation("es"),
new InactiveComputingLocation("fi"),
new InactiveComputingLocation("ge"),
new InactiveComputingLocation("gr"),
new InactiveComputingLocation("hr"),
Expand All @@ -90,7 +110,6 @@ public static class ComputingLocations
new InactiveComputingLocation("mk"),
new InactiveComputingLocation("mt"),
new InactiveComputingLocation("nie"),
new InactiveComputingLocation("nl"),
new InactiveComputingLocation("no"),
new InactiveComputingLocation("pl"),
new InactiveComputingLocation("pt"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace CarbonAwareComputing.ForecastUpdater.Test
[TestClass]
public abstract class ContextSpecification
{
public static TestContext TestContext { get; set; }
public static TestContext? TestContext { get; set; }

[AssemblyInitialize]
public static void SetupTests(TestContext testContext)
Expand Down
Loading

0 comments on commit d3e70c6

Please sign in to comment.