Skip to content

Commit

Permalink
fix: add about method to HyFI class
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Apr 25, 2023
1 parent a1fb54f commit fe37759
Show file tree
Hide file tree
Showing 6 changed files with 564 additions and 53 deletions.
1 change: 0 additions & 1 deletion book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ format: jb-book
root: index
chapters:
- file: usage
- file: api
- file: examples
234 changes: 234 additions & 0 deletions book/examples.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "cjgz1WTcPWee"
},
"source": [
"# HyFI Example\n",
"\n",
"This Jupyter Notebook demonstrates the usage of the `hyfi` package, including initializing a workspace, mounting Google Drive on Colab, and using HyFI to manage configurations.\n",
"\n",
"First, let's import the necessary functions and classes from the `hyfi` package.\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from hyfi import HyFI\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## About the `hyfi` package\n",
"\n",
"Now, let's check the version of the `hyfi` package we are using.\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"id": "BzxPwsOVPWef"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"name : HyFI\n",
"authors : Young Joon Lee <entelecheia@hotmail.com>\n",
"description : Hydra Fast Interface (Hydra and Pydantic based interface framework)\n",
"homepage : https://hyfi.entelecheia.ai\n",
"license : MIT\n",
"version : 0.2.13\n",
"\n",
"Execute `HyFI --help` to see what you can do with HyFI\n"
]
}
],
"source": [
"HyFI.about()\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initialize Workspace\n",
"\n",
"We'll initialize the workspace using the `HyFI.init_workspace` function. The function takes the following parameters:\n",
"\n",
"- `workspace`: The root workspace directory.\n",
"- `project`: The project subdirectory.\n",
"- `task`: The specific task within the project.\n",
"- `log_level`: Logging level for the workspace.\n",
"- `verbose`: Whether to print verbose messages.\n",
"\n",
"We'll check if we're running in Google Colab, and if so, we'll mount Google Drive.\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:hyfi.utils.notebook:Extension autotime not found. Install it first.\n",
"INFO:hyfi.env:config_module: hyfi.conf\n",
"INFO:hyfi.env:compose config with overrides: ['+project=__init__']\n",
"INFO:hyfi.env:initialized batcher with <hyfi.utils.batch.batcher.Batcher object at 0x7f05d6662fa0>\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"version: 0.2.13\n",
"project_dir: /workspace/projects/hyfi/examples\n"
]
}
],
"source": [
"if HyFI.is_colab():\n",
" HyFI.mount_google_drive()\n",
"\n",
"ws = HyFI.init_workspace(\n",
" workspace=\"/workspace\",\n",
" project=\"hyfi/examples\",\n",
" task=\"test\",\n",
" log_level=\"INFO\",\n",
" verbose=True,\n",
")\n",
"\n",
"print(\"version:\", ws.version)\n",
"print(\"project_dir:\", ws.project_dir)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compose Configuration\n",
"\n",
"We can use the `HyFI.compose` function to load a configuration file. In this example, we'll use the default configuration by specifying `path=__default__`.\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:hyfi.env:config_module: hyfi.conf\n",
"INFO:hyfi.env:compose config with overrides: ['+path=__default__']\n"
]
}
],
"source": [
"cfg = HyFI.compose(\"path=__default__\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Display Configuration\n",
"\n",
"Now, let's print the loaded configuration using the `HyFI.print` function.\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'cache_dir': '/workspace/projects/hyfi/examples/default-task/cache',\n",
" 'data_dir': '/workspace/projects/hyfi/examples/default-task/data',\n",
" 'library_dir': '/workspace/projects/hyfi/examples/default-task/libs',\n",
" 'log_dir': '/workspace/projects/hyfi/examples/default-task/logs',\n",
" 'model_dir': '/workspace/projects/hyfi/examples/default-task/models',\n",
" 'output_dir': '/workspace/projects/hyfi/examples/default-task/outputs',\n",
" 'root': '/workspace/projects/hyfi/examples/default-task',\n",
" 'task_name': 'default-task',\n",
" 'tmp_dir': '/workspace/projects/hyfi/examples/default-task/tmp',\n",
" 'verbose': False}\n"
]
}
],
"source": [
"HyFI.print(cfg)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"That's it! This example demonstrated the basic usage of the `hyfi` package. You can now use this package to manage your own projects and tasks in a structured manner.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"colab": {
"name": "corpus.ipynb",
"provenance": []
},
"interpreter": {
"hash": "f869af7787e6a1c49e09e367fc6e1b81d93d1c6583b43249c80edc047bd13cb2"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 1
}
34 changes: 0 additions & 34 deletions book/examples.md

This file was deleted.

Loading

0 comments on commit fe37759

Please sign in to comment.