Skip to content

Commit d6f75a7

Browse files
Merge branch 'main' into compathelper/new_version/2024-11-27-03-22-11-231-00492685430
2 parents a796a1d + 955fe6f commit d6f75a7

File tree

4 files changed

+83
-38
lines changed

4 files changed

+83
-38
lines changed

Project.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2222
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
2323

2424
[compat]
25+
AWS = "1"
2526
Base64 = "1.10.4"
2627
Distributed = "1.10.4"
2728
FilePathsBase = "0.9.21"
29+
JSON = "0.21.4"
2830
MPIClusterManagers = "0.2.4"
2931
PlatformAware = "0.6.1"
3032
Random = "1.10.4"
3133
Reexport = "1"
3234
Serialization = "1.10.4"
3335
Sockets = "1.10.4"
3436
TOML = "1.0.3"
35-
Test = "1.11.0"
37+
Test = "1.11.0"
38+
YAML = "0.4"
39+
julia = "1"

docs/src/index.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ _CloudClusters.jl_ assumes that the user has configured their credentials for th
2525
Creating clusters with _CloudClusters.jl_ requires specifying some configuration parameters. By default, they are specified in a file named _CCconfig.toml_ that is searched in the following locations, in this order:
2626
* a path pointed by the CLOUD_CLUSTERS_CONFIG environment variable, if it exists;
2727
* the current path.
28-
28+
29+
Section [Configuration parameters](https://github.com/PlatformAwareProgramming/CloudClusters.jl#configuration-parameters) describes configuration parameters and how they can be overridden in programs.
30+
2931
Default configuration parameters can be overridden in programs.
3032

31-
Section [Configuration parameters](https://github.com/PlatformAwareProgramming/CloudClusters.jl#configuration-parameters) describes configuration parameters and how they can be overridden in programs.
33+
A [_CCconfig.toml_](https://raw.githubusercontent.com/PlatformAwareProgramming/CloudClusters.jl/refs/heads/main/CCconfig.toml) file is provided in the repository's top-level directory. It is configured to create clusters using prebuilt virtual machine images for each supported cloud provider. These images are based on the latest version of Ubuntu and include a Julia installation of a recent stable version with all the packages needed to instantiate the clusters added and precompiled. Users can create customized images, possibly derived from the provided image, using their preferred version of Julia and adding the packages they need.
34+
35+
> [!NOTE]
36+
> The version of Julia on the host computer using _CloudClusters.jl_ must be the same version as the image used to deploy the clusters.
3237
3338
### The _PlatformAware.jl_ package
3439

@@ -192,7 +197,7 @@ julia> @nodes my_second_cluster
192197
12
193198
13
194199
195-
julia> @nodes my_third_cluster
200+
julia> @ nodes my_third_cluster
196201
8-element Vector{Int64}
197202
14
198203
15

src/CloudClusters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using Reexport
77
using Base.Threads
88
using Dates
99
using TOML
10+
using AWS
1011

1112
include("config/configs.jl")
1213
include("features/features.jl")

src/cluster_providers/ec2/ec2_backend.jl

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,6 @@
33
For this module to work, you`ll need AWS credentials in the ${HOME}/.aws directory.
44
=#
55

6-
#=
7-
1. Create placement group.
8-
2. Create EFS Filesystem.
9-
3. Create EC2 instances and attach them to the EFS.
10-
=#
11-
12-
using AWS
13-
println("Adaptando o código do Módulo AWS.jl...")
14-
using FilePathsBase
15-
aws_package_dir = ENV["HOME"] * "/.julia/packages/AWS"
16-
all_entries = readdir(aws_package_dir)
17-
subdirs = filter(entry -> isdir(joinpath(aws_package_dir, entry)), all_entries)
18-
19-
for subdir in subdirs
20-
ec2_file = joinpath(aws_package_dir, subdir, "src", "services", "ec2.jl")
21-
chmod(ec2_file, 0o644)
22-
content = read(ec2_file, String)
23-
new_content = replace(content, "Dict{String,Any}(\"groupName\" => groupName);" => "Dict{String,Any}(\"GroupName\" => groupName);")
24-
new_content = replace(new_content, "\"MaxCount\" => MaxCount, \"MinCount\" => MinCount, \"clientToken\" => string(uuid4())" =>
25-
"\"MaxCount\" => MaxCount, \"MinCount\" => MinCount, \"ClientToken\" => string(uuid4())")
26-
new_content = replace(new_content, "\"clientToken\" => string(uuid4())" => "\"ClientToken\" => string(uuid4())")
27-
open(ec2_file, "w") do io
28-
write(io, new_content)
29-
end
30-
end
31-
326
using Random
337
using AWS: @service
348
using Serialization
@@ -113,7 +87,6 @@ function ec2_create_cluster(cluster::Cluster)
11387
end
11488

11589

116-
11790
function ec2_get_ips_instance(instance_id::String)
11891
public_ip = Ec2.describe_instances(Dict("InstanceId" => instance_id))["reservationSet"]["item"]["instancesSet"]["item"]["ipAddress"]
11992
private_ip = Ec2.describe_instances(Dict("InstanceId" => instance_id))["reservationSet"]["item"]["instancesSet"]["item"]["privateIpAddress"]
@@ -150,7 +123,7 @@ end
150123

151124
function ec2_delete_placement_group(name)
152125
params = Dict("GroupName" => name)
153-
Ec2.delete_placement_group(name)
126+
delete_placement_group(name)
154127
end
155128

156129
#=
@@ -195,8 +168,6 @@ end
195168
Criação de Instâncias
196169
=#
197170

198-
199-
200171
# Funções auxiliares.
201172
function ec2_set_up_ssh_connection(cluster_name)
202173

@@ -382,14 +353,14 @@ chown -R ubuntu:ubuntu /home/ubuntu/shared
382353
# Criando as instâncias
383354
params_manager, params_workers = ec2_create_params(cluster, user_data_base64)
384355
# Criar o headnode
385-
instance_headnode = Ec2.run_instances(1, 1, params_manager)
356+
instance_headnode = run_instances(1, 1, params_manager)
386357
cluster_nodes[:manager] = instance_headnode["instancesSet"]["item"]["instanceId"]
387358

388359
# Criar os worker nodes.
389360
params_workers["InstanceType"] = cluster.instance_type_worker
390361
params_workers["TagSpecification"]["Tag"][2]["Value"] = "worker"
391362
count = cluster.count
392-
instances_workers = Ec2.run_instances(count, count, params_workers)
363+
instances_workers = run_instances(count, count, params_workers)
393364
workers = count
394365
for i in 1:count
395366
instance = ""
@@ -435,7 +406,7 @@ chown -R ubuntu:ubuntu /home/ubuntu/shared
435406

436407
# Criar os Peers.
437408
count = cluster.count
438-
instances_peers = Ec2.run_instances(count, count, params)
409+
instances_peers = run_instances(count, count, params)
439410
for i in 1:count
440411
instance = ""
441412
if count > 1
@@ -640,4 +611,68 @@ function ec2_get_ips(cluster::Cluster)
640611
ips[node] = ec2_get_ips_instance(id)
641612
end
642613
ips
643-
end
614+
end
615+
616+
617+
618+
function delete_placement_group(
619+
groupName; aws_config::AbstractAWSConfig=global_aws_config()
620+
)
621+
return Ec2.ec2(
622+
"DeletePlacementGroup",
623+
Dict{String,Any}("GroupName" => groupName);
624+
aws_config=aws_config,
625+
feature_set=Ec2.SERVICE_FEATURE_SET,
626+
)
627+
end
628+
function delete_placement_group(
629+
groupName,
630+
params::AbstractDict{String};
631+
aws_config::AbstractAWSConfig=global_aws_config(),
632+
)
633+
return Ec2.ec2(
634+
"DeletePlacementGroup",
635+
Dict{String,Any}(
636+
mergewith(_merge, Dict{String,Any}("GroupName" => groupName), params)
637+
);
638+
aws_config=aws_config,
639+
feature_set= Ec2.SERVICE_FEATURE_SET,
640+
)
641+
end
642+
643+
function run_instances(
644+
MaxCount, MinCount; aws_config::AbstractAWSConfig=global_aws_config()
645+
)
646+
return Ec2.ec2(
647+
"RunInstances",
648+
Dict{String,Any}(
649+
"MaxCount" => MaxCount, "MinCount" => MinCount, "ClientToken" => string(Ec2.uuid4())
650+
);
651+
aws_config=aws_config,
652+
feature_set=Ec2.SERVICE_FEATURE_SET,
653+
)
654+
end
655+
function run_instances(
656+
MaxCount,
657+
MinCount,
658+
params::AbstractDict{String};
659+
aws_config::AbstractAWSConfig=global_aws_config(),
660+
)
661+
return Ec2.ec2(
662+
"RunInstances",
663+
Dict{String,Any}(
664+
mergewith(
665+
_merge,
666+
Dict{String,Any}(
667+
"MaxCount" => MaxCount,
668+
"MinCount" => MinCount,
669+
"ClientToken" => string(Ec2.uuid4()),
670+
),
671+
params,
672+
),
673+
);
674+
aws_config=aws_config,
675+
feature_set=Ec2.SERVICE_FEATURE_SET,
676+
)
677+
end
678+

0 commit comments

Comments
 (0)