Skip to content

Commit

Permalink
Added wait to upload/track_files (#301)
Browse files Browse the repository at this point in the history
SiddhantSadangi authored Mar 6, 2024
1 parent 84e1840 commit 0f6093c
Showing 2 changed files with 5 additions and 28 deletions.
25 changes: 3 additions & 22 deletions use-cases/nlp/classification/keras/code/keras_nb.ipynb
Original file line number Diff line number Diff line change
@@ -365,9 +365,8 @@
"outputs": [],
"source": [
"project[\"keras/data/files\"].track_files(\n",
" \"s3://neptune-examples/data/text-classification/aclImdb_v1.tar.gz\"\n",
")\n",
"project.wait()"
" \"s3://neptune-examples/data/text-classification/aclImdb_v1.tar.gz\", wait=True\n",
")"
]
},
{
@@ -932,7 +931,7 @@
"outputs": [],
"source": [
"keras_model.save_weights(\"model_weights.h5\")\n",
"model_version[\"model_weights\"].upload(\"model_weights.h5\")"
"model_version[\"model_weights\"].upload(\"model_weights.h5\", wait=True)"
]
},
{
@@ -953,24 +952,6 @@
"model_version.change_stage(\"staging\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### (Neptune) Wait for all operations to reach with Neptune servers\n",
"Since Neptune sends data to servers asynchronously by default, we need to wait for operations to complete if we want to refer to fields/objects that were sent to Neptune earlier in the same code. \n",
"Read about the `wait()` and `sync()` methods here: https://docs.neptune.ai/logging/wait_and_sync/"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model_version.wait()"
]
},
{
"cell_type": "markdown",
"metadata": {},
8 changes: 2 additions & 6 deletions use-cases/nlp/classification/keras/code/keras_script.py
Original file line number Diff line number Diff line change
@@ -142,10 +142,8 @@ def build_model(model_params: dict, data_params: dict):
# Data preparation #
####################
project["keras/data/files"].track_files(
"s3://neptune-examples/data/text-classification/aclImdb_v1.tar.gz"
"s3://neptune-examples/data/text-classification/aclImdb_v1.tar.gz", wait=True
)
project.wait()


# (Neptune) Download files from S3 using Neptune
print("Downloading data...")
@@ -332,14 +330,12 @@ def build_model(model_params: dict, data_params: dict):
model_version["serialized_model"] = keras_model.to_json()

keras_model.save_weights("model_weights.h5")
model_version["model_weights"].upload("model_weights.h5")
model_version["model_weights"].upload("model_weights.h5", wait=True)


# (Neptune) Update model stage
model_version.change_stage("staging")

model_version.wait()

##############################################
# (Neptune) Promote best model to production #
##############################################

0 comments on commit 0f6093c

Please sign in to comment.