Skip to content

Commit

Permalink
Add offline mode arg to icat initialize function
Browse files Browse the repository at this point in the history
  • Loading branch information
WarmCyan committed Aug 22, 2023
1 parent 145ed4c commit 24ae62b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

### Added
* Offline mode arg to ``icat.initialize()``.

### Fixed
* Instance viewer missing search highlight.



## [0.5.0] - 2023-08-21

### Added
Expand Down
14 changes: 10 additions & 4 deletions icat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__version__ = "0.5.0"


def initialize():
def initialize(offline: bool = False):
"""Set up panel and ICAT-specific stylesheets.
Call this function before running any ICAT model ``.view`` cells.
Expand All @@ -35,15 +35,21 @@ def initialize():
Note that there's a weird conflict between ipyvuetify and panel where if you don't
run this initialize function, you may need to run your first ``model.view`` cell twice
for the stylesheets to correctly apply to some of the ipyvuetify datatables.
Args:
offline (bool): If set to true, will configure panel to draw js/css resources from
local packages rather than hitting a CDN for them.
"""
pn.extension("vega")
pn.extension("vega", inline=offline)

# pre render the anchorlist template once (invisibly) so that the css gets loaded
# (there's a weird conflict between the ghost dom that panel uses and how ipyvuetify
# components seem to get their ghost dom styling.)
# Yes this is a ridiculous hack. No, I no longer care, I've spent way too much time
# trying to make it so the user doesn't have to execute their first model.view cell twice.
from icat.anchorlist import AnchorListTemplate
from icat.table import TableContentsTemplate

# TODO: may need to do the same for the data table
return pn.Row(AnchorListTemplate(), styles={"display": "none"})
return pn.Row(
AnchorListTemplate(), TableContentsTemplate(), styles={"display": "none"}
)
26 changes: 25 additions & 1 deletion notebooks/archive/Example3-Model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"from icat.anchors import DictionaryAnchor\n",
"import icat\n",
"\n",
"icat.initialize()"
"icat.initialize(offline=True)"
]
},
{
Expand Down Expand Up @@ -86,6 +86,30 @@
"model.view"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3463693b-40ee-43a5-be84-91cc13d90ba9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from icat.table import TableContentsTemplate"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6aeff677-c3cc-4dda-a1ec-80d676681957",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"TableContentsTemplate()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 24ae62b

Please sign in to comment.