quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.67k stars 295 forks source link

Publish to Hugging Face workflow Improvement ? #9786

Open cderv opened 2 months ago

cderv commented 2 months ago

I Followed confguration steps at https://quarto.org/docs/publishing/hugging-face.html

First time publishing

❯ quarto publish huggingface
The current git repository needs to be reconfigured to allow `quarto publish`
to publish to Hugging Face Spaces. Please enter your username and authentication token.
Refer to https://huggingface.co/blog/password-git-deprecation#switching-to-personal-access-token
for more information on how to obtain a personal access token.
? Hugging Face username » cderv
? Hugging Face authentication token: » *************************************
No local changes to save
From https://huggingface.co/spaces/cderv/demo-quarto-website
 * branch            main       -> FETCH_HEAD
Already up to date.
No stash entries found.
Could not pop git stash.
This is likely because there are no changes to push to the repository.

Publishing a modified version

echo "Adding some dummy content" >> src/index.qmd
git commit -am 'tweak content'

Note here that I did not know but I committed then tried to publish

And it was not working

❯ quarto publish huggingface
No local changes to save
From https://huggingface.co/spaces/cderv/demo-quarto-website
 * branch            main       -> FETCH_HEAD
Already up to date.
No stash entries found.
Could not pop git stash.
This is likely because there are no changes to push to the repository.

I see in Hugging Face implementation that publish is supposed to commit src to main

So as I hinted, this is probably a workflow issue here because I committed myself the change and it seems our workflow does not support this. @cscheid is this expected ? Should we consider this workflow too or at least warn ? We could detect unpushed changes with git diff --quiet main origin/main after the fetch

I don't work with hugging face, but it seemed quite common to commit the change in a project as HuggingFaces is using main branch. Working on the project in any IDE will change changes to src.

I did not expect the quarto publish command to require to not commit.

I think we should support both workflow. I can work on a PR.

Some other notes (but other issue maybe: --no-prompt requires a publish YAML which does not exist the first time - like gh-pages maybe?)

❯ quarto publish huggingface --no-prompt
ERROR: No _publish.yml file available (_publish.yml specifying a destination required for non-interactive publish)

Stack trace:
    at resolveDeployment (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/publish/deployment.ts:105:13)
    at eventLoopTick (ext:core/01_core.js:153:7)
    at async publishAction (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/publish/cmd.ts:222:7)
    at async Command.actionHandler (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/publish/cmd.ts:163:11)
    at async Command.execute (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1948:7)
    at async Command.parseCommand (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1780:14)
    at async quarto (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:156:3)
    at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:170:5
    at async mainRunner (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/main.ts:35:5)
    at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:160:3

So when going back to reverting and publishing it works

# reverting commit
git reset origin/main
quarto publish huggingface
Saved working directory and index state WIP on main: 8137aba initial commit
From https://huggingface.co/spaces/cderv/demo-quarto-website
 * branch            main       -> FETCH_HEAD
Already up to date.
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   index.qmd

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (9e80d16eb28282a02881a2c47d0aab1554bf7ac5)
[main 184a37f] commit from `quarto publish`
 1 file changed, 1 insertion(+)
To https://huggingface.co/spaces/cderv/demo-quarto-website
   8137aba..184a37f  main -> main
NOTE: Hugging Face Space sites build the content remotely and use caching.
You will need to wait a moment for Hugging Face to rebuild your site, and
then click the refresh button within your web browser to see changes after deployment.

Specifically, you need to:
- wait for your space's status to go from 'Building' to 'Running'
  (this is visible in the status bar above the space)
- force-reload the web page by holding Shift and hitting the reload button in your browser.

Though it is quite verbose, and we could probably hide some git log here.

Originally posted by @cderv in https://github.com/quarto-dev/quarto-cli/issues/9648#issuecomment-2134825792

cscheid commented 2 months ago

I did not expect the quarto publish command to require to not commit.

I think we should support both workflow.

(I'm late here, but since you tagged me) This is a great change, thanks.

cderv commented 2 months ago

Thanks for the feedback.

(I'm late here, but since you tagged me)

You're not. I did not do it yet, the other PR was gh-pages only. I found this while testing.

but I'll remember to update the publishing workflow for hugging face with this