Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle updated Kolibri channels #137

Merged
merged 6 commits into from
Dec 7, 2023
Merged

Conversation

dbnicholson
Copy link
Member

If a Kolibri channel has been updated on Studio, the content server needs to run a channel update procedure or it won't import new content nodes.

While here, I couldn't resist the temptation to refactor all of this so that all the dispersed hooks can go away. I ran the Endless Key process locally and it seemed to work.

https://phabricator.endlessm.com/T34697

Copy the Kolibri server content seeding code common to vanilla Kolibri
and Endless Key to a separate module so that any changes can be shared
between the hooks.

https://phabricator.endlessm.com/T34697
This Kolibri option no longer exists in 0.16, which Endless Key is
using.

https://phabricator.endlessm.com/T34697
The FIXME has been addressed by not caching the Kolibri homedir on the
image builder and instead using the content server as the cache for
Kolibri content. There's no need to use a temporary homedir and copy it
into place.
This simplifies both configurations as the content seeding and
installation can be done in a single shell hook.

https://phabricator.endlessm.com/T34697
When a channel is updated is updated on Kolibri Studio, importing the
channel and content again does not fetch new content nodes. Instead, a
channel update process is needed, which also requires generating the
diff between the old and new versions of the channel.

Fortunately, there are APIs for those tasks, so run them if the channel
already exists on the server to ensure the it has seeded all content
nodes from the (potentially) updated channel.

https://phabricator.endlessm.com/T34697
Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Nice simplification too!

host = urlparse(base_url).netloc
creds = netrc_creds.authenticators(host)
if not creds:
logger.info(f'No credentials for {host}')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        logger.info(f'No credentials for {host} in {netrc_path}')

perhaps?

"""Wait for remote Kolibri job to complete"""
logger.debug(f'Waiting for job {job_id} to complete')
last_marker = None
while True:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to rate-limit this to check every 1 second rather than spamming the server as fast as we can go?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. I might split the difference to 0.5 seconds so there's less artificial slowdown.

f'Job {job_id} failed: {data["exception"]}\n{data["traceback"]}'
)
raise Exception(f'Job {job_id} failed')
elif status == 'CANCELED':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went to check the spelling here and it really is CANCELED for tasks, though for Morango sync it's CANCELLED.

I wasn't aware of the US spelling for this word (though I guess it's consistent with other Commonwealth vs US variations) but I'm really happy to see that both spellings are used in Kolibri!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't even thought about that! I just copied the strings directly out of the module.

@wjt wjt merged commit 2b194d4 into master Dec 7, 2023
2 checks passed
@wjt wjt deleted the T34697-kolibri-update-channel branch December 7, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants