Trial run for importing the nublado.org Trac tickets as GitHub issues.
There are several projects that do all or some of this semi-automatically
pipenv
pipenv run tracboat export --format json --out-file ~/tmp/nublado-trac-export.json --trac-uri=https://www.nublado.org/xmlrpc --no-ssl-verify
# Import tracboat/src/tracboat/trac.py
import trac
trac_uri="https://www.nublado.org/xmlrpc"
source = trac.connect(
trac_uri,
encoding='UTF-8',
use_datetime=True,
ssl_verify=False
)
# Get a list of all the ticket IDs
ticket_ids = source.ticket.query("max=0&order=id")
# Get the attachments from the latest ticket that has one
att = trac.ticket_get_attachments(source, 430)
# This returns a utf-8 bytes stream - decode it to string for printing
print(att["ism.in"]["data"].decode())
So that works for text attachments at least - I can't find any binary attachments to test on
bson
ascii encoding (something to do with MongoDB)git config
github.user
, not github.username
migrate.py
, but I am going to try and test the constituent partsm = Migrator(
"https://www.nublado.org",
github_username=github_username,
github_password=github_password,
github_project="cloudy-astrophysics/bug-tracker-migration-test",
github_api_url="https://api.github.com",
username_map={},
config={"labels": {}}
m.load_github()
get_all_tickets = xmlrpclib.MultiCall(m.trac)
)
So far, so good, but then:
tickets = m.trac.ticket.query("max=0&order=id")
fails with
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1056)
tracboat
to compare with. It turns out, we need to add the argument context=ssl._create_unverified_context()
to xmlrpclib.ServerProxy()
ProtocolError: <ProtocolError for www.nublado.org//login/rpc: 401 Unauthorized>
tracboat
they were using a different API url: https://www.nublado.org/xmlrpc, and when I switch to that it worksget_all_tickets = xmlrpclib.MultiCall(m.trac)
get_all_tickets.ticket.get(430)
get_all_tickets.ticket.get(111)
list(get_all_tickets())
This works, but it doesn't get the attachments:
[[430,
<DateTime '20191008T12:10:38' at 0x10a3aba90>,
<DateTime '20191008T12:10:38' at 0x10a3ab6d8>,
{'status': 'new',
'changetime': <DateTime '20191008T12:10:38' at 0x10a3abbe0>,
'_ts': '1570536638433514',
'description': 'The abundances command includes the keywords "no grains" and "no qheat" to modify the implicit grains that are included in certain mixtures. The "no qheat" option does not work on c17 but works in c13 and the trunk. A simple example is attached. ',
'reporter': 'gary',
'cc': '',
'resolution': '',
'time': <DateTime '20191008T12:10:38' at 0x10a3ab908>,
'component': 'grains',
'summary': 'abundances ISM no qheat does not work on c17',
'priority': 'blocker',
'keywords': '',
'version': 'c17_branch',
'milestone': 'c17.02',
'owner': 'peter',
'type': 'defect - etc'}],
[111,
<DateTime '20091117T02:35:40' at 0x10a3abef0>,
<DateTime '20190204T12:10:21' at 0x10a3ab668>,
{'status': 'accepted',
'changetime': <DateTime '20190204T12:10:21' at 0x10a3ab940>,
'_ts': '1549282221449479',
'description': 'The following model fails on trunk r3594 after failing to find an initial solution. We appear to be at a temperature instability, and a very slightly less dense model (13.5575) finishes fine. This model produces negative ion population errors in NI (and eventually all stages of nitrogen) but these are most likely unrelated to the root problems. \n{{{\nblackbody 1.16e7\nluminosity 37\nradius 10.48\nhden 13.5578\nstop zone 1\n}}}\n\n',
'reporter': 'rporter',
'cc': '',
'resolution': '',
'time': <DateTime '20091117T02:35:40' at 0x10a3ab0b8>,
'component': 'thermal convergence',
'summary': 'temperature instability',
'priority': 'major',
'keywords': '',
'version': 'trunk',
'milestone': 'c19 branch',
'owner': 'peter',
'type': 'defect - FPE'}]]
tracboat
, we only have the attributes
dict, and we are the missing the attachments
dict and the changelog
list of dicts. The comments are part of changelog
, but this also has edits to the description, title, etcticket_get_changelog
and ticket_get_attachments
. Alternatively, we could use tracboat to dump the JSON file and then functions from migrate.py
for the second step. Either way, we should bear in mind the following:
migrate.py
has a fancier method of queuing up all the queries with xmlrpc.client.MultiCall()
and then just doing one network call for everything. This should be more efficient, but there are aspects of it that I still don't understand.oldvalue
, which makes sense, but sometimes the oldvalue
is a number, which I don't understand. Aha, they do get the comments, see belowMigrator.get_trac_comments()
comments = m.get_trac_comments(111)
yields
{'20091117T22:51:41': ['@rjrw changed description from:\n\n> The following model fails on trunk r3594 after failing to find an initial solution. We appear to be at a temperature instability, and a very slightly less dense model (13.5575) finishes fine. This model produces negative ion population errors in NI (and eventually all stages of nitrogen) but these are most likely unrelated to the root problems. \n> \n> blackbody 1.16e7\n> \n> luminosity 37\n> \n> radius 10.48\n> \n> hden 13.5578\n> \n> stop zone 1\n> \n> \n> \n\nto:\n\n> The following model fails on trunk r3594 after failing to find an initial solution. We appear to be at a temperature instability, and a very slightly less dense model (13.5575) finishes fine. This model produces negative ion population errors in NI (and eventually all stages of nitrogen) but these are most likely unrelated to the root problems. \n> \n> ```\n> blackbody 1.16e7\n> luminosity 37\n> radius 10.48\n> hden 13.5578\n> stop zone 1\n> ```\n> \n> \n\n'],
'20091119T08:35:05': ['@rjrw changed attachment from "" to "conv_change"',
'@rjrw commented:\n\n> Updated patch to deal with underflow problems on 64bit\n\n'],
'20091120T12:15:03': ['@peter commented:\n\n> This is fixed on the mainline in r3610. This is the less invasive fix intended for c10_branch. Once we have branched, the more invasive patch intended for C12 that is attached to this PR will be applied to the trunk. So keeping this PR open until that has been done.\n\n',
'@peter changed milestone from "" to "C12 branch"',
'@peter changed owner from "nobody" to "peter"',
'@peter changed status from "new" to "accepted"'],
'20091120T12:19:49': ['@peter changed attachment from "" to "patch2"',
'@peter commented:\n\n> updated patch wrt r3610\n\n'],
'20190204T11:54:34': ['@peter changed milestone from "C13 branch" to "C19_branch"'],
'20190204T12:10:21': ['@peter commented:\n\n> Milestone renamed\n\n',
'@peter changed milestone from "C19_branch" to "c19 branch"']}
users:
'gary / robin': CloudyLex
gary: CloudyLex
rjrw: rjrw
will: will-henney
mchatzikos: mchatzikos
fguzman: fguzmanful
# nicholas: MISSING
# wangye0206: MISSING
# dquan: MISSING
# matt: MISSING
# peter: MISSING
# 'Peter, van, Hoof, <p.vanhoof@oma.be>': MISSING
# rporter: MISSING
# Ryan: MISSING
# 'rporter@pa.uky.edu' MISSING
# nobody: MISSING
# somebody: MISSING
# anonymous: MISSING
map-all-to-will.yaml
that maps all the Trac users to me (will-henney). I will use this during the testing stages, and then swap in the real mapping for the final migration.
cloudy-migration-bot
or similar. Migrator.migrate_tickets()
Migrator.import_issue()
migrate.py
Help message for my new version
$ ../migrate-trac-issues-to-github/migrate.py --help
usage: migrate.py [-h] [--trac-username TRAC_USERNAME] [--trac-url TRAC_URL]
[--github-username GITHUB_USERNAME]
[--github-api-url GITHUB_API_URL]
[--github-project GITHUB_PROJECT]
[--username-map USERNAME_MAP]
[--trac-hub-config TRAC_HUB_CONFIG] [--ssl-verify]
[--dry-run] [--ticket-range TICKET_RANGE TICKET_RANGE]
optional arguments:
-h, --help show this help message and exit
--trac-username TRAC_USERNAME
Trac username (default: will)
--trac-url TRAC_URL Trac base URL (`USERNAME` and `PASSWORD` will be
expanded)
--github-username GITHUB_USERNAME
Github username (default: will-henney)
--github-api-url GITHUB_API_URL
Github API URL (default: https://api.github.com)
--github-project GITHUB_PROJECT
Github Project: e.g. username/project
--username-map USERNAME_MAP
File containing tab-separated Trac:Github username
mappings
--trac-hub-config TRAC_HUB_CONFIG
YAML configuration file in trac-hub style
--ssl-verify Do SSL properly
--dry-run Do not actually import any issues into GitHub
--ticket-range TICKET_RANGE TICKET_RANGE
First and last ticket IDs to process
The last three options are ones that I have added.
../migrate-trac-issues-to-github/migrate.py --trac-url=https://www.nublado.org --dry-run --ticket-range 1 10
--dry-run
. This has put the first 10 tickets into the repo. Most of them were opened by Ryan. Note that we still do not have the attachments. That is what I will try and fix next. Adding milestone {'due': 0, 'completed': 0, 'description': 'This is the default milestone. It is appropriate for mainly for enhancements that are not time critical.', 'name': 'no milestone'}
Exception: 'int' object has no attribute 'timetuple'
> /Users/will/Dropbox/cloudy-github-migration/migrate-trac-issues-to-github/migrate.py(170)get_gh_milestone()
Problem is that there was no Due date. In fact, looking at the JSON dump, none of the milestones have a Due date, although some do have a Completed date.
username
-> username-noaccount
. Since these usernames do not actually exist on Github, this caused all sorts of problems, which I fixed by brute force with a bunch of try-excepts. As a result the issues will be peppered with a bunch of "@username-noaccount" tags that do not resolve to users, but never mind.c:ionization-convergence
p:minor
type:
'#color': '0366d6'
defect: t:defect
defect - (web) documentation: t:defect:(web)-documentation
defect - FPE: t:defect:FPE
defect - code aborts: t:defect:code-aborts
defect - convergence: t:defect:convergence
defect - etc: t:defect:etc
defect - failed assert: t:defect:failed-assert
defect - wrong answer: t:defect:wrong-answer
enhancement: t:enhancement
physics: t:physics
task: t:task
There are similar mappings for components, priorities, etc.
pat:bug-tracker-migration-test will$ python utils/extract-attachments.py data/nublado-trac-export.json
{'', '.JPG', '.c', '.cpp', '.dat', '.diff', '.dr', '.gz', '.in', '.ini', '.inp',
'.jpg', '.old', '.out', '.patch', '.pdf', '.png', '.rfi', '.szd', '.tgz',
'.txt', '.vlg', '.xz', '.zip'}
trac-legacy-attachments
repo (organize in folders by ticket)
get_trac_attachments_as_comments
, which is working more or less
trac-legacy-attachments
, which is not ideal. So I have now set it to raw.githubusercontent.com so the link is just to the raw file. (Although this got messed up on tickets 161 to 200, which have broken links).