Skip to content

Commit 77575fc

Browse files
Improving feature detection messages.
1 parent 57ff991 commit 77575fc

File tree

2 files changed

+66
-53
lines changed

2 files changed

+66
-53
lines changed

src/features/detection.jl

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,13 @@ end
408408
function identifyProcessor()
409409
try
410410
processor_features = collectProcessorFeatures_CpuId()
411-
println(stderr, "ok")
411+
412+
@info "Main processor detection succesful."
413+
412414
return processor_features
413-
catch error
414-
println(stderr, "fail.")
415-
println(stderr, "=> Error: detecting processor features failed. Using default features.")
416-
println(stderr, " You can setup processor features manually.")
415+
catch
416+
@warn "Main processor detection failed."
417+
@info "Detection of main processors failed. Using default features. You can setup manually."
417418
return collectProcessorFeaturesDefault()
418419
end
419420

@@ -477,7 +478,7 @@ function collectAcceleratorFeatures(l)
477478
i = i + 1
478479
end
479480

480-
return i == 2 ? accelerator_features["1"] : accelerator_features
481+
return i > 1 ? accelerator_features["1"] : accelerator_features
481482
end
482483

483484
function collectAcceleratorFeaturesDefault()
@@ -509,17 +510,18 @@ function identifyAccelerator()
509510
l[k] = haskey(l,k) ? l[k] + 1 : 1
510511
end
511512

512-
accelerator_features = if (length(l) > 0)
513+
accelerator_features = if (!isempty(l))
513514
collectAcceleratorFeatures(l)
514515
else
515516
collectAcceleratorFeaturesDefault()
516517
end
517-
println(stderr, "ok")
518+
519+
@info "Accelerator detection successful"
520+
518521
return accelerator_features
519-
catch error
520-
println(stderr, "fail.")
521-
println(stderr, "=> Error: detecting accelerator features failed. Using default features.")
522-
println(stderr, " You can setup accelerator features manually.")
522+
catch
523+
@warn "Accelerator detection failed."
524+
@info "Detection of accelerators failed. Using default features. You can setup manually."
523525
return collectAcceleratorFeaturesDefault()
524526
end
525527
end
@@ -554,7 +556,7 @@ function getMemorySize(mem_size)
554556
multiplier = Dict("KB" => 2^10, "MB" => 2^20, "GB" => 2^30, "TB" => 2^40, nothing => 1)
555557
return parse(Int64,match(r"^[-+]?[0-9]*\.?[0-9]+",mem_size).match) * multiplier[size_unit]
556558
catch error
557-
println(stderr,error)
559+
@warn string(error)
558560
return "unknown"
559561
end
560562

@@ -567,7 +569,7 @@ function getMemorySpeed(mem_speed)
567569
multiplier = Dict("MT/s" => 1, "GT/s" => 2^10, "MHz" => 1, "GHz" => 2^10, nothing => 1)
568570
return parse(Int64,match(r"^[-+]?[0-9]*\.?[0-9]+",mem_speed).match) * multiplier[speed_unit]
569571
catch error
570-
println(stderr,error)
572+
@warn string(error)
571573
return "unknown"
572574
end
573575
end
@@ -633,13 +635,14 @@ function identifyMemory()
633635
end
634636

635637
memory_features = collectMemoryFeatures(d1)
636-
println(stderr, "ok")
638+
639+
@info "Memory detection successfull."
640+
637641
return memory_features
638642

639-
catch error
640-
println(stderr, "fail.")
641-
println(stderr, "=> Error: detecting primary memory features failed. Using default features.")
642-
println(stderr, " You can setup primary memory features manually.")
643+
catch
644+
@warn "Memory detection failed."
645+
@info "Detection of memory features failed. Using default features. You can setup manually."
643646

644647
return collectMemoryFeaturesDefault()
645648
end
@@ -692,10 +695,12 @@ function identifyStorage()
692695
i = i + 1
693696
end
694697
end
695-
catch error
696-
println(stderr, "fail.")
697-
println(stderr, "=> Error: detection of storage features failed. Using default features.")
698-
println(stderr, " You can setup storage features manually.")
698+
699+
@info "Storage detection successfull."
700+
701+
catch
702+
@warn "Storage detection failed."
703+
@info "Detection of storage features failed. Using default features. You can setup manually."
699704

700705
# default
701706
storage_features["storage_type"] = "unset"
@@ -712,9 +717,9 @@ end
712717
# TODO
713718
function identityInterconnection()
714719

715-
println(stderr, "fail.")
716-
println(stderr, "=> Note: detection of interconnection features (cluster computing) not yet implemented. Using default features. You can setup manually.")
717-
println(stderr, " You can setup interconnection features manually.")
720+
@warn "Interconnection detection failed"
721+
@info "Detection of interconnection features (for cluster computing) not yet implemented. Using default features."
722+
@info "You can setup interconnection features manually."
718723

719724
interconnection_features = Dict()
720725

