openstax / corgi

CORGI
https://gitpod.io/#https://github.com/openstax/corgi
MIT License
1 stars 0 forks source link

CORGI Update #507

Closed ckline-tryptic closed 1 year ago

ckline-tryptic commented 2 years ago

Description

Since we are retiring Archive and moving fully to GitHub, CORGI needs to change to accommodate this new workflow, and require GitHub authentication. This opportunity is also being taken to update CORGI to V2.

Acceptance Criteria

TODO

Canceled / Deferred

ckline-tryptic commented 2 years ago

The question of whether to migrate CORGI over to Svelte vs sticking with Vue should be resolved sooner rather than later.

Here are a few items for consideration:

Neutral

Pro Svelte

Pro Vue

therealmarv commented 2 years ago

I also wanted to write down my opinion.

Good and helpful comparison of this two frameworks https://www.vuemastery.com/blog/vue-vs-svelte-comparing-framework-internals/

Pro Svelte

Con Svelte

Personal opinion:

I don't think the vue code is that much harder to read in comparison to Svelte. It's only more explicit where things live in a vue centric World (e.g. internal value store, events and VirtualDOM update process) and Svelte does some of this things magically in their compiler (that's were the magic in Svelte lies and why it looks like it needs less code). Overall our frontend is not a very big project. What is really missing is better (re)structure and separate things into components and a major rewrite with Svelte can lead to the same results there.

philschatz commented 2 years ago

I haven't had a chance to compare Nuxt & Svelte yet but:

  1. How does Nuxt and GitHub Authentication relate? I thought OAuth needed to be done with the server, not a frontend UI.
  2. Where are the CORGI mockups again? I forgot to remember the link
  3. Where's the link to the svelte code? Ah Here: corgi-svelte . and this is the deployment PR
  4. Could Otto pick a test to have Chris rewrite in svelte?

Notes: Unit tests in Jest, Code coverage on all the files, debugging examples (to see how much the auto-injected code and compilation impacts devs)

m1yag1 commented 2 years ago

As I was playing around with the UI, I noticed that it might be useful to have a clear button to empty all the fields. It's not super important and mainly for convenience. That's something that I can try and implement.

ckline-tryptic commented 2 years ago

Working on job submission / form validation now.

TylerZeroMaster commented 2 years ago

My opinion:

Svelte Advantages

Example of sledgehammer reactivity in svelte

If you want to try this yourself, go to svelte.dev and use the editor on the home page.

<script>
    let ticker = false
    let interval = -1
    let timeout = 1000

    $: if (timeout > 0) {
        clearInterval(interval)
        interval = setInterval(() => ticker = !ticker, timeout)
    }
</script>
{@debug interval}
<h1>{ticker ? 'Tick' : 'Tock'}</h1>
Timeout: <input type="number" bind:value={timeout}/>

Problem:

The interval will be cleared and set again every time because ticker is in the scope of the $:, even though it is not directly in scope (it's in an arrow function). The point is that you need to be careful what you include in the scope of one of these $: things because it will run when any global variable in any sub-scope of the $: scope changes.

Explanation

You can see the problem more clearly in the 'compiled js' output:

/* App.svelte generated by Svelte v3.49.0 */
/* -- snip -- */
    $$self.$$.update = () => {
        if ($$self.$$.dirty & /*timeout, interval, ticker*/ 7) {
            $: if (timeout > 0) {
                clearInterval(interval);
                $$invalidate(1, interval = setInterval(() => $$invalidate(0, ticker = !ticker), timeout));
            }
        }
    };
/* -- snip -- */

It shows that the bit that represents ticker is included in the binary AND that is used to determine if an update is required.

Solution

Use a function to remove ticker from the scope.

<script>
    let ticker = false
    let interval = -1
    let timeout = 1000

    function startTicker() {
        interval = setInterval(() => ticker = !ticker, timeout)
    }

    $: if (timeout > 0) {
        clearInterval(interval)
        startTicker()
    }
</script>
{@debug interval}
<h1>{ticker ? 'Tick' : 'Tock'}</h1>
Timeout: <input type="number" bind:value={timeout}/>
m1yag1 commented 2 years ago

First, thanks to those before me who submitted such detailed comments. I've been waiting to leave my comments to try and not tilt the balance in any direction, so I'm focusing on the positives.

Pro Svelte

I don't think Svelte will make or break the CORGI frontend. I can see clear advantages to why Svelte is a perfect framework for CORGI. Marvin's referenced article states, "Svelte will shine only when you’re building something like a spreadsheet application where thousands of reactive values are interconnected." I think this statement marks an important point about the strengths of Svelte, which is making reactive sites simple. CORGI is a lot like a spreadsheet application, and it may benefit us to remove all the extra things we don't use in nuxt.js. Removing extra features keeps us from having to maintain them over time. Lastly, the feedback from the community is extremely positive and hard to ignore.

Other pros

Pro Vue/nuxt.js

As a manager, I must seriously consider why we want to rewrite software. The "secret sauce" of LEAN software development is being purely iterative. By always chasing the next kaizen card, we transform the software we use to what the customer needs. If we didn't determine through experimentation that we need to rewrite the front-end, how do we know we need to rewrite it? Additionally, I have experience working on the front-end, and while there was a small learning curve, I enjoyed the process and felt nuxt.js provided a lot of flexibility we can still leverage into the future. I feel like we could have chosen Svelte or nuxt.js (both released in 2016).

m1yag1 commented 2 years ago

No updates to the issue since my last comment (?). It's really hard to tell where this is at w/o digging further.

therealmarv commented 2 years ago

Unfortunately I cannot join the meeting today but I'm biased to Vue personally (partly also because I have written large parts of current CORGI UI). Reasons are mostly that it's an iterative approach as Mike pointed out (we have something running and tested which needs refinement, upgrade and separation of concerns with more components) and Vue can be sprinkled into other possible projects we may have in future. The community is also bigger which is proven e.g. by the more advanced UI framework we currently use.

I think the biggest PRO for Svelte currently is that mainly Chris and partly Tyler are basically owning it and making amazing progress on it. There is currently no bigger effort going on on upgrading our Vue/Nuxt system (I wished I had time for it but there were other high priority things to do). If we continue using Vue it may slow them down in their progress. I definitely do NOT want to slow Chris and Tyler down just because I think that Vue has a little bit more flexibility (no compiler necessarily needed, tooling etc.), bigger community (more libraries like Vuetify) and is more "battle proven" by our users in the last years. I can imagine getting up to speed in a new Svelte CORGI project too.

ckline-tryptic commented 2 years ago

Fixed Icons, added details / actions dialog, fixed elapsed time, hooked up api for buttons. added login redirect. Working on autocomplete.

TylerZeroMaster commented 2 years ago

I finished altering the corgi-concourse-resource so that it will be able to translate to/from the old and new schema. It works locally. Next I would like to see if it will work in a PR environment.

Sidenote:

I ran into some problems because I was working on a branch that was based on a branch that I later squash merged into the main branch of Enki. Incase other people run into this problem, I found what I think is the ideal solution (backup your branch before you try this):

  1. Checkout the branch that was based on the one you squash merged
  2. Find the last commit that was squash merged into main and copy it's commit sha
  3. Run git rebase <commit_sha> --onto main
  4. Ideally you should be left with a branch that has all commits after <commit_sha> applied on top of the tip of main (like this one) 🎉.
TylerZeroMaster commented 2 years ago

Last Friday, 10/28/22, we managed to get this working an a PR pipeline here. It works better than expected for the first deploy. Building books works; the status of each job is updated as a book is built; aborting jobs works; and GitHub OAuth mostly works. Honestly, there are only a few problems.

What we know is problematic

What should change in the future

omehes commented 2 years ago

Initial testing results of the new corgi ui - https://corgi-514.ce.openstax.org/

  1. Can the pdf (job artifacts) be open in a separate tab? At the moment it opens in the same tab as the corgi is - I see this is already mentioned

  2. Is there enough space to expand the selection fields to maybe see the complete repo and book text (or as much as possible)?

  3. webview does not run a job

  4. select a repo and book, then delete (clear) book selection and after that clear repo. select a different repo and click the book field. the selection in the book field will show the books for the previously selected repo. I have to refresh browser to make it work correctly again. 59582241-60F9-4FDD-A175-011016CBA981_4_5005_c 281EF571-4F4D-4541-B136-83F016D19B92_4_5005_c

  5. epub job does not work - getting fetch-utils.ts:11 POST https://corgi-514.ce.openstax.org/api/jobs/ 500

  6. I am able to start a job for some repos (not all) while nothing is entered into the book field. Job starts with correct book entry and that book style is added to the book dropdown (even though it was not there before) 050252E0-049E-4345-A803-D38DA83325C8 56E4A358-2752-4B20-AFFF-33B49D295264

  7. we used to mark aborted jobs with brown colour. Maybe we could distinguish aborted and failed jobs with colours too (red ! - failed, brown x - aborted)? 8B33B758-58B6-4FED-9CE0-F77DFBDD6D0C_4_5005_c

  8. when all books in the bundle are processed, the resulting link to artifact looks a bit disorganised and only one of the titles is clickable. Maybe they could be listed in separate rows? A842CECA-827B-4A09-8EEF-A5BA8A6A3F13

TylerZeroMaster commented 2 years ago

I think most of the issues documented here have either been fixed or have a clear path to being fixed. We still need to fix the remaining issues, update all the tests, figure out how authentication and authorization should work in the first release, and get some more feedback from users.

Some feedback that I thought of:

  1. When you mouse over Elapsed values, you can see when a job is created. I wonder if this should be reversed. In my opinion, the date/time a job was started is more useful, at a glance, than the elapsed time.
  2. ~Error messages need to be shown to the user (maybe a snackbar or a toast). Right now there is literally no indication of errors occurring. You need to use your browser's dev tools to know that an error occurred.~
  3. Autocomplete for version field does not work.
  4. When the concourse resource checks for new jobs, most of the information it gets from the endpoint is extraneous (i.e. user, books, etc.). It might be a good idea to add something like a jobs-min endpoint that returns the minimum amount of information required for jobs of a specific type.
  5. ~Autocomplete does not work correctly for non-openstax repositories.~
  6. ~Intermittent 504 Gateway Timeout error on /api/jobs endpoint. When the error occurs, the backend takes > 50 seconds to respond.~ (Something was causing the proxy service to restart at a seemingly random interval. Restarting all the services fixed the issue)
TylerZeroMaster commented 1 year ago

Most of the issues listed previously have been addressed, so I found some more.

  1. When you build a repository that was not in the database, the autocomplete list does not update.
  2. Webview filtering is broken
  3. Some non-book repositories appear in the repo autocomplete list (exmaple template-osbooks)
  4. EPUB job type does not exist yet
TylerZeroMaster commented 1 year ago

@omehes

I am able to start a job for some repos (not all) while nothing is entered into the book field. Job starts with correct book entry and that book style is added to the book dropdown (even though it was not there before)

You should be able to build any repo without supplying a book because the backend fetches all the book metadata when you submit a job. Granted, in the initial release, the book field will be. It's possible that an authentication issue interfered with your ability to submit a job. Do you remember which repository you could not build?

we used to mark aborted jobs with brown colour. Maybe we could distinguish aborted and failed jobs with colours too (red ! - failed, brown x - aborted)?

I have done that, but I have not pushed the change to github yet. Same thing with the links.

I think everything else you mentioned has been fixed.

ckline-tryptic commented 1 year ago

Icon colors have been adjusted, and element ids have been added for testing purposes.

TylerZeroMaster commented 1 year ago

Frontend

  1. ~When you build a repository that was not in the database, the autocomplete list does not update.~
  2. ~Webview filtering is broken~
  3. ~EPUB job type does not exist yet (disable checkbox?)~
  4. ~Style is an optional property when creating a job, but it is completely ignored during job creation. Style should either be used or removed.~
  5. ~The Book field should be a required field until we can update Enki to build multiple books.~
  6. ~Expand the selection fields to see the complete repo and book text.~
  7. ~Try to figure a way around this strange SMUI autocomplete behavior:~

    select a repo and book, then delete (clear) book selection and after that clear repo. select a different repo and click the book field. the selection in the book field will show the books for the previously selected repo. I have to refresh browser to make it work correctly again.

  8. ~More detailed error messages.~

Backend

  1. ~Some non-book repositories appear in the repo autocomplete list (example template-osbooks)~
  2. ~Style is an optional property when creating a job, but it is completely ignored during job creation. Style should either be used or removed.~
  3. ~When the concourse resource checks for new jobs, most of the information it gets from the endpoint is extraneous (i.e. user, books, etc.). It might be a good idea to add something like a jobs-min endpoint that returns the minimum amount of information required for jobs of a specific type.~
  4. ~Fix strange behavior when creating jobs. For example, using a commit that exists in a different repository will cause a job to be created for the repository that the commit exists for, regardless of the repository that the user entered.~
  5. ~Make sure that everything works correctly for non-admin users.~
  6. ~Private repos in autocomplete.~
  7. ~More detailed error messages.~
  8. Add created/updated at times to new tables.

Waiting for more feedback

  1. When you mouse over Elapsed values, you can see when a job is created. I wonder if this should be reversed. In my opinion, the date/time a job was started is more useful, at a glance, than the elapsed time.
  2. Understand how filtering broke for at least one book (osbooks-statistics). We have not been able to recreate this issue yet.
    • Filtering should happen on more than one page at a time (reverse the order so that sorting happens before slicing down to page size)
ckline-tryptic commented 1 year ago

Changed status icons to Larissa's.

TylerZeroMaster commented 1 year ago
omehes commented 1 year ago

Some notes/observations:

1. When incorrect sha or other accepted data is entered into version field, we get a 500 error with not error explanation. Should we add some error text? ACCC61F3-ADD7-4AF3-86BB-F3793E2F2AEE

2. In the old corgi I used to copy/paste the repo names from the job raws. Don't know how much is this done by other users. It's a bit more difficult to do it in the new corgi UI because the (repeat, approve close) box pops up, then it has to be dismissed and then the highlighted selection can be copied. One word entries can be copy/pasted via simple right-click easier but multi word entries no.

Reply from Tyler: ...that bugs me too. I wonder if it would be better to have a specific clickable region of the row (maybe the ID)

3. New icons: at first sight they look very similar, especially the queued and processing ones. Maybe distinguish them more? also, the jobs which are successful, could the icons be static (like the Abort ones)? That would clearly distinguish them from all the others.

4. I was wondering. Can we handle multi error cases with multi error messages? Like in this case: incorrect book title in Book field and incorrect sha in Version field. Currently, it only shows error for one of them (incorrect sha)... 3B04343C-44C1-4F9C-B1EB-870BA2558DE9

TylerZeroMaster commented 1 year ago
  1. That's interesting, I would expect that to cause a graphql error, but it must be a different error because all graphql errors are forwarded to the client. It looks like GitHub is returning null instead of an error message when an object id that does not exist is used. I added a custom error for this situation. It should be ready for the next deploy.
  2. I will start to experiment with this.
  3. I agree it’s difficult to differentiate between queued, assigned, and processing. I wonder if it might make them more distinct if we vary the animations for each job status or only animate a subset. I think both the icons and autocomplete functionality could use additional discussion/feedback.
  4. Done: it should be ready for the next deploy.

In addition to the above:

omehes commented 1 year ago

Yea, I agree on point 3 above - team discussion (parking for Thursday)

TylerZeroMaster commented 1 year ago

Resolved

  1. Handling current data in the database. We need to do something because the current data is incompatible with the new schema. Options:
    1. Data migrations that only run once
      • Problem with using alembic: we would need to guarantee that the data (either old jobs or ABL data) would always be available when that migration runs.
      • Maybe we could run a data migration with a script that exists outside of CORGI
    2. Truncate the data
  2. Integration tests
    1. Need to be updated
    2. Need a username and password or an access token to authenticate with. Alternatively, we might be able to shim relevant parts of the GitHub api to get around authentication requirements (but that seems somewhat counter to the idea of integration testing).

Pending

  1. Should created_at and updated_at fields be on all tables?
  2. How do we start from a clean slate on staging/prod? Is it possible to create a new docker volume and swap them out? That would give us a backup of the current jobs too.
TylerZeroMaster commented 1 year ago

I finished the data migration for the ABL and noticed a small usability problem that we will want to address later. If, for example, you select astronomy as the book to build, the osbooks-astronomy repo is selected automatically, however, the 1e branch is not selected as the version. In this case, it will use main as the version and will not find the old book edition on the main branch because a new edition is on main.

Additionally, there was one error in the ABL data: repo_name: osbooks-college-algebra-bundle sha: ebc5beb15766e5a72d4d5085c1d470ae868007fb In repository: {'slug': 'college-algebra-coreq', 'style': 'precalculus-coreq'} In ABL: {'slug': 'college-algebra-corequisite-support', 'style': 'precalculus-coreq'}

TylerZeroMaster commented 1 year ago

Where we stand as of 22/12/22

I am making one more change to the way that jobs are cached to squeeze out a bit more performance. Other than that, we are ready to merge our changes, release to staging/proc, and wait for the inevitable issues to arise; however, we decided it would be best to wait until after the holidays to deploy.

Before we release, we should, "[...] let Alina know, as she’ll need to send the new documentation to the vendors and let them know it’ll be changing."