qiskit-documentation/scripts/tutorial-uploader
Frank Harkins 0dabb0559d Rewrite learning uploader (#1421)
The requirements for the learning uploader have changed since it was
first created.

It was originally intended to be used locally by writers to quickly push
content to the platform. I wrote it in Python so writers would not need
to install node, and using string manipulations to interact with the
REST API was good enough for just uploading the zip and linking the new
file. It also included functionality for a writer to log into the
database through a CLI.

Now, the uploader is only used in CI, so we don't care about logging in
or sticking to Python, and we want to be able to do more complex
manipulations such as adding new lessons and changing metadata. For this
reason, this PR rewrites the uploader using the official [Directus
SDK](https://docs.directus.io/guides/sdk/), which makes interacting with
the API a lot easier.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Arnau Casau <47946624+arnaucasau@users.noreply.github.com>
Co-authored-by: Abby Mitchell <23662430+javabster@users.noreply.github.com>
2024-07-09 09:36:21 +00:00
..
lib Rewrite learning uploader (#1421) 2024-07-09 09:36:21 +00:00
README.md Rewrite learning uploader (#1421) 2024-07-09 09:36:21 +00:00
setup-for-testing.ts Rewrite learning uploader (#1421) 2024-07-09 09:36:21 +00:00
sync.ts Rewrite learning uploader (#1421) 2024-07-09 09:36:21 +00:00
validate-config.ts Rewrite learning uploader (#1421) 2024-07-09 09:36:21 +00:00

README.md

Tutorial uploader

This script uploads tutorials to IBM Quantum Learning.

Developing

To work on this script, you'll need to set up the saiba-api project locally.

There are some extra steps you'll need to take to set up saiba-api for developing this script:

  • Follow the instructions in the README in the saiba-api repo. Don't forget the instructions to add the PUBLIC_URL entry to your docker-compose.yaml.

  • Login into the local CMS (http://0.0.0.0:8055/admin/) using

    • email: admin@example.com
    • password: password
  • Create a token for local testing.

    1. In the local CMS, go to "User directory" (in the leftmost navbar)
    2. Click "Create item"
    3. Create a new user with the "Content creator admin" role and generate a new static token. Copy the token to your clipboard. Then click the tick on the top-right of the page to save the user.
    4. To test the script in this repo, export the following environment variables.
      export LEARNING_API_URL=http://0.0.0.0:8055
      export LEARNING_API_TOKEN=<copied-token>
      
      Consider using direnv to handle this.
  • With the local database running, run the following command to add the topics and categories that we expect to exist.

    npm run tutorial:setup-testing