Repository: IAMconsortium/nomenclature

Issue:
Improve required data output
Currently the output of the `RequiredDataValidator` in the case of missing variables is not useful in understanding what exactly is missing. For example:

```console
2023-06-29 13:49:37 ERROR    Required data [{'region': ['ABW', 'AFG', 'AGO', 'ALB', 'ARE', 'ARG', 'ARM', 'ASM', 'ATG', 'AUS', 'AUT', 'AZE', 'BDI', 'BEL', 'BEN', 'BFA', 'BGD', 'BGR', 'BHR', 'BHS', 'BIH', 'BLR', 'BLZ', 'BMU', 'BOL', 'BRA', 'BRB', 'BRN', 'BTN', 'BWA', 'CAF', 'CAN', 'CHE', 'CHL', 'CHN', 'CIV', 'CMR', 'COD', 'COG', 'COK', 'COL', 'COM', 'CPV', 'CRI', 'CUB', 'CUW', 'CYM', 'CYP', 'CZE', 'DEU', 'DJI', 'DMA', 'DNK', 'DOM', 'DZA', 'ECU', 'EGY', 'ERI', 'ESH', 'ESP', 'EST', 'ETH', 'EU27', 'FIN', 'FJI', 'FLK', 'FRA', 'FRO', 'FSM', 'GAB', 'GBR', 'GEO', 'GHA', 'GIB', 'GIN', 'GLP', 'GMB', 'GNB', 'GNQ', 'GRC', 'GRD', 'GRL', 'GTM', 'GUF', 'GUM', 'GUY', 'HKG', 'HND', 'HRV', 'HTI', 'HUN', 'IDN', 'IND', 'IRL', 'IRN', 'IRQ', 'ISL', 'ISR', 'ITA', 'JAM', 'JOR', 'JPN', 'KAZ', 'KEN', 'KGZ', 'KHM', 'KIR', 'KNA', 'KOR', 'KWT', 'LAO', 'LBN', 'LBR', 'LBY', 'LCA', 'LIE', 'LKA', 'LSO', 'LTU', 'LUX', 'LVA', 'MAC', 'MAR', 'MDA', 'MDG', 'MDV', 'MEX', 'MHL', 'MKD', 'MLI', 'MLT', 'MMR', 'MNE', 'MNG', 'MOZ', 'MRT', 'MSR', 'MTQ', 'MUS', 'MWI', 'MYS', 'NAM', 'NCL', 'NER', 'NGA', 'NIC', 'NIU', 'NLD', 'NOR', 'NPL', 'NZL', 'OMN', 'PAK', 'PAN', 'PER', 'PHL', 'PLW', 'PNG', 'POL', 'PRI', 'PRK', 'PRT', 'PRY', 'PSE', 'PYF', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'SAU', 'SDN', 'SEN', 'SGP', 'SLB', 'SLE', 'SLV', 'SOM', 'SPM', 'SRB', 'SSD', 'STP', 'SUR', 'SVK', 'SVN', 'SWE', 'SWZ', 'SXM', 'SYC', 'SYR', 'TCA', 'TCD', 'TGO', 'THA', 'TJK', 'TKL', 'TKM', 'TLS', 'TON', 'TTO', 'TUN', 'TUR', 'TWN', 'TZA', 'UGA', 'UKR', 'URY', 'USA', 'UZB', 'VCT', 'VEN', 'VGB', 'VIR', 'VNM', 'VUT', 'WLF', 'WSM', 'YEM', 'ZAF', 'ZMB', 'ZWE'], 'year': [2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050], 'variable': 'Final Energy|Residential and Commercial|Electricity', 'unit': 'EJ/yr'}] from file applications/ngfs-phase-4-internal-workflow/required_data/Downscaling_requirements.yaml missing for:
                        model   scenario
0  Downscaling[GCAM 6.0 NGFS]  d_delfrag
1  Downscaling[GCAM 6.0 NGFS]   d_strain
2  Downscaling[GCAM 6.0 NGFS]     h_cpol
3  Downscaling[GCAM 6.0 NGFS]      h_ndc
4  Downscaling[GCAM 6.0 NGFS]     o_1p5c
5  Downscaling[GCAM 6.0 NGFS]       o_2c
6  Downscaling[GCAM 6.0 NGFS]   o_lowdem
```

