Skip to content

Commit

Permalink
work on #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Dcosthephalump committed Jul 19, 2023
1 parent 1417402 commit 72bd417
Show file tree
Hide file tree
Showing 12 changed files with 1,632 additions and 254 deletions.
310 changes: 108 additions & 202 deletions 01_selection.ipynb

Large diffs are not rendered by default.

101 changes: 95 additions & 6 deletions 02_information.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@
},
"outputs": [],
"source": [
"#| export\n",
"class Information(param.Parameterized):\n",
"#| hide\n",
"class InformationTrial(param.Parameterized):\n",
" \n",
" newManClicked = param.Boolean(default = False)\n",
" # Set this to a default manuscript ASAP\n",
Expand Down Expand Up @@ -1299,7 +1299,7 @@
" \n",
" self.centuriesWidget = createCenturiesWidget()\n",
" # This takes the Centuries data and parses it based on if the work is split over centuries\n",
" centuries = informationDemo.selectedManuscript[1]['Centuries'].split()\n",
" centuries = self.selectedManuscript[1]['Centuries'].split()\n",
" if len(centuries) == 2:\n",
" self.centuriesWidget.value = (centuries[0], centuries[0])\n",
" else:\n",
Expand Down Expand Up @@ -1348,9 +1348,9 @@
}
],
"source": [
"#| export\n",
"#| hide\n",
"@patch\n",
"def on_click_save(self:Information, null):\n",
"def on_click_save(self:InformationTrial, null):\n",
" directory = self.selectedManuscript[0]\n",
" \n",
" updateValues = {}\n",
Expand Down Expand Up @@ -1478,11 +1478,100 @@
"source": [
"#| hide\n",
"\n",
"informationDemo = Information()\n",
"informationDemo = InformationTrial()\n",
"\n",
"informationDemo.panel()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As with ```Selection```, import problems with the ```@patch``` decorator are not things which can be easily avoided. To solve this, the following is a full code block of the ```Information``` class."
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#| export\n",
"class Information(param.Parameterized):\n",
" \n",
" newManClicked = param.Boolean(default = False)\n",
" # Set this to a default manuscript ASAP\n",
" selectedManuscript = param.List(default = ['/home/dc/glyptodon/manuscripts/stvrnktmnstrygrkcllctnn.53',\n",
" {'Work': 'Stavronikita Monastery Greek handwritten document Collection no.53',\n",
" 'Author': '',\n",
" 'Language': 'Greek',\n",
" 'Country': 'Greece',\n",
" 'City': 'Mount Athos',\n",
" 'Institution': 'Stavronikita Monastery',\n",
" 'Centuries': '14th Century'\n",
" }\n",
" ]\n",
" )\n",
" \n",
" @param.output('manuscriptDirectory',param.String)\n",
" def informationOutput():\n",
" return selectedManuscript[0]\n",
" \n",
" def panel(self):\n",
" self.metadata, self.textWidgets = createTextWidgets()\n",
" \n",
" textRowOne = pn.Row(self.textWidgets[0], self.textWidgets[1])\n",
" textRowTwo = pn.Row(self.textWidgets[2], self.textWidgets[3])\n",
" textRowThree = pn.Row(self.textWidgets[4], self.textWidgets[5])\n",
" \n",
" self.textWidgets[0].value, self.textWidgets[1].value = self.selectedManuscript[1]['Work'], self.selectedManuscript[1]['Author']\n",
" self.textWidgets[2].value, self.textWidgets[3].value = self.selectedManuscript[1]['Language'], self.selectedManuscript[1]['Country']\n",
" self.textWidgets[4].value, self.textWidgets[5].value = self.selectedManuscript[1]['City'], self.selectedManuscript[1]['Institution']\n",
" \n",
" self.centuriesWidget = createCenturiesWidget()\n",
" # This takes the Centuries data and parses it based on if the work is split over centuries\n",
" centuries = self.selectedManuscript[1]['Centuries'].split()\n",
" if len(centuries) == 2:\n",
" self.centuriesWidget.value = (centuries[0], centuries[0])\n",
" else:\n",
" self.centuriesWidget.value = (centuries[0], centuries[2])\n",
" \n",
" self.saveButton = wc.orangeButton('Save Manuscript Data')\n",
" self.saveButton.on_click(self.on_click_save)\n",
" bottomRow = pn.Row(self.centuriesWidget, self.saveButton)\n",
" \n",
" columnRight = pn.Column(textRowOne, textRowTwo, textRowThree, bottomRow)\n",
" self.informationInfo = createInformationInfo()\n",
" \n",
" if self.newManClicked:\n",
" self.upImages, self.upTranscripts = createUploaders()\n",
" uploaders = pn.Row(self.upImages, self.upTranscripts)\n",
" \n",
" columnLeft = pn.Column(self.informationInfo, uploaders)\n",
" layout = pn.Row(columnLeft, columnRight)\n",
" else:\n",
" self.informationInfo = createInformationInfo()\n",
" layout = pn.Row(self.informationInfo, columnRight)\n",
" \n",
" return layout\n",
" \n",
" def on_click_save(self, null):\n",
" directory = self.selectedManuscript[0]\n",
"\n",
" updateValues = {}\n",
" for widget in self.textWidgets:\n",
" updateValues[widget.description] = widget.value\n",
"\n",
" if self.centuriesWidget.value[0] == self.centuriesWidget.value[1]:\n",
" updateValues['Centuries'] = self.centuriesWidget.value[0] + ' Century'\n",
" else:\n",
" updateValues['Centuries'] = self.centuriesWidget.value[0] + ' to ' + self.centuriesWidget.value[1] + ' Century'\n",
"\n",
" updateMetadata(directory, updateValues)"
]
},
{
"cell_type": "code",
"execution_count": 19,
Expand Down
Loading

1 comment on commit 72bd417

@Dcosthephalump
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This edit fixed a problem where the @patch decorator was making it impossible to import classes functionally through library calls. For export cells, I removed the patch decorator for class specific functions and put them all into one class. Additionally, I integrated the different Stages together into one pipeline.

Please sign in to comment.