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
Hi All, Is There A Clean Way To Check If A Local Trains-Server Is Available? I Want To Set A Condition Weather To Set To Offline Mode Or Not. Thanks

Hi all, is there a clean way to check if a local trains-server is available? I want to set a condition weather to set to offline mode or not. thanks

  
  
Posted 3 years ago
Votes Newest

Answers 8


edit: tweaked it a little bit for my use-case:
is_demo_server = ' http://demoapi.trains.allegro.ai ' in Session.get_api_server_host()
is_server_available = requests.get(Session.get_api_server_host() + "/debug.ping").status_code == 200

  
  
Posted 3 years ago

In your Python script, you can use something like:
` import requests
from trains.backend_api import Session

server_available = requests.get(Session.get_api_server_host() + "/debug.ping").ok() `

  
  
Posted 3 years ago

Cool. My mistake was that I forgot ok is a boolean property, not a method 😄 So you can actually do:
is_server_available = requests.get(Session.get_api_server_host() + "/debug.ping").ok
ok basically does what you did yourself 🙂

  
  
Posted 3 years ago

I'm doing this instead

  
  
Posted 3 years ago

TypeError: 'bool' object is not callable

  
  
Posted 3 years ago

Hi RipeGoose2 , you can use curl http://<server-ip-or-host-name>:8008/debug.ping
The server should return 200 🙂

  
  
Posted 3 years ago

the ok() call seem to crash

  
  
Posted 3 years ago

much appreciated, thanks!

  
  
Posted 3 years ago
583 Views
8 Answers
3 years ago
one year ago
Tags