@@ -38,37 +38,39 @@ def run_entrypoint(
3838 profile: The credentials profile to use.
3939 """
4040 add_py_folder (entrypoint )
41-
42- # Read dataspace from config.json if it exists
41+
42+ # Read dataspace from config.json (required)
4343 entrypoint_dir = os .path .dirname (entrypoint )
4444 config_json_path = os .path .join (entrypoint_dir , "config.json" )
45- if os .path .exists (config_json_path ):
46- try :
47- with open (config_json_path , "r" ) as f :
48- config_json = json .load (f )
49- dataspace = config_json .get ("dataspace" )
50- if dataspace :
51- # Add dataspace to reader config options
52- if (
53- config .reader_config
54- and hasattr (config .reader_config , "options" )
55- ):
56- config .reader_config .options ["dataspace" ] = dataspace
57- # Add dataspace to writer config options (for PrintDataCloudWriter)
58- if (
59- config .writer_config
60- and hasattr (config .writer_config , "options" )
61- ):
62- config .writer_config .options ["dataspace" ] = dataspace
63- except json .JSONDecodeError as err :
64- raise ValueError (
65- f"config.json at { config_json_path } is not valid JSON"
66- ) from err
67- except FileNotFoundError as err :
68- raise FileNotFoundError (
69- f"config.json not found at { config_json_path } "
70- ) from err
71-
45+
46+ if not os .path .exists (config_json_path ):
47+ raise FileNotFoundError (
48+ f"config.json not found at { config_json_path } . config.json is required."
49+ )
50+
51+ try :
52+ with open (config_json_path , "r" ) as f :
53+ config_json = json .load (f )
54+ except json .JSONDecodeError as err :
55+ raise ValueError (
56+ f"config.json at { config_json_path } is not valid JSON"
57+ ) from err
58+
59+ # Require dataspace to be present in config.json
60+ dataspace = config_json .get ("dataspace" )
61+ if not dataspace :
62+ raise ValueError (
63+ f"config.json at { config_json_path } is missing required field 'dataspace'. "
64+ f"Please ensure config.json contains a 'dataspace' field."
65+ )
66+
67+ # Add dataspace to reader config options
68+ if config .reader_config and hasattr (config .reader_config , "options" ):
69+ config .reader_config .options ["dataspace" ] = dataspace
70+ # Add dataspace to writer config options (for PrintDataCloudWriter)
71+ if config .writer_config and hasattr (config .writer_config , "options" ):
72+ config .writer_config .options ["dataspace" ] = dataspace
73+
7274 if profile != "default" :
7375 if config .reader_config and hasattr (config .reader_config , "options" ):
7476 config .reader_config .options ["credentials_profile" ] = profile
0 commit comments