Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
update sample
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Aug 12, 2020
1 parent d04a331 commit ea87730
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
4 changes: 1 addition & 3 deletions samples/snippets/create_instruction.py
Expand Up @@ -59,9 +59,7 @@ def create_instruction(project_id, data_type, instruction_gcs_uri):
print("The instruction resource name: {}".format(result.name))
print("Display name: {}".format(result.display_name))
print("Description: {}".format(result.description))
print("Create time:")
print("\tseconds: {}".format(result.create_time.seconds))
print("\tnanos: {}".format(result.create_time.nanos))
print("Create time: {}").format(result.create_time)
print("Data type: {}".format(datalabeling.DataType(result.data_type).name))
print("Pdf instruction:")
print("\tGcs file uri: {}\n".format(result.pdf_instruction.gcs_file_uri))
Expand Down
12 changes: 3 additions & 9 deletions samples/snippets/manage_dataset.py
Expand Up @@ -49,9 +49,7 @@ def create_dataset(project_id):
print("The dataset resource name: {}".format(response.name))
print("Display name: {}".format(response.display_name))
print("Description: {}".format(response.description))
print("Create time:")
print("\tseconds: {}".format(response.create_time.seconds))
print("\tnanos: {}\n".format(response.create_time.nanos))
print("Create time: {}").format(result.create_time)

return response

Expand Down Expand Up @@ -82,9 +80,7 @@ def list_datasets(project_id):
print("The dataset resource name: {}\n".format(element.name))
print("Display name: {}".format(element.display_name))
print("Description: {}".format(element.description))
print("Create time:")
print("\tseconds: {}".format(element.create_time.seconds))
print("\tnanos: {}".format(element.create_time.nanos))
print("Create time: {}").format(result.create_time)


# [END datalabeling_list_datasets_beta]
Expand All @@ -109,9 +105,7 @@ def get_dataset(dataset_resource_name):
print("The dataset resource name: {}\n".format(response.name))
print("Display name: {}".format(response.display_name))
print("Description: {}".format(response.description))
print("Create time:")
print("\tseconds: {}".format(response.create_time.seconds))
print("\tnanos: {}".format(response.create_time.nanos))
print("Create time: {}").format(result.create_time)


# [END datalabeling_get_dataset_beta]
Expand Down
6 changes: 3 additions & 3 deletions samples/snippets/testing_lib.py
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import os
import time

import backoff
from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -57,9 +57,9 @@ def delete_old_datasets(project_id):

response = client.list_datasets(request={"parent": formatted_project_name})
# It will delete datasets created more than 2 hours ago
cutoff_time = time.time() - 7200
cutoff_time = datetime.datetime.utcnow() - datetime.timedelta(hours=2)
for element in response:
if element.create_time.seconds < cutoff_time:
if element.create_time < cutoff_time:
print("Deleting {}".format(element.name))
try:
dataset_sample.delete_dataset(element.name)
Expand Down

0 comments on commit ea87730

Please sign in to comment.