Skip to content

Commit 8b522b5

Browse files
authored
Merge pull request #5764 from opsmill/stable
Merge stable into develop
2 parents 0da3a07 + ca89edc commit 8b522b5

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

development/docker-compose.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@ services:
116116
target: backend
117117
image: "${IMAGE_NAME}:${IMAGE_VER}"
118118
pull_policy: always
119-
command: >
120-
gunicorn --config backend/infrahub/serve/gunicorn_config.py -w ${WEB_CONCURRENCY:-4} --logger-class infrahub.serve.log.GunicornLogger infrahub.server:app
121-
depends_on:
122-
database:
123-
condition: service_healthy
124-
message-queue:
125-
condition: service_healthy
126-
cache:
127-
condition: service_healthy
128-
task-manager:
129-
condition: service_healthy
130119
environment:
131120
<<: *infrahub_config
132121
INFRAHUB_INTERNAL_ADDRESS: "http://server:8000"
@@ -145,6 +134,19 @@ services:
145134
INFRAHUB_DB_PORT: 7687
146135
INFRAHUB_DB_PROTOCOL: bolt
147136
INFRAHUB_STORAGE_DRIVER: local
137+
# INFRAHUB_SERVER_COMMAND is defined while running with reload option as it requires to run server using `uvicorn`.
138+
COMMAND: ${INFRAHUB_SERVER_COMMAND:- gunicorn --config backend/infrahub/serve/gunicorn_config.py -w ${WEB_CONCURRENCY:-4} --logger-class infrahub.serve.log.GunicornLogger infrahub.server:app}
139+
command: >
140+
sh -c "$$COMMAND"
141+
depends_on:
142+
database:
143+
condition: service_healthy
144+
message-queue:
145+
condition: service_healthy
146+
cache:
147+
condition: service_healthy
148+
task-manager:
149+
condition: service_healthy
148150
volumes:
149151
- "storage_data:/opt/infrahub/storage"
150152
tty: true

docs/docs/topics/schema.mdx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,28 @@ To help with the development process of a schema definition file, you can levera
2525

2626
## Schema definition
2727

28-
### Namespace, Node, Attributes, Relationships, and Generics
28+
### Node, Attributes, Relationships, and Generics
2929

3030
The schema is composed of 4 primary types of objects: `Nodes`- that are themselves composed of `Attributes` and `Relationships` and finally `Generics`.
3131

32-
- A `Node` in Infrahub represents a `Model`.
32+
- A `Node` in Infrahub represents a `Model`. Nodes are instances of a specific object within your infrastructure. Nodes have attributes that define specific values, such as text or numbers, and relationships that link them to other nodes.
3333
- An `Attribute` represents a direct value associated with a `Node` like a `Text`, a `Number` etc ...
3434
- A `Relationship` represents a link between 2 `Node`, a `Relationship` can be of cardinality `one` or `many`.
35-
- A `Generic` can be used to share some attributes between multiple `Node`, if you're familiar with programming concept, it's close to class inheritance.
35+
- A `Generic` can be used to share attributes and relationships between different types of `Node`s. They can connect multiple types of nodes to the same relationship or define attributes and relationships on a specific list of nodes. Generics are similar to class inheritance in programming languages like Java or Python.
36+
37+
### Nodes vs. Generics
38+
39+
Use a `Node` when you need to represent a concrete object in your infrastructure model with specific attributes and relationships.
40+
41+
Use a `Generic` when you want to share common attributes or relationships across multiple node types. This helps to avoid redundancy and ensures consistency across your schema. For example, if you have different types of network interfaces (physical, logical) that share common attributes like name and description, you can define a `Generic` interface with these attributes and have the specific interface types inherit from it.
42+
43+
`Generic`s can also be used to connect multiple types of Nodes to the same relationship.
44+
45+
When deciding between a `Node` and `Generic`, remember that computed attributes can only be used on `Nodes`, not `Generics`.
46+
47+
If a `Generic`'s properties are updated after the `Node` has been created, these updates will not be propagated to the `Node`; users must manually update `Nodes` if they want to reflect changes made to `Generic`s. See [Inherited properties](#inherited-properties) for more information.
48+
49+
### Node example
3650

3751
In the example below, the node `Person` has 2 attributes (`name` and `description`) and the node `Car` has 1 attribute (`model`) and 1 relationship to `Person`, identified by `owner`.
3852

tasks/dev.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
from typing import TYPE_CHECKING
45

56
from invoke.tasks import task
@@ -172,8 +173,16 @@ def status(
172173

173174

174175
@task(optional=["database"])
175-
def start(context: Context, database: str = INFRAHUB_DATABASE, wait: bool = False) -> None:
176+
def start(context: Context, database: str = INFRAHUB_DATABASE, wait: bool = False, reload: bool = False) -> None:
176177
"""Start a local instance of Infrahub within docker compose."""
178+
179+
if reload:
180+
# Need to use `uvicorn` instead of `gunicorn` for reload option because of this issue:
181+
# https://github.com/benoitc/gunicorn/issues/2339
182+
os.environ["INFRAHUB_SERVER_COMMAND"] = (
183+
"uvicorn infrahub.server:app --host 0.0.0.0 --port 8000 --workers 4 --timeout-keep-alive 90 --reload"
184+
)
185+
177186
start_services(context=context, database=database, namespace=NAMESPACE, wait=wait)
178187

179188

0 commit comments

Comments
 (0)