@@ -20,7 +20,8 @@ for access to client projects.
2020Projects
2121--------
2222
23- You can list the projects available to your account::
23+ You can list the :class: `~scrapinghub.client.projects.Projects ` available to your
24+ account::
2425
2526 >>> client.projects.list()
2627 [123, 456]
@@ -67,31 +68,6 @@ For example, to schedule a spider run (it returns a
6768 <scrapinghub.client.Job at 0x106ee12e8>>
6869
6970
70- Settings
71- --------
72-
73- You can work with project settings via :class: `~scrapinghub.client.projects.Settings `.
74-
75- To get a list of the project settings::
76-
77- >>> project.settings.list()
78- [(u'default_job_units', 2), (u'job_runtime_limit', 24)]]
79-
80- To get a project setting value by name::
81-
82- >>> project.settings.get('job_runtime_limit')
83- 24
84-
85- To update a project setting value by name::
86-
87- >>> project.settings.set('job_runtime_limit', 20)
88-
89- Or update a few project settings at once::
90-
91- >>> project.settings.update({'default_job_units': 1,
92- ... 'job_runtime_limit': 20})
93-
94-
9571Spiders
9672-------
9773
@@ -160,17 +136,17 @@ Use ``run`` method to run a new job for project/spider::
160136
161137Scheduling logic supports different options, like
162138
163- - job_args to provide arguments for the job
164- - units to specify amount of units to run the job
165- - job_settings to pass additional settings for the job
166- - priority to set higher/lower priority of the job
167- - add_tag to create a job with a set of initial tags
168- - meta to pass additional custom metadata
139+ - ** job_args ** to provide arguments for the job
140+ - ** units ** to specify amount of units to run the job
141+ - ** job_settings ** to pass additional settings for the job
142+ - ** priority ** to set higher/lower priority of the job
143+ - ** add_tag ** to create a job with a set of initial tags
144+ - ** meta ** to pass additional custom metadata
169145
170146For example, to run a new job for a given spider with custom params::
171147
172- >>> job = spider.jobs.run(units=2, job_settings={'SETTING': 'VALUE'},
173- priority=1, add_tag=['tagA','tagB'], meta={'custom-data': 'val1'})
148+ >>> job = spider.jobs.run(units=2, job_settings={'SETTING': 'VALUE'}, priority=1,
149+ ... add_tag=['tagA','tagB'], meta={'custom-data': 'val1'})
174150
175151Note that if you run a job on project level, spider name is required::
176152
@@ -216,7 +192,7 @@ ones::
216192 >>> job_summary = next(project.jobs.iter())
217193 >>> job_summary.get('spider', 'missing')
218194 'foo'
219- >>> jobs_summary = project.jobs.iter(jobmeta=['scheduled_by', ])
195+ >>> jobs_summary = project.jobs.iter(jobmeta=['scheduled_by'])
220196 >>> job_summary = next(jobs_summary)
221197 >>> job_summary.get('scheduled_by', 'missing')
222198 'John'
@@ -235,8 +211,9 @@ To get jobs filtered by tags::
235211
236212 >>> jobs_summary = project.jobs.iter(has_tag=['new', 'verified'], lacks_tag='obsolete')
237213
238- List of tags has ``OR `` power, so in the case above jobs with 'new' or
239- 'verified' tag are expected.
214+ List of tags in **has_tag ** has ``OR `` power, so in the case above jobs with
215+ ``new `` or ``verified `` tag are expected (while list of tags in **lacks_tag **
216+ has ``AND `` power).
240217
241218To get certain number of last finished jobs per some spider::
242219
@@ -250,10 +227,10 @@ for filtering by state:
250227- finished
251228- deleted
252229
253- Dict entries returned by ``iter `` method contain some additional meta,
254- but can be easily converted to `` Job ` ` instances with::
230+ Dictionary entries returned by ``iter `` method contain some additional meta,
231+ but can be easily converted to :class: ` ~scrapinghub.client.jobs. Job ` instances with::
255232
256- >>> [Job(x['key']) for x in jobs]
233+ >>> [Job(client, x['key']) for x in jobs]
257234 [
258235 <scrapinghub.client.Job at 0x106e2cc18>,
259236 <scrapinghub.client.Job at 0x106e260b8>,
@@ -290,6 +267,25 @@ It's also possible to get last jobs summary (for each spider)::
290267
291268Note that there can be a lot of spiders, so the method above returns an iterator.
292269
270+
271+ update_tags
272+ ^^^^^^^^^^^
273+
274+ Tags is a convenient way to mark specific jobs (for better search, postprocessing etc).
275+
276+
277+ To mark all spider jobs with tag ``consumed ``::
278+
279+ >>> spider.jobs.update_tags(add=['consumed'])
280+
281+ To remove existing tag ``existing `` for all spider jobs::
282+
283+ >>> spider.jobs.update_tags(remove=['existing'])
284+
285+ Modifying tags is available on :class: `~scrapinghub.client.spiders.Spider `/
286+ :class: `~scrapinghub.client.jobs.Job ` levels.
287+
288+
293289Job
294290---
295291
@@ -310,6 +306,10 @@ To delete a job::
310306
311307 >>> job.delete()
312308
309+ To mark a job with tag ``consumed ``::
310+
311+ >>> job.update_tags(add=['consumed'])
312+
313313.. _job-metadata :
314314
315315Metadata
@@ -422,13 +422,12 @@ To post a new activity event::
422422Or post multiple events at once::
423423
424424 >>> events = [
425- {'event': 'job:completed', 'job': '123/2/5', 'user': 'john'},
426- {'event': 'job:cancelled', 'job': '123/2/6', 'user': 'john'},
427- ]
425+ ... {'event': 'job:completed', 'job': '123/2/5', 'user': 'john'},
426+ ... {'event': 'job:cancelled', 'job': '123/2/6', 'user': 'john'},
427+ ... ]
428428 >>> project.activity.add(events)
429429
430430
431-
432431Collections
433432-----------
434433
@@ -559,24 +558,30 @@ Frontiers are available on project level only.
559558
560559.. _job-tags :
561560
562- Tags
563- ----
564561
565- Tags is a convenient way to mark specific jobs (for better search, postprocessing etc).
562+ Settings
563+ --------
566564
567- To mark a job with tag `` consumed ``::
565+ You can work with project settings via :class: ` ~scrapinghub.client.projects.Settings `.
568566
569- >>> job.update_tags(add=['consumed'])
567+ To get a list of the project settings::
570568
571- To mark all spider jobs with tag ``consumed ``::
569+ >>> project.settings.list()
570+ [(u'default_job_units', 2), (u'job_runtime_limit', 24)]]
572571
573- >>> spider.jobs.update_tags(add=['consumed'])
572+ To get a project setting value by name::
574573
575- To remove existing tag ``existing `` for all spider jobs::
574+ >>> project.settings.get('job_runtime_limit')
575+ 24
576576
577- >>> spider.jobs.update_tags(remove=['existing'])
577+ To update a project setting value by name::
578+
579+ >>> project.settings.set('job_runtime_limit', 20)
578580
579- Modifying tags is available on spider/job levels.
581+ Or update a few project settings at once::
582+
583+ >>> project.settings.update({'default_job_units': 1,
584+ ... 'job_runtime_limit': 20})
580585
581586
582587Exceptions
0 commit comments