Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Is There A Way To Get The Most Updated

Is there a way to get the most updated Script class?
Use case - I have a piece of code that is common in a few API services which may hold different version of the trains package.
(this piece of code is part of an internal pip-installable package).
The API services create a trains task in advance for other services to later on connect to and upload artifacts.

My current code is something like this:
` from trains import Task
try:
from trains.backend_api.services.v2_8.tasks import Script
except ImportError:
from trains.backend_api.services.v2_5.tasks import Script

def create_task(project_name, task_name, hyperparameters, entrypoint="", task_type=TaskTypes.training):
task = Task.create(project_name=project_name, task_name=task_name, task_type=task_type)
if entrypoint:
script = Script(entry_point=entrypoint, repository="")
task._update_script(script)
for key, value in hyperparameters.items():
task.set_parameter(key, value)
return task `

  
  
Posted 4 years ago
Votes Newest

Answers 6


yes 🙂
But I think that when you get the internal_task_representation.execution.script you are basically already getting the API object (obviously with the correct version) so you can edit it in place and pass it too

  
  
Posted 4 years ago

HandsomeCrow5 if you want to edit the Task object you can just use:
internal_task_representation = task.data internal_task_representation.execution.script = ... task._edit(execution=internal_task_representation.execution)This will make sure you do not need to worry about API version etc. the Task object will take care of it.
BTW: it seems a few more people wanted this ability, maybe we should edit a proper .edit method to Task. Thoughts ?

  
  
Posted 4 years ago

HandsomeCrow5
So using the _edit method you have the ability to add/edit the execution.script field, without worrying about the API version (I guess the name edit is misleading, it also does add :)

  
  
Posted 4 years ago

Thanks for the prompt response SuccessfulKoala55 ! exactly what I was looking for 🙂

AgitatedDove14 - using your suggested solution looks a bit more generic, and a proper .edit method is a good idea for that. However - it doesn’t resolve the API version issue I had (that is, unless you also suggest to add a method to add execution.script , which isn’t initialized when I use Task.create )

  
  
Posted 4 years ago

oh, it is indeed misleading.
what should I assign to internal_task_representation.execution.script then (per your example snippet)? a dictionary?

  
  
Posted 4 years ago

Hi HandsomeCrow5 ,
Try doing the following:
from trains.backend_api.services import tasks ... script = tasks.Script(...)

  
  
Posted 4 years ago
966 Views
6 Answers
4 years ago
one year ago
Tags