@@ -742,11 +747,15 @@ function identifyNode()
742747
node_features["node_vcpus_count"] = "unset"
743748

744749
for p in subtypes(CloudProvider)
745-
print(stderr, string(p) * "?")
750+
@info "Checking $(string(p)) provider."
746751
ok = getNodeFeatures(p, node_features)
747-
if (isnothing(ok)) print(stderr, "No") else print(stderr, "Yes") end; print(stderr, ", ")
752+
if (isnothing(ok))
753+
@info "$(string(p)) provider failed"
754+
else
755+
@info "$(string(p)) provider succesful"
756+
end;
748757
end
749-
print(stderr, "... ok")
758+
@info "Node identification complete."
750759
return node_features
751760
end
752761

@@ -777,43 +786,47 @@ end
777786

778787
function setup()
779788

780-
print("identifying node... "); node_features = identifyNode()
781-
print("identifying processor... "); processor_features = identifyProcessor()
782-
print("identifying accelerator... "); accelerator_features = identifyAccelerator()
783-
print("identifying memory... "); memory_features = identifyMemory()
784-
print("identifying storage... "); storage_features = identifyStorage()
785-
print("identifying interconnection... "); interconnection_features = identityInterconnection()
786-
787789
platform_features = Dict()
788790

791+
node_features = nothing
792+
793+
@sync begin
794+
@async begin @info "Started node identification."; node_features = identifyNode() end
795+
@async begin
796+
@info "Started processor detection."; processor_features = identifyProcessor();
797+
@info "Started accelerator detection."; accelerator_features = identifyAccelerator()
798+
@info "Started memory system detection."; memory_features = identifyMemory()
799+
@info "Started storage detection."; storage_features = identifyStorage()
800+
@info "Started interconnection detection."; interconnection_features = identityInterconnection()
801+
802+
addProcessorFeatures!(platform_features, processor_features)
803+
addAcceleratorFeatures!(platform_features, accelerator_features)
804+
addMemoryFeatures!(platform_features, memory_features)
805+
addStorageFeatures!(platform_features, storage_features)
806+
addInterconnectionFeatures!(platform_features, interconnection_features)
807+
end
808+
end
809+
789810
addNodeFeatures!(platform_features, node_features)
790-
addProcessorFeatures!(platform_features, processor_features)
791-
addAcceleratorFeatures!(platform_features, accelerator_features)
792-
addMemoryFeatures!(platform_features, memory_features)
793-
addStorageFeatures!(platform_features, storage_features)
794-
addInterconnectionFeatures!(platform_features, interconnection_features)
795-
796-
println(stderr)
797811

798812
if (!isfile("Platform.toml"))
799813
@sync begin
800-
Threads.@spawn TOML.print(stdout, platform_features)
801814
Threads.@spawn begin
802815
fn = open("Platform.toml","w")
803816
TOML.print(fn, platform_features)
804817
close(fn)
805818
end
806819
end
807-
@info "Platform.toml file was created in the current folder."
820+
@info "The platform description file (Platform.toml) was created in the current folder."
808821
@info "You can move it to your preferred target."
809822
@info "Platform.toml will be searched in the following locations:"
810823
@info " 1) A file path pointed by a PLATFORM_DESCRIPTION environment variable;"
811824
@info " 2) The current directory;"
812825
@info " 3) The /etc directory."
813826
else
814827
TOML.print(stdout, platform_features)
815-
@info "Platform description file already exists in the current folder (Platform.toml)."
816-
@info "You must delete or move it before creating a new one."
828+
@info "A platform description file (Platform.toml) already exists in the current folder. It will not be removed or overwritten."
829+
@info "You can see above the Platform.toml content calculated by the feature detection processing."
817830
end
818831

819832
end

src/features/qualifiers/ec2/ec2.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,12 @@ abstract type EC2Type_H1_16xLarge <: EC2Type_H1 end
777777

778778
##
779779
function get_instance_info(::Type{<:AmazonEC2})
780-
try
781-
global instance_id = JSON.parse(String(HTTP.request("GET", "http://169.254.169.254/latest/dynamic/instance-identity/document"; connect_timeout=10, readtimeout=10).body))
782-
# return instance_info["instanceType"], instance_info["region"]
783-
catch e
784-
return nothing
785-
end
780+
instance_id = try
781+
JSON.parse(String(HTTP.request("GET", "http://169.254.169.254/latest/dynamic/instance-identity/document"; connect_timeout=5, readtimeout=5).body))
782+
# return instance_info["instanceType"], instance_info["region"]
783+
catch e
784+
return nothing
785+
end
786786

787787
database_path = @get_scratch!("database_path")
788788
machinetypedb_ec2_url = "https://raw.githubusercontent.com/PlatformAwareProgramming/PlatformAware.jl/aws_ec2/src/features/qualifiers/ec2/db-machinetypes.ec2.csv"

0 commit comments

Comments
 (0)