qiaojunfeng commited on
Commit
61de2dc
·
1 Parent(s): 250618e

Generate initial datasets

Browse files
Files changed (3) hide show
  1. Artifacts.toml +87 -0
  2. docs/CONTRIBUTING.md +4 -0
  3. make_artifacts.jl +26 -10
Artifacts.toml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Cu]
2
+ git-tree-sha1 = "7a62b6fd9cf0b8414d402bf5109ab1e4e3770812"
3
+ lazy = true
4
+
5
+ [[Cu.download]]
6
+ sha256 = "1a140584aab78b59171bb75c4d4e741646a0e7162dd50577f771f3287fc62128"
7
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/Cu.tar.gz"
8
+
9
+ [Si2_valence]
10
+ git-tree-sha1 = "69abcb33e42a08354b68dae0c4ced116b6234d70"
11
+ lazy = true
12
+
13
+ [[Si2_valence.download]]
14
+ sha256 = "ed279ed6d3f6fbd7d953633d0574230d3d405eefc6798a59e587fa8ebe175446"
15
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/Si2_valence.tar.gz"
16
+
17
+ [CrI3]
18
+ git-tree-sha1 = "888fc3a5816e746cf3b7ddd2c469b89ae0f7e7da"
19
+ lazy = true
20
+
21
+ [[CrI3.download]]
22
+ sha256 = "5f24343dd393117213a329f8f850e3e967b91634ea1f6723cc5a3c1a1a55be2b"
23
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/CrI3.tar.gz"
24
+
25
+ [MoS2]
26
+ git-tree-sha1 = "2b36703f7e686b5b3e40bcdbd86688e80be4a4d6"
27
+ lazy = true
28
+
29
+ [[MoS2.download]]
30
+ sha256 = "37127125dbf63455034bf918186b4bbe87d8b6739d4fd217f05e060b54aa9fc1"
31
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/MoS2.tar.gz"
32
+
33
+ [BN]
34
+ git-tree-sha1 = "5c6644b683c4783271d99973e21156daa2075bac"
35
+ lazy = true
36
+
37
+ [[BN.download]]
38
+ sha256 = "af312e7f4e5b75765abd669934660e13048cf9cc402b105416a449a35290d55e"
39
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/BN.tar.gz"
40
+
41
+ [SnSe2]
42
+ git-tree-sha1 = "b45310314ba59112420850678fa416fcbbd7aa6a"
43
+ lazy = true
44
+
45
+ [[SnSe2.download]]
46
+ sha256 = "8ed6355a0746a7b69e48080abc60e5beda324591b46ef5f3e5325407d1917d38"
47
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/SnSe2.tar.gz"
48
+
49
+ [Fe_collinear]
50
+ git-tree-sha1 = "7491f2d773a5f682f83cf46120ae3ef8430c0f99"
51
+ lazy = true
52
+
53
+ [[Fe_collinear.download]]
54
+ sha256 = "176e34a5a5786fdcc12175444bde251a320150ddf5f4040fb91d2bfc5ac94f65"
55
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/Fe_collinear.tar.gz"
56
+
57
+ [Fe_soc]
58
+ git-tree-sha1 = "61ccd2c018e0934c3541b85c32a8bd0ee957e2d7"
59
+ lazy = true
60
+
61
+ [[Fe_soc.download]]
62
+ sha256 = "7effe3c3827c23571d970e69db4499a068e1bbdce3ae18be10532e7d21bd9e1c"
63
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/Fe_soc.tar.gz"
64
+
65
+ [graphene]
66
+ git-tree-sha1 = "600f801c60eba4eb34c7d6396de079a597bc29cc"
67
+ lazy = true
68
+
69
+ [[graphene.download]]
70
+ sha256 = "b9f399a3875fa1cff5dc95437c863b4b1090d3658e48be6724a54cbffb3175a2"
71
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/graphene.tar.gz"
72
+
73
+ [CuBr2]
74
+ git-tree-sha1 = "1cb8c060dd58a341f243216ba96932660f7310d4"
75
+ lazy = true
76
+
77
+ [[CuBr2.download]]
78
+ sha256 = "7d305aea2ddfbb6e7d9036e6110c4e7272e5ba90544532681d622cf2fdb1aaa0"
79
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/CuBr2.tar.gz"
80
+
81
+ [Si2]
82
+ git-tree-sha1 = "1459f891f478ff64c3d1296c634ad441611778b2"
83
+ lazy = true
84
+
85
+ [[Si2.download]]
86
+ sha256 = "0dcdd64a0955a88258dd839687469449e9c5aae9a5c20335fb3cec840dba917a"
87
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/Si2.tar.gz"
docs/CONTRIBUTING.md CHANGED
@@ -43,6 +43,10 @@ Pull requests are the best way to propose changes to the codebase.
43
  We actively welcome your pull requests:
44
 
45
  1. Fork the repo and create your branch from `main`.
 
 
 
 
46
  2. Add dataset(s), ideally small (in terms of file size) but still gives
47
  physical results. The `prefix` of the files (i.e. `prefix.amn`/`prefix.mmn`)
48
  should be the same as the folder name, to allow easy loading of the dataset
 
43
  We actively welcome your pull requests:
44
 
45
  1. Fork the repo and create your branch from `main`.
46
+ ```shell
47
+ # clone the repo, remember to replace the username with your own username
48
+ git clone [email protected]:datasets/atomology/WannierDatasets
49
+ ```
50
  2. Add dataset(s), ideally small (in terms of file size) but still gives