does not tell us a lot in terms of region and year where the data is missing. 
This needs to be improved to give better feedback.

Discussion:
phackstock: Thanks for the review @dc-almeida, I'll go ahead with the merge now. 

Patch:
diff --git a/nomenclature/processor/required_data.py b/nomenclature/processor/required_data.py
index 3d229e8..65643bd 100644
--- a/nomenclature/processor/required_data.py
+++ b/nomenclature/processor/required_data.py
@@ -178,7 +178,13 @@ class RequiredDataValidator(Processor):
             for model, data_list in missing_data.items():
                 missing_data_log_info += f"Missing for '{model}':\n"
                 for data in data_list:
-                    missing_data_log_info += f"{data}\n\n"
+                    missing_data_log_info += (
+                        data.to_string(
+                            index=False,
+                            justify="left",
+                        )
+                        + "\n\n"
+                    )
             logger.error(
                 "Missing required data.\nFile: %s\n\n%s",
                 get_relative_path(self.file),
@@ -212,6 +218,7 @@ class RequiredDataValidator(Processor):
                         .to_frame()
                         .reset_index()
                         .drop(columns=["model"])
+                        .rename(columns={"year": "year(s)"})
                     )
         return missing_data
 


Test patch:
diff --git a/tests/data/required_data/required_data/requiredData_apply_error.yaml b/tests/data/required_data/required_data/requiredData_apply_error.yaml
index d309ddf..b52dd08 100644
--- a/tests/data/required_data/required_data/requiredData_apply_error.yaml
+++ b/tests/data/required_data/required_data/requiredData_apply_error.yaml
@@ -1,7 +1,7 @@
 model: model_a
 required_data:
   - measurand:
-    - Primary Energy:
+    - Primary Energy|Making sure that a really long variable is displayed completely:
         unit: [GWh/yr, Mtoe]
     year: [2005, 2010, 2015] # 2015 is missing from simple_df for all models
   - variable: Final Energy
diff --git a/tests/test_required_data.py b/tests/test_required_data.py
index e616e25..cbb9074 100644
--- a/tests/test_required_data.py
+++ b/tests/test_required_data.py
@@ -100,24 +100,20 @@ def test_RequiredData_apply_raises(simple_df, caplog):
         required_data_validator.apply(simple_df)
 
     missing_data = [
-        """
-  scenario        variable    unit            year
-0   scen_a  Primary Energy  GWh/yr  2005,2010,2015
-1   scen_a  Primary Energy    Mtoe  2005,2010,2015
-2   scen_b  Primary Energy  GWh/yr  2005,2010,2015
-3   scen_b  Primary Energy    Mtoe  2005,2010,2015""",
-        """
-  scenario      variable
-0   scen_a  Final Energy
-1   scen_b  Final Energy""",
-        """
-  scenario       variable       unit
-0   scen_a  Emissions|CO2  Mt CO2/yr
-1   scen_b  Emissions|CO2  Mt CO2/yr""",
-        """
-  scenario region      variable
-0   scen_a  World  Final Energy
-1   scen_b  World  Final Energy""",
+        """scenario variable                                                                       unit   year(s)""",
+        """scen_a   Primary Energy|Making sure that a really long variable is displayed completely GWh/yr 2005,2010,2015
+scen_a   Primary Energy|Making sure that a really long variable is displayed completely   Mtoe 2005,2010,2015
+scen_b   Primary Energy|Making sure that a really long variable is displayed completely GWh/yr 2005,2010,2015
+scen_b   Primary Energy|Making sure that a really long variable is displayed completely   Mtoe 2005,2010,2015""",
+        """scenario variable""",
+        """scen_a   Final Energy
+scen_b   Final Energy""",
+        """scenario variable      unit""",
+        """scen_a   Emissions|CO2 Mt CO2/yr
+scen_b   Emissions|CO2 Mt CO2/yr""",
+        """scenario region variable""",
+        """scen_a   World  Final Energy
+scen_b   World  Final Energy""",
     ]
     # check if the log message contains the correct information
     assert all(