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

Workflow volume #57

Merged
merged 7 commits into from
Apr 12, 2023
Merged

Workflow volume #57

merged 7 commits into from
Apr 12, 2023

Conversation

bertsky
Copy link
Member

@bertsky bertsky commented Apr 11, 2023

fix #46

also,

  • add timestamps to job info
  • make interruptible

WORKFLOW=$(command -v "$WORKFLOW" || realpath "$WORKFLOW")
if ! test -f "$WORKFLOW"; then
logger -p user.error -t $TASK "invalid workflow '$WORKFLOW'"
exit 3
fi
logger -p user.notice -t $TASK "using workflow '$WORKFLOW':"
ocrd_format_workflow | logger -p user.notice -t $TASK
if test "${WORKFLOW#/workflows/}" = "$WORKFLOW"; then
Copy link
Collaborator

@markusweigelt markusweigelt Apr 11, 2023

Choose a reason for hiding this comment

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

I do not understand the check here cause of Line 48 and i think that needs a comment.

So with this parameter substitution it looks like the file test Line 48 will fail or this check will not be successful.

IMO for example:

With /workflows/ocr-workflow-default.sh as $WORKFLOW Line 48 will successful.

Line 54 "ocr-workflow-default.sh" = "/workflows/ocr-workflow-default.sh" will fail.

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 precisely the point. The check trivially looks whether the realpath of the workflow starts with /workflows and thus, needs no further action. If it does not, then it gets copied into the workdir under a default name, to ensure it will be accessible.

Copy link
Collaborator

@markusweigelt markusweigelt Apr 11, 2023

Choose a reason for hiding this comment

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

Alone that already the inquiry came from me would be worth to write comment there cause it is not easy to read (for none linux power users those for whom parameter substitution syntax has not yet become flesh and blood 😉 ) and understand why you do that here.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that by this logic, I would have to second every other statement in the script with an explanatory comment. Code is also documentation in itself. Only complex / non-trivial code bits should be commented.

If you encounter an unknown construct in a (new) language, it's up to you to visit the documentation first. This expansion test is very common in shell scripts.

Feel free to make a suggestion with a better formulation (preferbly inside the condition, i.e. from the perspective after the test succeeded).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to make a suggestion with a better formulation (preferbly inside the condition, i.e. from the perspective after the test succeeded).

Maybe a little bit simpler otherwise i would separate the variable or leave a small comment.

Suggested change
if test "${WORKFLOW#/workflows/}" = "$WORKFLOW"; then
if test "${WORKFLOW:0:11}" != "/workflow/"; then

IMO not only knowledge was required, you also had to think outside the box. I think code should be clearly visible without thinking outside the box. But I understand your points and I can also live with the current state.

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 don't know what you mean by thinking outside the box here. This substitution test is straightforward and very common (e.g. you can see tons of these tests in every autoconf script). Your offeset-length test would also work (with plural s), but is less idiomatic.

I just added a comment – happy now?

(You still need to unrequest changes, otherwise the PR is still blocked.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thx sorry for the circumstances 🤐

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
WORKFLOW=$(command -v "$WORKFLOW" || realpath "$WORKFLOW")
if ! test -f "$WORKFLOW"; then
logger -p user.error -t $TASK "invalid workflow '$WORKFLOW'"
exit 3
fi
logger -p user.notice -t $TASK "using workflow '$WORKFLOW':"
ocrd_format_workflow | logger -p user.notice -t $TASK
if test "${WORKFLOW#/workflows/}" = "$WORKFLOW"; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to make a suggestion with a better formulation (preferbly inside the condition, i.e. from the perspective after the test succeeded).

Maybe a little bit simpler otherwise i would separate the variable or leave a small comment.

Suggested change
if test "${WORKFLOW#/workflows/}" = "$WORKFLOW"; then
if test "${WORKFLOW:0:11}" != "/workflow/"; then

IMO not only knowledge was required, you also had to think outside the box. I think code should be clearly visible without thinking outside the box. But I understand your points and I can also live with the current state.

@markusweigelt markusweigelt merged commit 57e863f into main Apr 12, 2023
@markusweigelt markusweigelt deleted the workflow-volume branch April 12, 2023 18:56
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.

manage discrete repo of workflows, share as volume
2 participants