51
  physical results. The `prefix` of the files (i.e. `prefix.amn`/`prefix.mmn`)
52
  should be the same as the folder name, to allow easy loading of the dataset
make_artifacts.jl CHANGED
@@ -8,12 +8,15 @@
8
  # Artifacts docs:
9
  # https://pkgdocs.julialang.org/v1/artifacts/
10
  #
 
 
 
11
  using Tar, Inflate, SHA, TOML
12
  using Dates: unix2datetime
13
 
14
  const artifacts_dir = joinpath(@__DIR__, "artifacts")
15
  const datasets_dir = joinpath(@__DIR__, "datasets")
16
- const deploy_branch = "artifacts"
17
 
18
  """
19
  folder: e.g. `"Si2"`
@@ -68,7 +71,7 @@ function create_artifact(folder::AbstractString; local_url::Bool=false)
68
  url = "file://$(outpath)"
69
  else
70
  # use huggingface `artifacts` branch to host the artifacts
71
- url = "https://huggingface.co/datasets/atomology/WannierDatasets/blob/artifacts/$(tar_name)"
72
  end
73
 
74
  artifact_name = folder
@@ -99,6 +102,11 @@ function git_date(githash::AbstractString)
99
  end
100
 
101
  function list_previous_artifacts()
 
 
 
 
 
102
  files = split(read(`git ls-tree -r --name-only $deploy_branch`, String))
103
  filter!(f -> endswith(f, ".tar.gz"), files)
104
  return Dict(f => git_hash(f; deploy_branch) for f in files)
@@ -127,11 +135,19 @@ function list_new_folders()
127
  end
128
 
129
  function upload_artifacts(names::AbstractVector)
130
- paths = map(names) do name
131
- joinpath(artifacts_dir, "$(name).tar.gz")
132
- end
133
- println("huggingface-cli upload --repo-type dataset --revision $deploy_branch atomology/WannierDatasets \\")
134
- println(join(paths, " \\\n"))
 
 
 
 
 
 
 
 
135
  end
136
 
137
  function clean_artifacts_dir()
@@ -141,7 +157,7 @@ function clean_artifacts_dir()
141
  println("Aborting...")
142
  return false
143
  end
144
- rm(artifacts_dir; force=true, recurive=true)
145
  mkpath(artifacts_dir)
146
  println("Cleaned `$(artifacts_dir)` folder.")
147
  return true
@@ -152,12 +168,12 @@ function (@main)(args)
152
  if isfile(toml_path)
153
  artifacts = TOML.parsefile(toml_path)
154
  else
155
- artifacts = Dict{String, Any}()
156
  end
157
 
158
  new_folders = list_new_folders()
159
 
160
- if length(args) > 0 && args[1] != "dryrun"
161
  clean_artifacts_dir() || return
162
 
163
  for folder in new_folders
 
8
  # Artifacts docs:
9
  # https://pkgdocs.julialang.org/v1/artifacts/
10
  #
11
+ using Pkg
12
+ Pkg.instantiate()
13
+
14
  using Tar, Inflate, SHA, TOML
15
  using Dates: unix2datetime
16
 
17
  const artifacts_dir = joinpath(@__DIR__, "artifacts")
18
  const datasets_dir = joinpath(@__DIR__, "datasets")
19
+ const deploy_branch = "artifacts"
20
 
21
  """
22
  folder: e.g. `"Si2"`
 
71
  url = "file://$(outpath)"
72
  else
73
  # use huggingface `artifacts` branch to host the artifacts
74
+ url = "https://huggingface.co/datasets/atomology/WannierDatasets/resolve/artifacts/$(tar_name)"
75
  end
76
 
77
  artifact_name = folder
 
102
  end
103
 
104
  function list_previous_artifacts()
105
+ # if this command fails with the error
106
+ # `fatal: Not a valid object name artifacts`
107
+ # you need to run at least once
108
+ # `git checkout artifacts`
109
+ # to create the artifacts branch
110
  files = split(read(`git ls-tree -r --name-only $deploy_branch`, String))
111
  filter!(f -> endswith(f, ".tar.gz"), files)
112
  return Dict(f => git_hash(f; deploy_branch) for f in files)
 
135
  end
136
 
137
  function upload_artifacts(names::AbstractVector)
138
+ files = join(["$(n).tar.gz" for n in names], "\n")
139
+ println("\n\n# $(length(names)) Files to be uploaded to huggingface")
140
+
141
+ commit_msg = "Upload artifacts v1.1.0"
142
+ commit_desc = files
143
+ println()
144
+ println("huggingface-cli upload " *
145
+ "atomology/WannierDatasets $artifacts_dir . " *
146
+ "--repo-type dataset " *
147
+ "--revision $deploy_branch " *
148
+ "--include \"*.tar.gz\" " *
149
+ "--commit-message \"$commit_msg\" " *
150
+ "--commit-description \"$commit_desc\"")
151
  end
152
 
153
  function clean_artifacts_dir()
 
157
  println("Aborting...")
158
  return false
159
  end
160
+ rm(artifacts_dir; force=true, recursive=true)
161
  mkpath(artifacts_dir)
162
  println("Cleaned `$(artifacts_dir)` folder.")
163
  return true
 
168
  if isfile(toml_path)
169
  artifacts = TOML.parsefile(toml_path)
170
  else
171
+ artifacts = Dict{String,Any}()
172
  end
173
 
174
  new_folders = list_new_folders()
175
 
176
+ if !("dryrun" in args)
177
  clean_artifacts_dir() || return
178
 
179
  for folder in new_folders