Skip to content

Commit c64be06

Browse files
committed
excluding items
1 parent a453068 commit c64be06

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
[spaces]
22
space_ids = [
3+
"66ec6210e4b08e5e86b30c20",
4+
"62d992dce4b0e32fd16081f4"
5+
]
6+
exclude_space_ids = [
37

48
]
59

610
[users]
7-
user_email = [
11+
user_emails = [
12+
13+
14+
15+
16+
]
17+
exclude_space_ids = [
18+
819
]
920

10-
[exclude_users]
11-
exclude_user_emails = [
21+
[datasets]
22+
dataset_ids = [
1223

13-
]
24+
]
25+
exclude_dataset_ids = [
26+
"66eb1ddfe4b08e5e86b2e124"
27+
]

scripts/migration/migrate.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,24 @@
2525

2626
# Load environment variables
2727
path_to_env = os.path.join(os.getcwd(),"scripts","migration", ".env")
28+
path_to_toml = os.path.join(os.getcwd(),"scripts","migration", "config.toml")
2829
config = dotenv_values(dotenv_path=path_to_env)
2930

31+
toml_space_ids=None
32+
toml_exclude_space_ids=None
33+
toml_users=None
34+
toml_exclude_users=None
35+
toml_exclude_dataset_ids=None
36+
37+
# Load configuration from toml file
38+
if os.path.exists(path_to_toml):
39+
toml_config = tomllib.loads(open(path_to_toml).read())
40+
print(f"Loaded toml config")
41+
toml_space_ids = toml_config["spaces"]["space_ids"]
42+
toml_users = toml_config["users"]["user_emails"]
43+
toml_exclude_dataset_ids = toml_config["datasets"]["exclude_dataset_ids"]
44+
45+
3046
CLOWDER_V1 = config["CLOWDER_V1"]
3147
ADMIN_KEY_V1 = config["ADMIN_KEY_V1"]
3248
CLOWDER_V2 = config["CLOWDER_V2"]
@@ -791,6 +807,14 @@ def process_user_and_resources(user_v1, USER_MAP, DATASET_MAP):
791807
USER_MAP = {}
792808
DATASET_MAP = {}
793809
users_v1 = get_clowder_v1_users()
810+
# TODO filter if toml users
811+
if toml_users is not None and len(toml_users) > 0:
812+
print(f"Using spaces from config.toml: {toml_users}")
813+
users_v1 = [
814+
user for user in users_v1 if user["email"] in toml_users
815+
]
816+
else:
817+
print("No spaces specified in config.toml, migrating all users.")
794818
for user_v1 in users_v1:
795819
if (
796820
"[Local Account]" in user_v1["identityProvider"]

0 commit comments

Comments
 (0)