Skip to content

Commit 2501b7f

Browse files
committed
add attribute names to ipython.display methods
1 parent 85259df commit 2501b7f

File tree

2 files changed

+28
-48
lines changed

2 files changed

+28
-48
lines changed

pvdeg/geospatialscenario.py

+17-38
Original file line numberDiff line numberDiff line change
@@ -980,64 +980,43 @@ def _check_set(self, iterable, to_check: set):
980980
if not iterable.issubset(to_check):
981981
raise ValueError(f"All of iterable: {iterable} does not exist in {to_check}")
982982

983-
984-
# GeospatialScenario no longer uses pipeline, instead job attributes are stored in attrbutes "func", "template"
985-
# def format_pipeline(self):
986-
# pipeline_html = "<div>"
987-
# if "geospatial_job" in self.pipeline:
988-
# step_name = "geospatial_job"
989-
# step = self.pipeline[step_name]
990-
# params_html = f"<pre>{json.dumps(step['params'], indent=2)}</pre>"
991-
992-
# step_content = f"""
993-
# <div id="{step_name}" onclick="toggleVisibility('pipeline_{step_name}')" style="cursor: pointer; background-color: #000000; color: #FFFFFF; padding: 5px; border-radius: 3px; margin-bottom: 1px;">
994-
# <h4 style="font-family: monospace; margin: 0;">
995-
# <span id="arrow_pipeline_{step_name}" style="color: #b676c2;">►</span>
996-
# {step['job'].__name__}, <span style="color: #b676c2;">#{step_name}</span>
997-
# </h4>
998-
# </div>
999-
# <div id="pipeline_{step_name}" style="display:none; margin-left: 20px; padding: 5px; background-color: #f0f0f0; color: #000;">
1000-
# <p>Job: {step['job'].__name__}</p>
1001-
# <p>Parameters:</p>
1002-
# <div style="margin-left: 20px;">
1003-
# {params_html}
1004-
# </div>
1005-
# </div>
1006-
# """
1007-
# pipeline_html += step_content
1008-
# pipeline_html += "</div>"
1009-
# return pipeline_html
983+
def format_geospatial_work(self):
984+
if self.func:
985+
return f"""
986+
<p><strong>self.func:</strong> {self.func.__name__}</p>
987+
<p><strong>self.template:</strong> {self.format_template()}</p>
988+
"""
1010989

1011990
def _ipython_display_(self):
1012991
file_url = f"file:///{os.path.abspath(self.path).replace(os.sep, '/')}"
1013992
html_content = f"""
1014993
<div style="border:1px solid #ddd; border-radius: 5px; padding: 3px; margin-top: 5px;">
1015-
<h2>{self.name}: Scenario Analysis</h2>
1016-
<p><strong>Path:</strong> <a href="{file_url}" target="_blank">{self.path}</a></p>
1017-
<p><strong>HPC Configuration:</strong> {self.hpc}</p>
1018-
<p><strong>GIDs:</strong> {self.gids}</p>
994+
<h2>self.name: {self.name}</h2>
995+
<p><strong>self.path:</strong> <a href="{file_url}" target="_blank">{self.path}</a></p>
996+
<p><strong>self.hpc:</strong> {self.hpc}</p>
997+
<p><strong>self.gids:</strong> {self.gids}</p>
1019998
<div>
1020-
<h3>Results</h3>
999+
<h3>self.results</h3>
10211000
{self.format_results() if self.results else None}
10221001
</div>
10231002
<div>
1024-
<h3>Geospatial Job</h3>
1025-
Function : {self.func.__name__}
1026-
{self.format_template()}
1003+
<h3>Geospatial Work</h3>
1004+
{self.format_geospatial_work()}
10271005
</div>
10281006
<div>
1029-
<h3>Modules</h3>
1007+
<h3>self.modules</h3>
10301008
{super().format_modules()}
10311009
</div>
10321010
<div>
1033-
<h3>Weather Dataset</h3>
1011+
<h3>self.weather_data</h3>
10341012
{self.format_geo_weather()}
10351013
</div>
10361014
<div>
1037-
<h3>Meta Dataframe</h3>
1015+
<h3>self.meta_data</h3>
10381016
{self.format_geo_meta()}
10391017
</div>
10401018
</div>
1019+
<p><i>All attributes can be accessed by the names shown above.</i></p>
10411020
<script>
10421021
function toggleVisibility(id) {{
10431022
var content = document.getElementById(id);

pvdeg/scenario.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -875,32 +875,33 @@ def _ipython_display_(self):
875875

876876
html_content = f"""
877877
<div style="border:1px solid #ddd; border-radius: 5px; padding: 3px; margin-top: 5px;">
878-
<h2>{self.name}: Scenario Analysis</h2>
879-
<p><strong>Path:</strong> <a href="{file_url}" target="_blank">{self.path}</a></p>
880-
<p><strong>GIDs:</strong> {self.gids}</p>
881-
<p><strong>Email:</strong> {self.email}</p>
882-
<p><strong>API Key:</strong> {self.api_key}</p>
878+
<h2>self.name: {self.name}</h2>
879+
<p><strong>self.path:</strong> <a href="{file_url}" target="_blank">{self.path}</a></p>
880+
<p><strong>self.gids:</strong> {self.gids}</p>
881+
<p><strong>self.email:</strong> {self.email}</p>
882+
<p><strong>self.api_key:</strong> {self.api_key}</p>
883883
<div>
884-
<h3>Results</h3>
884+
<h3>self.results</h3>
885885
{self.format_results() if self.results else None}
886886
</div>
887887
<div>
888-
<h3>Pipeline</h3>
888+
<h3>self.pipeline</h3>
889889
{self.format_pipeline()}
890890
</div>
891891
<div>
892-
<h3>Modules</h3>
892+
<h3>self.modules</h3>
893893
{self.format_modules()}
894894
</div>
895895
<div>
896-
<h3>Weather Data</h3>
896+
<h3>self.weather_data</h3>
897897
{self.format_weather()}
898898
</div>
899899
<div>
900-
<h3>Meta Data</h3>
900+
<h3>self.meta_data</h3>
901901
{self.meta_data}
902902
</div>
903903
</div>
904+
<p><i>All attributes can be accessed by the names shown above.</i></p>
904905
<script>
905906
function toggleVisibility(id) {{
906907
var content = document.getElementById(id);

0 commit comments

Comments
 (0)