Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
snippets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
snippets
Commits
55327911
Unverified
Commit
55327911
authored
6 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Allow rescheduling from elasticsearch errors output
I have difficulties naming things.
parent
535b7431
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ardumont/from-output-to-csv.py
+71
-0
71 additions, 0 deletions
ardumont/from-output-to-csv.py
with
71 additions
and
0 deletions
ardumont/from-output-to-csv.py
0 → 100755
+
71
−
0
View file @
55327911
# Use sample:
# cat mercurial.output.txt | \
# grep 'sensible-filter' | \
# python3 -m from-output-to-csv
# The output of this command is designed to feed the
# `swh.scheduler.cli task schedule` subcommand
import
ast
import
click
import
json
import
sys
TYPES
=
{
'
mercurial
'
:
'
origin-update-hg
'
,
'
mercurial-archive
'
:
'
origin-load-archive-hg
'
,
'
svn
'
:
'
origin-update-svn
'
,
'
svn-archive
'
:
'
swh-loader-mount-dump-and-load-svn-repository
'
,
'
pypi
'
:
'
origin-update-pypi
'
,
}
@click.command
()
@click.option
(
'
--task-policy
'
,
default
=
'
oneshot
'
,
type
=
click
.
Choice
([
'
oneshot
'
,
'
recurring
'
]),
help
=
"
Task
'
s policy
"
)
@click.option
(
'
--task-type
'
,
default
=
'
mercurial
'
,
type
=
click
.
Choice
(
TYPES
.
keys
()),
help
=
"
Task
'
s type
"
)
def
main
(
task_policy
,
task_type
):
"""
Given an output from kibana_fetch_logs, transform the input in csv
format (; as delimiter) to ease back scheduling for those
origins.
The output format is of the form:
<task-type>;<task-policy>;task-args;task-kwargs
Then use of `swh.scheduler.cli schedule` subcommand.
cat <output-of-this-command> |
\
python3 -m swh.mercurial.cli task schedule
\
--columns type
\
--columns policy
\
--columns args
\
--columns kwargs
\
--delimiter
'
;
'
-
"""
for
line
in
sys
.
stdin
:
line
=
line
.
rstrip
()
data
=
ast
.
literal_eval
(
line
)
_task_type
=
TYPES
.
get
(
task_type
)
_task_args
=
json
.
dumps
(
data
[
'
args
'
])
kwargs
=
data
[
'
kwargs
'
]
# HACK: Should have been set earlier...
if
task_type
in
[
'
mercurial
'
,
'
mercurial-archive
'
]:
if
'
visit_date
'
not
in
kwargs
:
kwargs
[
'
visit_date
'
]
=
'
Tue, 3 May 2016 17:16:32 +0200
'
_task_kwargs
=
json
.
dumps
(
kwargs
)
print
(
'
;
'
.
join
([
_task_type
,
task_policy
,
_task_args
,
_task_kwargs
]))
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment