Skip to content

Commit f79c822

Browse files
automatic loading default CCconfig.toml if not found
1 parent aa95c90 commit f79c822

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Project.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
88
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
99
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1010
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
11+
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
1112
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
1213
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1314
MPIClusterManagers = "e7922434-ae4b-11e9-05c5-9780451d2c66"
@@ -22,18 +23,19 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2223
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
2324

2425
[compat]
25-
AWS = "1.92.0"
26+
AWS = "1"
2627
Base64 = "1.10.4"
2728
Distributed = "1.10.4"
2829
FilePathsBase = "0.9.21"
29-
JSON = "0.21.4"
30+
Downloads = "1.6.0"
31+
JSON = "0.21"
3032
MPIClusterManagers = "0.2.4"
3133
PlatformAware = "0.6.1"
3234
Random = "1.10.4"
33-
Reexport = "1.2.2"
35+
Reexport = "1"
3436
Serialization = "1.10.4"
3537
Sockets = "1.10.4"
3638
TOML = "1.0.3"
3739
Test = "1.11.0"
38-
YAML = "0.4.12"
39-
julia = "1"
40+
YAML = "0.4"
41+
julia = "1"

src/config/configs.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Downloads
12

23
abstract type Localhost <: OnPremises end
34

@@ -17,32 +18,31 @@ function readCCConfig(config_file::String)
1718
close(io)
1819
contents
1920
catch
20-
default_location = "/etc/$config_file"
21+
# system wide location
2122
try
22-
# defaul system location
23+
default_location = "/etc/$config_file"
2324
io = open(default_location)
2425
contents = read(io,String)
2526
close(io)
2627
contents
2728
catch
28-
@info "The configuration file ($config_file) was not found."
29-
30-
# dpf_path = @get_scratch!("default_platform_path")
31-
# dpf_url = "https://raw.githubusercontent.com/PlatformAwareProgramming/PlatformAware.jl/manager/src/features/default/Platform.toml"
32-
# dpf_fname = joinpath(dpf_path, basename(dpf_url))
33-
# try_download(dpf_url, dpf_fname)
34-
35-
# read(dpf_fname,String)
29+
# NOTHING TO DO
3630
end
3731
end
3832

3933
#@info "=====> $ccconfig_toml"
4034
if isnothing(ccconfig_toml)
41-
@error "The configuration file ($config_file) was not found."
42-
return nothing
35+
@warn "A configuration file ($config_file) was not found. A default $config_file will be downloaded and copied to the current directory."
36+
fetch_default_configuration_file(config_file)
37+
return readCCConfig(config_file)
38+
else
39+
return TOML.parse(ccconfig_toml)
4340
end
41+
end
4442

45-
TOML.parse(ccconfig_toml)
43+
function fetch_default_configuration_file(config_file)
44+
url = "https://raw.githubusercontent.com/PlatformAwareProgramming/CloudClusters.jl/refs/heads/main/CCconfig.toml"
45+
Downloads.download(url, config_file)
4646
end
4747

4848
function loadDefaults(_::Type{Provider}, ccconfig_dict)

0 commit comments

Comments
 (0)