test_canvas.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. import pytest
  2. from case import MagicMock, Mock
  3. from celery._state import _task_stack
  4. from celery.canvas import (
  5. Signature,
  6. chain,
  7. _chain,
  8. group,
  9. chord,
  10. signature,
  11. xmap,
  12. xstarmap,
  13. chunks,
  14. _maybe_group,
  15. maybe_signature,
  16. maybe_unroll_group,
  17. )
  18. from celery.result import AsyncResult, GroupResult, EagerResult
  19. SIG = Signature({
  20. 'task': 'TASK',
  21. 'args': ('A1',),
  22. 'kwargs': {'K1': 'V1'},
  23. 'options': {'task_id': 'TASK_ID'},
  24. 'subtask_type': ''},
  25. )
  26. class test_maybe_unroll_group:
  27. def test_when_no_len_and_no_length_hint(self):
  28. g = MagicMock(name='group')
  29. g.tasks.__len__.side_effect = TypeError()
  30. g.tasks.__length_hint__ = Mock()
  31. g.tasks.__length_hint__.return_value = 0
  32. assert maybe_unroll_group(g) is g
  33. g.tasks.__length_hint__.side_effect = AttributeError()
  34. assert maybe_unroll_group(g) is g
  35. class CanvasCase:
  36. def setup(self):
  37. @self.app.task(shared=False)
  38. def add(x, y):
  39. return x + y
  40. self.add = add
  41. @self.app.task(shared=False)
  42. def mul(x, y):
  43. return x * y
  44. self.mul = mul
  45. @self.app.task(shared=False)
  46. def div(x, y):
  47. return x / y
  48. self.div = div
  49. class test_Signature(CanvasCase):
  50. def test_getitem_property_class(self):
  51. assert Signature.task
  52. assert Signature.args
  53. assert Signature.kwargs
  54. assert Signature.options
  55. assert Signature.subtask_type
  56. def test_getitem_property(self):
  57. assert SIG.task == 'TASK'
  58. assert SIG.args == ('A1',)
  59. assert SIG.kwargs == {'K1': 'V1'}
  60. assert SIG.options == {'task_id': 'TASK_ID'}
  61. assert SIG.subtask_type == ''
  62. def test_call(self):
  63. x = Signature('foo', (1, 2), {'arg1': 33}, app=self.app)
  64. x.type = Mock(name='type')
  65. x(3, 4, arg2=66)
  66. x.type.assert_called_with(3, 4, 1, 2, arg1=33, arg2=66)
  67. def test_link_on_scalar(self):
  68. x = Signature('TASK', link=Signature('B'))
  69. assert x.options['link']
  70. x.link(Signature('C'))
  71. assert isinstance(x.options['link'], list)
  72. assert Signature('B') in x.options['link']
  73. assert Signature('C') in x.options['link']
  74. def test_json(self):
  75. x = Signature('TASK', link=Signature('B', app=self.app), app=self.app)
  76. assert x.__json__() == dict(x)
  77. @pytest.mark.usefixtures('depends_on_current_app')
  78. def test_reduce(self):
  79. x = Signature('TASK', (2, 4), app=self.app)
  80. fun, args = x.__reduce__()
  81. assert fun(*args) == x
  82. def test_replace(self):
  83. x = Signature('TASK', ('A'), {})
  84. assert x.replace(args=('B',)).args == ('B',)
  85. assert x.replace(kwargs={'FOO': 'BAR'}).kwargs == {
  86. 'FOO': 'BAR',
  87. }
  88. assert x.replace(options={'task_id': '123'}).options == {
  89. 'task_id': '123',
  90. }
  91. def test_set(self):
  92. assert Signature('TASK', x=1).set(task_id='2').options == {
  93. 'x': 1, 'task_id': '2',
  94. }
  95. def test_link(self):
  96. x = signature(SIG)
  97. x.link(SIG)
  98. x.link(SIG)
  99. assert SIG in x.options['link']
  100. assert len(x.options['link']) == 1
  101. def test_link_error(self):
  102. x = signature(SIG)
  103. x.link_error(SIG)
  104. x.link_error(SIG)
  105. assert SIG in x.options['link_error']
  106. assert len(x.options['link_error']) == 1
  107. def test_flatten_links(self):
  108. tasks = [self.add.s(2, 2), self.mul.s(4), self.div.s(2)]
  109. tasks[0].link(tasks[1])
  110. tasks[1].link(tasks[2])
  111. assert tasks[0].flatten_links() == tasks
  112. def test_OR(self):
  113. x = self.add.s(2, 2) | self.mul.s(4)
  114. assert isinstance(x, _chain)
  115. y = self.add.s(4, 4) | self.div.s(2)
  116. z = x | y
  117. assert isinstance(y, _chain)
  118. assert isinstance(z, _chain)
  119. assert len(z.tasks) == 4
  120. with pytest.raises(TypeError):
  121. x | 10
  122. ax = self.add.s(2, 2) | (self.add.s(4) | self.add.s(8))
  123. assert isinstance(ax, _chain)
  124. assert len(ax.tasks), 3 == 'consolidates chain to chain'
  125. def test_INVERT(self):
  126. x = self.add.s(2, 2)
  127. x.apply_async = Mock()
  128. x.apply_async.return_value = Mock()
  129. x.apply_async.return_value.get = Mock()
  130. x.apply_async.return_value.get.return_value = 4
  131. assert ~x == 4
  132. x.apply_async.assert_called()
  133. def test_merge_immutable(self):
  134. x = self.add.si(2, 2, foo=1)
  135. args, kwargs, options = x._merge((4,), {'bar': 2}, {'task_id': 3})
  136. assert args == (2, 2)
  137. assert kwargs == {'foo': 1}
  138. assert options == {'task_id': 3}
  139. def test_set_immutable(self):
  140. x = self.add.s(2, 2)
  141. assert not x.immutable
  142. x.set(immutable=True)
  143. assert x.immutable
  144. x.set(immutable=False)
  145. assert not x.immutable
  146. def test_election(self):
  147. x = self.add.s(2, 2)
  148. x.freeze('foo')
  149. x.type.app.control = Mock()
  150. r = x.election()
  151. x.type.app.control.election.assert_called()
  152. assert r.id == 'foo'
  153. def test_AsyncResult_when_not_registered(self):
  154. s = signature('xxx.not.registered', app=self.app)
  155. assert s.AsyncResult
  156. def test_apply_async_when_not_registered(self):
  157. s = signature('xxx.not.registered', app=self.app)
  158. assert s._apply_async
  159. class test_xmap_xstarmap(CanvasCase):
  160. def test_apply(self):
  161. for type, attr in [(xmap, 'map'), (xstarmap, 'starmap')]:
  162. args = [(i, i) for i in range(10)]
  163. s = getattr(self.add, attr)(args)
  164. s.type = Mock()
  165. s.apply_async(foo=1)
  166. s.type.apply_async.assert_called_with(
  167. (), {'task': self.add.s(), 'it': args}, foo=1,
  168. route_name=self.add.name,
  169. )
  170. assert type.from_dict(dict(s)) == s
  171. assert repr(s)
  172. class test_chunks(CanvasCase):
  173. def test_chunks(self):
  174. x = self.add.chunks(range(100), 10)
  175. assert dict(chunks.from_dict(dict(x), app=self.app)) == dict(x)
  176. assert x.group()
  177. assert len(x.group().tasks) == 10
  178. x.group = Mock()
  179. gr = x.group.return_value = Mock()
  180. x.apply_async()
  181. gr.apply_async.assert_called_with((), {}, route_name=self.add.name)
  182. gr.apply_async.reset_mock()
  183. x()
  184. gr.apply_async.assert_called_with((), {}, route_name=self.add.name)
  185. self.app.conf.task_always_eager = True
  186. chunks.apply_chunks(app=self.app, **x['kwargs'])
  187. class test_chain(CanvasCase):
  188. def test_clone_preserves_state(self):
  189. x = chain(self.add.s(i, i) for i in range(10))
  190. assert x.clone().tasks == x.tasks
  191. assert x.clone().kwargs == x.kwargs
  192. assert x.clone().args == x.args
  193. def test_repr(self):
  194. x = self.add.s(2, 2) | self.add.s(2)
  195. assert repr(x) == '%s(2, 2) | add(2)' % (self.add.name,)
  196. def test_apply_async(self):
  197. c = self.add.s(2, 2) | self.add.s(4) | self.add.s(8)
  198. result = c.apply_async()
  199. assert result.parent
  200. assert result.parent.parent
  201. assert result.parent.parent.parent is None
  202. def test_splices_chains(self):
  203. c = chain(
  204. self.add.s(5, 5),
  205. chain(self.add.s(6), self.add.s(7), self.add.s(8), app=self.app),
  206. app=self.app,
  207. )
  208. c.freeze()
  209. tasks, _ = c._frozen
  210. assert len(tasks) == 4
  211. def test_from_dict_no_tasks(self):
  212. assert chain.from_dict(dict(chain(app=self.app)), app=self.app)
  213. @pytest.mark.usefixtures('depends_on_current_app')
  214. def test_app_falls_back_to_default(self):
  215. from celery._state import current_app
  216. assert chain().app is current_app
  217. def test_handles_dicts(self):
  218. c = chain(
  219. self.add.s(5, 5), dict(self.add.s(8)), app=self.app,
  220. )
  221. c.freeze()
  222. tasks, _ = c._frozen
  223. for task in tasks:
  224. assert isinstance(task, Signature)
  225. assert task.app is self.app
  226. def test_group_to_chord(self):
  227. c = (
  228. self.add.s(5) |
  229. group([self.add.s(i, i) for i in range(5)], app=self.app) |
  230. self.add.s(10) |
  231. self.add.s(20) |
  232. self.add.s(30)
  233. )
  234. c._use_link = True
  235. tasks, results = c.prepare_steps((), c.tasks)
  236. assert tasks[-1].args[0] == 5
  237. assert isinstance(tasks[-2], chord)
  238. assert len(tasks[-2].tasks) == 5
  239. body = tasks[-2].body
  240. assert len(body.tasks) == 3
  241. assert body.tasks[0].args[0] == 10
  242. assert body.tasks[1].args[0] == 20
  243. assert body.tasks[2].args[0] == 30
  244. c2 = self.add.s(2, 2) | group(self.add.s(i, i) for i in range(10))
  245. c2._use_link = True
  246. tasks2, _ = c2.prepare_steps((), c2.tasks)
  247. assert isinstance(tasks2[0], group)
  248. def test_group_to_chord__protocol_2__or(self):
  249. c = (
  250. group([self.add.s(i, i) for i in range(5)], app=self.app) |
  251. self.add.s(10) |
  252. self.add.s(20) |
  253. self.add.s(30)
  254. )
  255. assert isinstance(c, chord)
  256. def test_group_to_chord__protocol_2(self):
  257. c = chain(
  258. group([self.add.s(i, i) for i in range(5)], app=self.app),
  259. self.add.s(10),
  260. self.add.s(20),
  261. self.add.s(30)
  262. )
  263. assert isinstance(c, chord)
  264. assert isinstance(c.body, _chain)
  265. assert len(c.body.tasks) == 3
  266. c2 = self.add.s(2, 2) | group(self.add.s(i, i) for i in range(10))
  267. c2._use_link = False
  268. tasks2, _ = c2.prepare_steps((), c2.tasks)
  269. assert isinstance(tasks2[0], group)
  270. def test_apply_options(self):
  271. class static(Signature):
  272. def clone(self, *args, **kwargs):
  273. return self
  274. def s(*args, **kwargs):
  275. return static(self.add, args, kwargs, type=self.add, app=self.app)
  276. c = s(2, 2) | s(4) | s(8)
  277. r1 = c.apply_async(task_id='some_id')
  278. assert r1.id == 'some_id'
  279. c.apply_async(group_id='some_group_id')
  280. assert c.tasks[-1].options['group_id'] == 'some_group_id'
  281. c.apply_async(chord='some_chord_id')
  282. assert c.tasks[-1].options['chord'] == 'some_chord_id'
  283. c.apply_async(link=[s(32)])
  284. assert c.tasks[-1].options['link'] == [s(32)]
  285. c.apply_async(link_error=[s('error')])
  286. for task in c.tasks:
  287. assert task.options['link_error'] == [s('error')]
  288. def test_reverse(self):
  289. x = self.add.s(2, 2) | self.add.s(2)
  290. assert isinstance(signature(x), _chain)
  291. assert isinstance(signature(dict(x)), _chain)
  292. def test_always_eager(self):
  293. self.app.conf.task_always_eager = True
  294. assert ~(self.add.s(4, 4) | self.add.s(8)) == 16
  295. def test_apply(self):
  296. x = chain(self.add.s(4, 4), self.add.s(8), self.add.s(10))
  297. res = x.apply()
  298. assert isinstance(res, EagerResult)
  299. assert res.get() == 26
  300. assert res.parent.get() == 16
  301. assert res.parent.parent.get() == 8
  302. assert res.parent.parent.parent is None
  303. def test_empty_chain_returns_none(self):
  304. assert chain(app=self.app)() is None
  305. assert chain(app=self.app).apply_async() is None
  306. def test_call_no_tasks(self):
  307. x = chain()
  308. assert not x()
  309. def test_call_with_tasks(self):
  310. x = self.add.s(2, 2) | self.add.s(4)
  311. x.apply_async = Mock()
  312. x(2, 2, foo=1)
  313. x.apply_async.assert_called_with((2, 2), {'foo': 1})
  314. def test_from_dict_no_args__with_args(self):
  315. x = dict(self.add.s(2, 2) | self.add.s(4))
  316. x['args'] = None
  317. assert isinstance(chain.from_dict(x), _chain)
  318. x['args'] = (2,)
  319. assert isinstance(chain.from_dict(x), _chain)
  320. def test_accepts_generator_argument(self):
  321. x = chain(self.add.s(i) for i in range(10))
  322. assert x.tasks[0].type, self.add
  323. assert x.type
  324. def test_chord_sets_result_parent(self):
  325. g = (self.add.s(0, 0) |
  326. group(self.add.s(i, i) for i in range(1, 10)) |
  327. self.add.s(2, 2) |
  328. self.add.s(4, 4))
  329. res = g.freeze()
  330. assert isinstance(res, AsyncResult)
  331. assert not isinstance(res, GroupResult)
  332. assert isinstance(res.parent, AsyncResult)
  333. assert not isinstance(res.parent, GroupResult)
  334. assert isinstance(res.parent.parent, GroupResult)
  335. assert isinstance(res.parent.parent.parent, AsyncResult)
  336. assert not isinstance(res.parent.parent.parent, GroupResult)
  337. assert res.parent.parent.parent.parent is None
  338. seen = set()
  339. node = res
  340. while node:
  341. assert node.id not in seen
  342. seen.add(node.id)
  343. node = node.parent
  344. class test_group(CanvasCase):
  345. def test_repr(self):
  346. x = group([self.add.s(2, 2), self.add.s(4, 4)])
  347. assert repr(x)
  348. def test_reverse(self):
  349. x = group([self.add.s(2, 2), self.add.s(4, 4)])
  350. assert isinstance(signature(x), group)
  351. assert isinstance(signature(dict(x)), group)
  352. def test_cannot_link_on_group(self):
  353. x = group([self.add.s(2, 2), self.add.s(4, 4)])
  354. with pytest.raises(TypeError):
  355. x.apply_async(link=self.add.s(2, 2))
  356. def test_cannot_link_error_on_group(self):
  357. x = group([self.add.s(2, 2), self.add.s(4, 4)])
  358. with pytest.raises(TypeError):
  359. x.apply_async(link_error=self.add.s(2, 2))
  360. def test_group_with_group_argument(self):
  361. g1 = group(self.add.s(2, 2), self.add.s(4, 4), app=self.app)
  362. g2 = group(g1, app=self.app)
  363. assert g2.tasks is g1.tasks
  364. def test_maybe_group_sig(self):
  365. assert _maybe_group(self.add.s(2, 2), self.app) == [self.add.s(2, 2)]
  366. def test_apply(self):
  367. x = group([self.add.s(4, 4), self.add.s(8, 8)])
  368. res = x.apply()
  369. assert res.get(), [8 == 16]
  370. def test_apply_async(self):
  371. x = group([self.add.s(4, 4), self.add.s(8, 8)])
  372. x.apply_async()
  373. def test_prepare_with_dict(self):
  374. x = group([self.add.s(4, 4), dict(self.add.s(8, 8))], app=self.app)
  375. x.apply_async()
  376. def test_group_in_group(self):
  377. g1 = group(self.add.s(2, 2), self.add.s(4, 4), app=self.app)
  378. g2 = group(self.add.s(8, 8), g1, self.add.s(16, 16), app=self.app)
  379. g2.apply_async()
  380. def test_set_immutable(self):
  381. g1 = group(Mock(name='t1'), Mock(name='t2'), app=self.app)
  382. g1.set_immutable(True)
  383. for task in g1.tasks:
  384. task.set_immutable.assert_called_with(True)
  385. def test_link(self):
  386. g1 = group(Mock(name='t1'), Mock(name='t2'), app=self.app)
  387. sig = Mock(name='sig')
  388. g1.link(sig)
  389. g1.tasks[0].link.assert_called_with(sig.clone().set(immutable=True))
  390. def test_link_error(self):
  391. g1 = group(Mock(name='t1'), Mock(name='t2'), app=self.app)
  392. sig = Mock(name='sig')
  393. g1.link_error(sig)
  394. g1.tasks[0].link_error.assert_called_with(
  395. sig.clone().set(immutable=True),
  396. )
  397. def test_apply_empty(self):
  398. x = group(app=self.app)
  399. x.apply()
  400. res = x.apply_async()
  401. assert res
  402. assert not res.results
  403. def test_apply_async_with_parent(self):
  404. _task_stack.push(self.add)
  405. try:
  406. self.add.push_request(called_directly=False)
  407. try:
  408. assert not self.add.request.children
  409. x = group([self.add.s(4, 4), self.add.s(8, 8)])
  410. res = x()
  411. assert self.add.request.children
  412. assert res in self.add.request.children
  413. assert len(self.add.request.children) == 1
  414. finally:
  415. self.add.pop_request()
  416. finally:
  417. _task_stack.pop()
  418. def test_from_dict(self):
  419. x = group([self.add.s(2, 2), self.add.s(4, 4)])
  420. x['args'] = (2, 2)
  421. assert group.from_dict(dict(x))
  422. x['args'] = None
  423. assert group.from_dict(dict(x))
  424. def test_call_empty_group(self):
  425. x = group(app=self.app)
  426. assert not len(x())
  427. x.delay()
  428. x.apply_async()
  429. x()
  430. def test_skew(self):
  431. g = group([self.add.s(i, i) for i in range(10)])
  432. g.skew(start=1, stop=10, step=1)
  433. for i, task in enumerate(g.tasks):
  434. assert task.options['countdown'] == i + 1
  435. def test_iter(self):
  436. g = group([self.add.s(i, i) for i in range(10)])
  437. assert list(iter(g)) == list(g.keys())
  438. @staticmethod
  439. def helper_test_get_delay(result):
  440. import time
  441. t0 = time.time()
  442. while not result.ready():
  443. time.sleep(0.01)
  444. if time.time() - t0 > 1:
  445. return None
  446. return result.get()
  447. def test_kwargs_direct(self):
  448. res = [self.add(x=1, y=1), self.add(x=1, y=1)]
  449. assert res == [2, 2]
  450. def test_kwargs_apply(self):
  451. x = group([self.add.s(), self.add.s()])
  452. res = x.apply(kwargs=dict(x=1, y=1)).get()
  453. assert res == [2, 2]
  454. def test_kwargs_apply_async(self):
  455. self.app.conf.task_always_eager = True
  456. x = group([self.add.s(), self.add.s()])
  457. res = self.helper_test_get_delay(x.apply_async(kwargs=dict(x=1, y=1)))
  458. assert res == [2, 2]
  459. def test_kwargs_delay(self):
  460. self.app.conf.task_always_eager = True
  461. x = group([self.add.s(), self.add.s()])
  462. res = self.helper_test_get_delay(x.delay(x=1, y=1))
  463. assert res == [2, 2]
  464. def test_kwargs_delay_partial(self):
  465. self.app.conf.task_always_eager = True
  466. x = group([self.add.s(1), self.add.s(x=1)])
  467. res = self.helper_test_get_delay(x.delay(y=1))
  468. assert res == [2, 2]
  469. class test_chord(CanvasCase):
  470. def test_reverse(self):
  471. x = chord([self.add.s(2, 2), self.add.s(4, 4)], body=self.mul.s(4))
  472. assert isinstance(signature(x), chord)
  473. assert isinstance(signature(dict(x)), chord)
  474. def test_clone_clones_body(self):
  475. x = chord([self.add.s(2, 2), self.add.s(4, 4)], body=self.mul.s(4))
  476. y = x.clone()
  477. assert x.kwargs['body'] is not y.kwargs['body']
  478. y.kwargs.pop('body')
  479. z = y.clone()
  480. assert z.kwargs.get('body') is None
  481. def test_argument_is_group(self):
  482. x = chord(group(self.add.s(2, 2), self.add.s(4, 4), app=self.app))
  483. assert x.tasks
  484. def test_app_when_app(self):
  485. app = Mock(name='app')
  486. x = chord([self.add.s(4, 4)], app=app)
  487. assert x.app is app
  488. def test_app_when_app_in_task(self):
  489. t1 = Mock(name='t1')
  490. t2 = Mock(name='t2')
  491. x = chord([t1, self.add.s(4, 4)])
  492. assert x.app is x.tasks[0].app
  493. t1.app = None
  494. x = chord([t1], body=t2)
  495. assert x.app is t2._app
  496. @pytest.mark.usefixtures('depends_on_current_app')
  497. def test_app_fallback_to_current(self):
  498. from celery._state import current_app
  499. t1 = Mock(name='t1')
  500. t1.app = t1._app = None
  501. x = chord([t1], body=t1)
  502. assert x.app is current_app
  503. def test_set_immutable(self):
  504. x = chord([Mock(name='t1'), Mock(name='t2')], app=self.app)
  505. x.set_immutable(True)
  506. def test_links_to_body(self):
  507. x = chord([self.add.s(2, 2), self.add.s(4, 4)], body=self.mul.s(4))
  508. x.link(self.div.s(2))
  509. assert not x.options.get('link')
  510. assert x.kwargs['body'].options['link']
  511. x.link_error(self.div.s(2))
  512. assert not x.options.get('link_error')
  513. assert x.kwargs['body'].options['link_error']
  514. assert x.tasks
  515. assert x.body
  516. def test_repr(self):
  517. x = chord([self.add.s(2, 2), self.add.s(4, 4)], body=self.mul.s(4))
  518. assert repr(x)
  519. x.kwargs['body'] = None
  520. assert 'without body' in repr(x)
  521. def test_freeze_tasks_is_not_group(self):
  522. x = chord([self.add.s(2, 2)], body=self.add.s(), app=self.app)
  523. x.freeze()
  524. x.tasks = [self.add.s(2, 2)]
  525. x.freeze()
  526. class test_maybe_signature(CanvasCase):
  527. def test_is_None(self):
  528. assert maybe_signature(None, app=self.app) is None
  529. def test_is_dict(self):
  530. assert isinstance(maybe_signature(dict(self.add.s()), app=self.app),
  531. Signature)
  532. def test_when_sig(self):
  533. s = self.add.s()
  534. assert maybe_signature(s, app=self.app) is s