Skip to content

Commit ae29606

Browse files
committed
Fix bug
1 parent 321739e commit ae29606

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

myst_libre/tools/build_source_manager.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,19 @@ def git_checkout_commit(self):
7878
def get_project_name(self):
7979
"""
8080
Get the project name from the data requirement file.
81+
If the file doesn't exist, use the repository name.
8182
8283
Returns:
83-
str: Project name.
84+
str: Project name or repository name.
8485
"""
8586
data_config_dir = os.path.join(self.build_dir, 'binder', 'data_requirement.json')
86-
with open(data_config_dir, 'r') as file:
87-
data = json.load(file)
88-
self.dataset_name = data['projectName']
87+
if os.path.isfile(data_config_dir):
88+
with open(data_config_dir, 'r') as file:
89+
data = json.load(file)
90+
self.dataset_name = data.get('projectName', self.repo_name)
91+
else:
92+
self.cprint(f'Data requirement file not found at {data_config_dir}, using repository name', "yellow")
93+
self.dataset_name = None
8994

9095
def repo2data_download(self,target_directory):
9196
data_req_path = os.path.join(self.build_dir, 'binder', 'data_requirement.json')

0 commit comments

Comments
 (0)