Repository: huggingface/text-generation-inference
Pull request: Fix typo and use POSIX comparison in the makefile
# What does this PR do?

This PR fixes:
- The usage of non posix comparison which may fail depending on the shell used (`=` will always work, `==` only with bash)
- Typo in the env variable name displayed in the error message `BUILD_EXTENSION` instead of `BUILD_EXTENSIONS`

<!-- Remove if not applicable -->

Fixes #422 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
      https://github.com/huggingface/text-generation-inference/issues/442
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @


@OlivierDehaene OR @Narsil

 -->
@OlivierDehaene

Problem statement:
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name'
### System Info
V100 double 32G，centos8
ghcr.io/huggingface/text-generation-inference:0.8  python 

### Information

- [X] Docker
- [ ] The CLI directly

### Tasks

- [X] An officially supported command
- [ ] My own modifications

### Reproduction

docker run --gpus all --shm-size 1g -p 8080:80 ghcr.io/huggingface/text-generation-inference:0.8 --model-id /data/bloom-560m --num-shard 2

2023-06-07T03:20:36.098949Z  INFO text_generation_launcher: Args { model_id: "/data/bloom-560m", revision: None, sharded: None, num_shard: Some(2), quantize: None, trust_remote_code: false, max_concurrent_requests: 128, max_best_of: 2, max_stop_sequences: 4, max_input_length: 1000, max_total_tokens: 1512, max_batch_size: None, waiting_served_ratio: 1.2, max_batch_total_tokens: 32000, max_waiting_tokens: 20, port: 80, shard_uds_path: "/tmp/text-generation-server", master_addr: "localhost", master_port: 29500, huggingface_hub_cache: Some("/data"), weights_cache_override: None, disable_custom_kernels: false, json_output: false, otlp_endpoint: None, cors_allow_origin: [], watermark_gamma: None, watermark_delta: None, env: false }
2023-06-07T03:20:36.098978Z  INFO text_generation_launcher: Sharding model on 2 processes
2023-06-07T03:20:36.099072Z  INFO text_generation_launcher: Starting download process.
2023-06-07T03:20:38.101003Z ERROR text_generation_launcher: Download encountered an error: Traceback (most recent call last):

  File "/opt/conda/bin/text-generation-server", line 8, in <module>
    sys.exit(app())

  File "/opt/conda/lib/python3.9/site-packages/text_generation_server/cli.py", line 96, in download_weights
    utils.weight_files(model_id, revision, extension)

  File "/opt/conda/lib/python3.9/site-packages/text_generation_server/utils/hub.py", line 92, in weight_files
    filenames = weight_hub_files(model_id, revision, extension)

  File "/opt/conda/lib/python3.9/site-packages/text_generation_server/utils/hub.py", line 25, in weight_hub_files
    info = api.model_info(model_id, revision=revision)

  File "/opt/conda/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 112, in _inner_fn
    validate_repo_id(arg_value)

  File "/opt/conda/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 160, in validate_repo_id
    raise HFValidationError(

huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/data/bloom-560m'. Use `repo_type` argument if needed.

### Expected behavior

docker run --gpus all --shm-size 1g -p 8080:80 ghcr.io/huggingface/text-generation-inference:0.8 --model-id /data/bloom-560m --num-shard 2

my model in local dir /data/bloom-560m,  system is centos8

Hints from issue discussion:
no docker, only run cli is ok， command is `text-generation-launcher --model-id /data/bloom-560m --num-shard 2 --port 8080`
please help me，i'm crazzy....emm
> please help me，i'm crazzy....emm

This is not a discussion forum.
`/data/xxx`  is a directory, you forgot to mount your drive on you docker run.

Commit message: Fix typo and use Posix comparison

Fixes #422

Patch to review:
diff --git a/Makefile b/Makefile
index c7f649ecf73..c3c849cf3c9 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ install-server:
 	cd server && make install
 
 install-custom-kernels:
-	if [ "$$BUILD_EXTENSIONS" == "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSION environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
+	if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
 
 install-integration-tests:
 	cd integration-tests && pip install -r requirements.txt


Code review comments:
diff_hunk: @@ -2,7 +2,7 @@ install-server:
 	cd server && make install
 
 install-custom-kernels:
-	if [ "$$BUILD_EXTENSIONS" == "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSION environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
+	if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
path: Makefile
text: @user1:
```suggestion
	if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need to set the BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
```

diff_hunk: @@ -2,7 +2,7 @@ install-server:
 	cd server && make install
 
 install-custom-kernels:
-	if [ "$$BUILD_EXTENSIONS" == "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSION environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
+	if [ "$$BUILD_EXTENSIONS" = "True" ]; then cd server/custom_kernels && python setup.py install; else echo "Custom kernels are disabled, you need set to BUILD_EXTENSIONS environment variable to 'True' in order to build them. (Please read the docs, kernels might not work on all hardware)"; fi
path: Makefile
text: @user1:
Is the `=` correct though ?

My bash foo is not great but: 
https://linuxhint.com/compare_strings_bash/

@author:
Yes `==` works only for bash, `=` works for everything that is following the posix standard (including bash)

```
╭─piratos@user2 ~ 
╰─$ bash -c '[ "True" = "True" ] && echo Yes'
Yes

╭─piratos@user2 ~ 
╰─$ bash -c '[ "True" == "True" ] && echo Yes'
Yes

╭─piratos@user2 ~ 
╰─$ sh -c '[ "True" == "True" ] && echo Yes'  
sh: 1: [: True: unexpected operator

╭─piratos@user2 ~ 
╰─$ sh -c '[ "True" = "True" ] && echo Yes'
Yes
```