Skip to content

Update notebook demo to run on Colab; add explanatory text#335

Merged
siddharth-krishna merged 5 commits intomainfrom
sid/colab-demo
Jun 9, 2025
Merged

Update notebook demo to run on Colab; add explanatory text#335
siddharth-krishna merged 5 commits intomainfrom
sid/colab-demo

Conversation

@siddharth-krishna
Copy link
Collaborator

@siddharth-krishna siddharth-krishna commented Jun 7, 2025

This PR updates the notebook demo to work on Google Colab. It also adds some text to explain what the demo is about and what else can be done (but just a sketch, please suggest how to extend/improve it!). The Demo 3 model is downloaded from a link to my drive.

Here is a shareable link to open the notebook from this branch on Colab:
https://colab.research.google.com/github/etsap-TIMES/xl2times/blob/sid/colab-demo/tests/notebook-demo.ipynb

}
],
"source": [
"%pip install gdx2py gamspy-base git+https://github.com/etsap-TIMES/xl2times.git"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this after release

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make a release before merging this PR then?

@github-actions
Copy link

github-actions bot commented Jun 7, 2025

Regression test results on commit d411ec4

         Benchmark    Time (s)                 GDX Diff     Accuracy       Correct    Additional
------------------  ----------  -----------------------  -----------  ------------  ------------
     DemoS_001-all   2.0   2.4            OK         OK  100.0 100.0    118    118      3      3
     DemoS_002-all   2.5   2.8            OK         OK  100.0 100.0    344    344      3      3
     DemoS_003-all   2.7   3.3            OK         OK  100.0 100.0    633    633      6      6
         DemoS_004   2.9   3.5            OK         OK  100.0 100.0    662    662     12     12
        DemoS_004a   2.8   3.9            OK         OK  100.0 100.0    665    665     12     12
DemoS_004a-ie-test   2.9   3.5            OK         OK  100.0 100.0    667    667     12     12
        DemoS_004b   3.1   3.6            OK         OK  100.0 100.0    665    665     12     12
     DemoS_004-all   3.0   3.2            OK         OK  100.0 100.0    667    667     12     12
     DemoS_005-all   3.4   4.3            13         13   99.7  99.7   1160   1160     12     12
     DemoS_006-all   4.3   5.3            13         13   99.7  99.7   1258   1258     12     12
     DemoS_007-all   5.4   6.3            13         13   99.8  99.8   2155   2155     12     12
  DemoS_007-all-1r   4.2   4.5            11         11   99.8  99.8   1179   1179     12     12
     DemoS_008-all   7.0   7.6            13         13   99.9  99.9   5333   5333     18     18
     DemoS_009-all   7.9   9.0            32         32   99.9  99.9   5807   5807     29     29
     DemoS_010-all   8.1   9.8            44         48   99.9  99.9   6941   6941     29     29
     DemoS_011-all   8.0   9.9            26         32   99.9  99.9   6982   6982     29     29
     DemoS_012-all   8.4   9.1            82         60   99.9  99.9   7149   7149     53     53
  DemoS_special-t1   4.2   4.6  Error runn… Error runn…   92.2  92.2   2108   2108     42     42
      TIMES-IE-all  23.9  24.4          3125       3125   97.5  97.5  42461  42461   2826   2826
      TIMES-IE-NoM  21.7  21.6           357        357   99.3  99.3  40529  40529    632    632
      TIMES-IE-MCB  22.6  22.1          1100       1100   97.6  97.6  42068  42068    632    632
      TIMES-NZ-KEA  25.0  25.8          3877       3877   98.5  98.5  76487  76487    341    341
      TIMES-NZ-TUI  17.8  16.7          3887       3887   98.5  98.5  76123  76123    347    347

2025-06-09 16:28:06.848 |     INFO : Total runtime: 207.37s (main: 193.50s)
2025-06-09 16:28:06.848 |     INFO : Change in runtime (negative == faster): +13.87s (+7.2%)
2025-06-09 16:28:06.848 |     INFO : Change in correct rows (higher == better): +0 (+0.0%)
2025-06-09 16:28:06.848 |     INFO : Change in additional rows: +0 (+0.0%)
2025-06-09 16:28:06.849 |  SUCCESS : No regressions. You're awesome!

This comment will be updated when new commits are added to the PR.

Comment on lines +319 to +322
"var_act = g._find_symbol(\"VAR_ACT\")\n",
"print(g._get_symtype(var_act)) # No idea what this means\n",
"# But the symbol exists in the file, it's just not a parameter\n",
"# Perhaps gdx2py doesn't support this type?"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olejandro no luck with these 2 new parameters. If I use gdxdump, I see them both having many lines of data in them. Any hints on what to extract and how to present their data?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both should be tables....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's figure this out later... I'll reach out to GAMS to ask about the future of the package.

@olejandro olejandro requested a review from Copilot June 9, 2025 13:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adapts the existing Jupyter notebook demo to run seamlessly on Google Colab, adds explanatory text for context, and updates setup and execution steps for both Colab and local environments.

  • Convert initial code cell to markdown introductory text.
  • Add Colab-specific installation and resource‐download steps.
  • Insert environment‐aware path logic and expand explanatory markdown.

"def inspect_solution():\n",
" with gdx2py.GdxFile(path.join(output_dir, \"scenario.gdx\"), gams_dir=directory) as g:\n",
" with gdx2py.GdxFile(\n",
" str(Path(output_dir) / \"scenario.gdx\"), gams_dir=directory\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" str(Path(output_dir) / \"scenario.gdx\"), gams_dir=directory\n",
" Path(output_dir) / \"scenario.gdx\", gams_dir=directory\n",

}
],
"source": [
"g = gdx2py.GdxFile(str(Path(output_dir) / \"scenario.gdx\"), gams_dir=directory)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"g = gdx2py.GdxFile(str(Path(output_dir) / \"scenario.gdx\"), gams_dir=directory)\n",
"g = gdx2py.GdxFile(Path(output_dir) / \"scenario.gdx\", gams_dir=directory)\n",

@siddharth-krishna siddharth-krishna enabled auto-merge (squash) June 9, 2025 16:26
@siddharth-krishna siddharth-krishna merged commit 32d2521 into main Jun 9, 2025
2 checks passed
@siddharth-krishna siddharth-krishna deleted the sid/colab-demo branch June 9, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants