Skip to content

Commit 5b9660f

Browse files
authored
Document ZENML_ACTIVE_PROJECT_ID environment variable (#3992)
* Update documentation for environment variable usage This commit enhances the documentation by clarifying the usage of the `ZENML_ACTIVE_PROJECT_ID` environment variable in the context of client configuration. It ensures users understand how to set their active project and the default project configuration effectively. Additionally, it improves the formatting and consistency of the environment variable examples across the documentation. * Add 403 exception handling for HF token link
1 parent 9c8fd37 commit 5b9660f

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

docs/book/getting-started/zenml-pro/projects.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ This command sets the "default" project as your active project. All subsequent Z
4545
Best practice is to set your active project right after running `zenml init`, just like you would set an active stack. This ensures all your resources are properly organized within the project.
4646
{% endhint %}
4747

48+
You can also set the project to be used by your client via an environment variable:
49+
50+
```bash
51+
export ZENML_ACTIVE_PROJECT_ID=<PROJECT_ID>
52+
```
53+
4854
### Setting a default project
4955

5056
The default project is something that each user can configure. This project will be automatically set as the active project when you connect your local Python client to a ZenML Pro workspace.

docs/book/reference/environment-variables.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ For more information on server configuration, see the [ZenML Server documentatio
135135

136136
## Client configuration
137137

138-
Setting the `ZENML_STORE_URL` and `ZENML_STORE_API_KEY` environment variables automatically connects your ZenML Client to the specified server. This method is particularly useful when you are using the ZenML client in an automated CI/CD workload environment like GitHub Actions or GitLab CI or in a containerized environment like Docker or Kubernetes:
138+
Setting the `ZENML_STORE_URL`, `ZENML_STORE_API_KEY` and `ZENML_ACTIVE_PROJECT_ID` environment variables automatically connects your ZenML Client to the specified server for a specific project. This method is particularly useful when you are using the ZenML client in an automated CI/CD workload environment like GitHub Actions or GitLab CI or in a containerized environment like Docker or Kubernetes:
139139

140140
```bash
141141
export ZENML_STORE_URL=https://...
142142
export ZENML_STORE_API_KEY=<API_KEY>
143+
export ZENML_ACTIVE_PROJECT_ID=<PROJECT_ID>
143144
```
144145

145146
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>

docs/link_checker.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@
7979
except ImportError:
8080
HAS_REQUESTS = False
8181

82+
# ------------------------------------------------------------------------------
83+
# Centralized exceptions for HTTP status codes we consider acceptable for
84+
# specific URLs or domains during link validation.
85+
#
86+
# How to extend:
87+
# - To allow particular statuses for a *single* URL, add an entry to
88+
# EXEMPT_URL_STATUS with the normalized URL (no trailing slash) and a set
89+
# of allowed status codes.
90+
# - To allow particular statuses for an entire *domain*, add an entry to
91+
# EXEMPT_DOMAIN_STATUS with the domain suffix (e.g. "example.com") and a
92+
# set of allowed status codes. Matching uses host.endswith(domain).
93+
# ------------------------------------------------------------------------------
94+
95+
EXEMPT_URL_STATUS: Dict[str, set] = {
96+
# Requires authentication; often returns 403 to unauthenticated HEAD/GET.
97+
"https://huggingface.co/settings/tokens": {403},
98+
}
99+
100+
EXEMPT_DOMAIN_STATUS: Dict[str, set] = {
101+
# Some HashiCorp properties rate-limit automated checks.
102+
"hashicorp.com": {429},
103+
"developer.hashicorp.com": {429},
104+
"terraform.io": {429},
105+
"www.terraform.io": {429},
106+
}
107+
82108
# Default policies for troublesome domains that frequently rate-limit automated traffic.
83109
# These defaults can be extended via CLI flags.
84110
DEFAULT_IGNORE_429_DOMAINS = {
@@ -96,6 +122,37 @@
96122
)
97123

98124

125+
def is_exception_status(cleaned_url: str, status_code: int) -> bool:
126+
"""
127+
Return True if (cleaned_url, status_code) should be treated as valid based
128+
on configured exemptions.
129+
130+
Rules:
131+
- Exact-URL exemptions: compared after stripping any trailing slash.
132+
- Domain exemptions: suffix match against the URL hostname.
133+
"""
134+
if not cleaned_url.startswith(("http://", "https://")):
135+
return False
136+
137+
# Exact URL exemptions (normalize by removing trailing slash)
138+
normalized = cleaned_url.rstrip("/")
139+
allowed = EXEMPT_URL_STATUS.get(normalized)
140+
if allowed and status_code in allowed:
141+
return True
142+
143+
# Domain exemptions
144+
try:
145+
host = urlparse(cleaned_url).hostname or ""
146+
except Exception:
147+
host = ""
148+
149+
for domain, codes in EXEMPT_DOMAIN_STATUS.items():
150+
if host.endswith(domain) and status_code in codes:
151+
return True
152+
153+
return False
154+
155+
99156
def find_markdown_files(directory: str) -> List[str]:
100157
"""Find all markdown files in the given directory and its subdirectories."""
101158
markdown_files = []
@@ -334,7 +391,11 @@ def check_link_validity(
334391
cleaned_url, timeout=timeout, allow_redirects=True
335392
)
336393

337-
# Soft-pass 429 for configured domains
394+
# Check configured exception rules (domain- and URL-specific)
395+
if is_exception_status(cleaned_url, response.status_code):
396+
return (url, True, None, response.status_code)
397+
398+
# Also check for 429 soft-pass for configured domains (backward compatibility)
338399
if response.status_code == 429 and ignore_429:
339400
return (
340401
url,

0 commit comments

Comments
 (0)