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

WIP: try fixing actions #17

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,33 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: mypy-check
uses: theCapypara/mypy-check@master
uses: jpetrucciani/mypy-check@master
with:
path: ""
requirements: types-toml
mypy_flags: "-p celestial --config setup.cfg"
- name: mypy-check2
uses: theCapypara/mypy-check@master
with:
requirements: types-toml numpy types-request mypy-protobuf
requirements: "types-toml numpy types-requests mypy-protobuf"
path: "*.py"
mypy_flags: "--config setup.cfg"

go:
name: go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: --out-format=colored-line-number

markdown:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: markdownlint-cli
uses: nosborn/[email protected]
with:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
name: goreleaser

on:
pull_request:
push:
tags:
- "*"
Expand All @@ -28,13 +27,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: '1.21'
cache: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
Expand Down
8 changes: 7 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
#

builds:
- skip: true
- id: "celestial.bin"
main: ./celestial.go
binary: celestial.bin
goos:
- linux
goarch:
- amd64
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"go.toolsEnvVars": {
"GOOS": "linux",
"GOARCH": "amd64"
}
},
"mypy.runUsingActiveInterpreter": true
}
12 changes: 6 additions & 6 deletions celestial.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ def get_diff(
) -> typing.List[proto.celestial.celestial_pb2.StateUpdateRequest]:
# we get iterators of the deserialized diffs
t1 = time.perf_counter()
l = [
s = [
*celestial.proto_util.make_update_request_iter(
serializer.diff_machines(t), serializer.diff_links(t)
)
]

logging.debug(f"diffs took {time.perf_counter() - t1} seconds")

return l
return s

# start the simulation
timestep: celestial.types.timestamp_s = 0
Expand All @@ -171,9 +171,9 @@ def get_diff(
logging.info(f"Updating for timestep {timestep}")

with concurrent.futures.ThreadPoolExecutor() as e:
for h in range(len(hosts)):
for i in range(len(hosts)):
# need to make some generators
e.submit(hosts[h].update, (u for u in updates))
e.submit(hosts[i].update, (u for u in updates))

timestep += config.resolution

Expand All @@ -194,8 +194,8 @@ def get_diff(
finally:
logging.info("got keyboard interrupt, stopping...")
with concurrent.futures.ThreadPoolExecutor() as e:
for h in range(len(hosts)):
for i in range(len(hosts)):
# need to make some generators
e.submit(hosts[h].stop)
e.submit(hosts[i].stop)

logging.info("finished")
4 changes: 3 additions & 1 deletion celestial/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def register(self) -> proto.celestial.celestial_pb2.RegisterResponse:
"""
request = proto.celestial.celestial_pb2.RegisterRequest(host=self.num)

response = self.stub.Register(request)
response: proto.celestial.celestial_pb2.RegisterResponse = self.stub.Register(
request
)

# others currently not used
self.peer_public_key = response.peer_public_key
Expand Down
63 changes: 34 additions & 29 deletions celestial/proto_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
MAX_DIFF_UPDATE_SIZE = 100_000


def _machineID_group(m: celestial.types.MachineID_dtype) -> int:
return typing.cast(int, celestial.types.MachineID_group(m))


def _machineID_id(m: celestial.types.MachineID_dtype) -> int:
return typing.cast(int, celestial.types.MachineID_id(m))


def make_init_request(
hosts: typing.List[celestial.host.Host],
machines: typing.Dict[
Expand All @@ -53,8 +61,8 @@ def make_init_request(

for m in machines[h.num]:
mid = proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(m[0]),
id=celestial.types.MachineID_id(m[0]),
group=_machineID_group(m[0]),
id=_machineID_id(m[0]),
)

mc = proto.celestial.celestial_pb2.InitRequest.Machine.MachineConfig(
Expand All @@ -66,19 +74,22 @@ def make_init_request(
boot_parameters=m[1].boot_parameters,
)

m = proto.celestial.celestial_pb2.InitRequest.Machine(
r = proto.celestial.celestial_pb2.InitRequest.Machine(
id=mid,
config=mc,
host=h.num,
name=celestial.types.MachineID_name(m[0]),
)

init_request.machines.append(m)
init_request.machines.append(r)

return init_request


def _islice(iterable: typing.Iterator, n: int) -> typing.Iterator:
T = typing.TypeVar("T")


def _islice(iterable: typing.Iterator[T], n: int) -> typing.Iterator[T]:
count = 0

for i in iterable:
Expand Down Expand Up @@ -114,8 +125,8 @@ def make_update_request_iter(
machine_diffs=[
proto.celestial.celestial_pb2.StateUpdateRequest.MachineDiff(
id=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(m_id),
id=celestial.types.MachineID_id(m_id),
group=_machineID_group(m_id),
id=_machineID_id(m_id),
),
active=proto.celestial.celestial_pb2.VM_STATE_STOPPED
if m_state == celestial.types.VMState.STOPPED
Expand All @@ -131,42 +142,36 @@ def make_update_request_iter(
network_diffs=[
proto.celestial.celestial_pb2.StateUpdateRequest.NetworkDiff(
source=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(source),
id=celestial.types.MachineID_id(source),
group=_machineID_group(source),
id=_machineID_id(source),
),
target=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(target),
id=celestial.types.MachineID_id(target),
group=_machineID_group(target),
id=_machineID_id(target),
),
latency=typing.cast(int, celestial.types.Link_latency_us(link)),
bandwidth=typing.cast(
int, celestial.types.Link_bandwidth_kbits(link)
),
latency=celestial.types.Link_latency_us(link),
bandwidth=celestial.types.Link_bandwidth_kbits(link),
blocked=False,
next=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(
celestial.types.Link_next_hop(link)
),
id=celestial.types.MachineID_id(
celestial.types.Link_next_hop(link)
),
group=_machineID_group(celestial.types.Link_next_hop(link)),
id=_machineID_id(celestial.types.Link_next_hop(link)),
),
prev=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(
celestial.types.Link_prev_hop(link)
),
id=celestial.types.MachineID_id(
celestial.types.Link_prev_hop(link)
),
group=_machineID_group(celestial.types.Link_prev_hop(link)),
id=_machineID_id(celestial.types.Link_prev_hop(link)),
),
)
if not celestial.types.Link_blocked(link)
else proto.celestial.celestial_pb2.StateUpdateRequest.NetworkDiff(
source=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(source),
id=celestial.types.MachineID_id(source),
group=_machineID_group(source),
id=_machineID_id(source),
),
target=proto.celestial.celestial_pb2.MachineID(
group=celestial.types.MachineID_group(target),
id=celestial.types.MachineID_id(target),
group=_machineID_group(target),
id=_machineID_id(target),
),
blocked=True,
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion celestial/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _init_ground_stations(
)
init_pos[2] = (EARTH_RADIUS_M + 100.0) * math.sin(latitude)

temp: npt.NDArray[GROUNDPOINT_DTYPE] = np.zeros(1, dtype=GROUNDPOINT_DTYPE)
temp: npt.NDArray = np.zeros(1, dtype=GROUNDPOINT_DTYPE) # type: ignore

temp[0]["ID"] = np.int16(-i - 1)

Expand Down
2 changes: 2 additions & 0 deletions pkg/ebpfem/ebpfem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestBasic(t *testing.T) {

if _, err := cmd.CombinedOutput(); err != nil {
// ignore
log.Debugf("could not delete tap %s: %s", tap, err)
}

// iptables -D FORWARD -i [TAP_NAME] -o [HOSTINTERFACE] -j ACCEPT
Expand All @@ -73,6 +74,7 @@ func TestBasic(t *testing.T) {

if _, err := cmd.CombinedOutput(); err != nil {
// ignore
log.Debugf("could not delete iptables rule: %s", err)
}

// create a tap device
Expand Down
4 changes: 4 additions & 0 deletions pkg/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ func (p *PeeringService) InitPeering(remotes map[orchestrator.Host]HostInfo) err

portNum, err := strconv.ParseUint(port, 10, 16)

if err != nil {
return errors.WithStack(err)
}

r := &peer{
directAddr: net.ParseIP(addr),
wgAddr: remoteWgAddr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (m *machine) initialize() error {
return errors.WithStack(err)
}

loglevel := "ERROR"
var loglevel string

// unfortunately Firecracker is incredibly verbose
switch log.GetLevel() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func removeNetworkDevice(tapName string, hostInterface string) error {
}

// createNetworkDevice creates a new network device for a microVM.
func createNetworkDevice(gateway net.IPNet, tapName string, hostInterface string) error {
func createNetworkDevice(gateway net.IPNet, tapName string, _ string) error {

// ip tuntap add [TAP_NAME] mode tap

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cerberus==1.3.5
grpcio==1.59.0
grpcio-tools==1.59.0
llvmlite==0.41.1
mypy==1.6.1
mypy==1.9.0
mypy-protobuf==3.5.0
numba==0.58.1
numpy==1.26.1
Expand Down
6 changes: 4 additions & 2 deletions satgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

import celestial.config
import celestial.zip_serializer
import celestial.satgen
import celestial.satgen_connstellation

if __name__ == "__main__":
if len(sys.argv) > 3 or len(sys.argv) < 2:
Expand All @@ -77,7 +77,9 @@
serializer = celestial.zip_serializer.ZipSerializer(config, output_file)

# init the constellation
constellation = celestial.satgen.SatgenConstellation(config, serializer)
constellation = celestial.satgen_connstellation.SatgenConstellation(
config, serializer
)

# run the simulation
i = 0
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
python_version = 3.11
warn_unused_configs = True
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_return_any = True
no_implicit_reexport = True
strict_equality = True
ignore_missing_imports = True
show_column_numbers = True
follow_imports = skip
plugins = numpy.typing.mypy_plugin