|
43 | 43 | ]
|
44 | 44 | },
|
45 | 45 | {
|
| 46 | + "metadata": {}, |
46 | 47 | "cell_type": "code",
|
47 |
| - "execution_count": null, |
48 |
| - "metadata": { |
49 |
| - "cellView": "form" |
50 |
| - }, |
51 |
| - "outputs": [], |
52 | 48 | "source": [
|
53 | 49 | "# @title Authorization Form\n",
|
54 |
| - "USERNAME = \"YOUR_USERNAME\" # @param {type:\"string\"}\n", |
| 50 | + "USERNAME = \"YOUR_USERNAME\" # @param {type:\"string\"}" |
| 51 | + ], |
| 52 | + "outputs": [], |
| 53 | + "execution_count": null |
| 54 | + }, |
| 55 | + { |
| 56 | + "metadata": {}, |
| 57 | + "cell_type": "code", |
| 58 | + "source": [ |
| 59 | + "import sys\n", |
55 | 60 | "\n",
|
| 61 | + "# Get username if not set in parameters\n", |
| 62 | + "if USERNAME == \"YOUR_USERNAME\":\n", |
| 63 | + " if sys.platform == \"emscripten\":\n", |
| 64 | + " USERNAME = await input(\"Please enter username: \")\n", |
| 65 | + " else:\n", |
| 66 | + " USERNAME = input(\"Please enter username: \")\n", |
| 67 | + "print(f\"Using username: {USERNAME}\")" |
| 68 | + ], |
| 69 | + "outputs": [], |
| 70 | + "execution_count": null |
| 71 | + }, |
| 72 | + { |
| 73 | + "metadata": {}, |
| 74 | + "cell_type": "code", |
| 75 | + "source": [ |
| 76 | + "# Get password\n", |
56 | 77 | "# avoid storing password in plaintext\n",
|
57 | 78 | "from getpass import getpass\n",
|
58 | 79 | "\n",
|
| 80 | + "if sys.platform == \"emscripten\":\n", |
| 81 | + " PASSWORD = await getpass(\"Please enter password: \")\n", |
| 82 | + "else:\n", |
| 83 | + " PASSWORD = getpass(\"Please enter password: \")" |
| 84 | + ], |
| 85 | + "outputs": [], |
| 86 | + "execution_count": null |
| 87 | + }, |
| 88 | + { |
| 89 | + "metadata": {}, |
| 90 | + "cell_type": "code", |
| 91 | + "source": [ |
59 | 92 | "import os\n",
|
60 |
| - "import sys\n", |
61 | 93 | "\n",
|
62 | 94 | "if \"COLAB_JUPYTER_IP\" in os.environ:\n",
|
63 | 95 | " !GIT_BRANCH=\"dev\"; export GIT_BRANCH; curl -s \"https://raw.githubusercontent.com/Exabyte-io/api-examples/${GIT_BRANCH}/scripts/env.sh\" | bash\n",
|
|
78 | 110 | " await micropip.install(\"mat3ra-api-examples\", deps=False)\n",
|
79 | 111 | " from utils.jupyterlite import install_packages\n",
|
80 | 112 | "\n",
|
81 |
| - " await install_packages(\"api_examples\")\n", |
82 |
| - " PASSWORD = await getpass(\"Please enter password: \")\n", |
83 |
| - "else:\n", |
84 |
| - " PASSWORD = getpass(\"Please enter password: \")" |
85 |
| - ] |
| 113 | + " await install_packages(\"api_examples\")" |
| 114 | + ], |
| 115 | + "outputs": [], |
| 116 | + "execution_count": null |
86 | 117 | },
|
87 | 118 | {
|
88 | 119 | "attachments": {},
|
|
94 | 125 | },
|
95 | 126 | {
|
96 | 127 | "cell_type": "code",
|
97 |
| - "execution_count": null, |
98 | 128 | "metadata": {},
|
99 |
| - "outputs": [], |
100 | 129 | "source": [
|
101 | 130 | "from utils.settings import HOST, PORT, VERSION, SECURE\n",
|
102 | 131 | "from utils.generic import display_JSON\n",
|
103 | 132 | "\n",
|
104 | 133 | "from exabyte_api_client.endpoints.login import LoginEndpoint"
|
105 |
| - ] |
| 134 | + ], |
| 135 | + "outputs": [], |
| 136 | + "execution_count": null |
106 | 137 | },
|
107 | 138 | {
|
108 | 139 | "attachments": {},
|
|
114 | 145 | },
|
115 | 146 | {
|
116 | 147 | "cell_type": "code",
|
117 |
| - "execution_count": null, |
118 | 148 | "metadata": {},
|
119 |
| - "outputs": [], |
120 | 149 | "source": [
|
121 | 150 | "endpoint = LoginEndpoint(HOST, PORT, USERNAME, PASSWORD, VERSION, SECURE)\n",
|
122 | 151 | "auth_params = endpoint.login()"
|
123 |
| - ] |
| 152 | + ], |
| 153 | + "outputs": [], |
| 154 | + "execution_count": null |
124 | 155 | },
|
125 | 156 | {
|
126 | 157 | "attachments": {},
|
|
134 | 165 | },
|
135 | 166 | {
|
136 | 167 | "cell_type": "code",
|
137 |
| - "execution_count": null, |
138 | 168 | "metadata": {
|
139 | 169 | "pycharm": {
|
140 | 170 | "name": "#%%\n"
|
141 | 171 | }
|
142 | 172 | },
|
143 |
| - "outputs": [], |
144 | 173 | "source": [
|
145 | 174 | "display_JSON(auth_params)"
|
146 |
| - ] |
| 175 | + ], |
| 176 | + "outputs": [], |
| 177 | + "execution_count": null |
147 | 178 | }
|
148 | 179 | ],
|
149 | 180 | "metadata": {
|
|
0 commit comments