arr-ai / arrai

The ultimate data engine.
http://arr.ai
Apache License 2.0
20 stars 15 forks source link

Support versioned imports #534

Closed andrewemeryanz closed 4 years ago

andrewemeryanz commented 4 years ago

Purpose

arr.ai imports are currently unversioned:

// file: service.arrai
let service = //{github.com/anz-bank/sysl-go/codegen/arrai/service.arrai};

The current behaviour is to always retrieve the latest repository version:

$ arrai service.arrai

Imports should be versionable:

// file: service.arrai
let service = //{github.com/anz-bank/sysl-go/codegen/arrai/service.arrai} @v0.123.0;

References

https://github.com/arr-ai/arrai/issues/504

marcelocantos commented 4 years ago

Versioning is currently via go.mod, which controls versioning at the module level. There might be a case for per-import versioning, though that's a significant impact to our current approach. @ChloePlanet

andrewemeryanz commented 4 years ago

Versioning is currently via go.mod

What's the right setup to get this behaviour? Given the following files:

go.mod           # containing sysl-go v0.72.0 (a couple of versions behind the latest)
service.arrai

If I run arrai service.arrai then go.mod gets bumped up to sysl-go v0.74.0 (the latest version).

--

Version    : DIRTY-v0.109.0
Git commit : 50b6ba3e1789cec84acb8625364dd3bd24b8a18b
Date       : 2020-08-04T01:01:45Z
OS/arch    : darwin/amd64
Go version : go1.14.1 darwin/amd64
marcelocantos commented 4 years ago

That might be a design bug. Running the code shouldn't update version information in go.mod. It might be doing that as a side effect of automatically filling in any missing dependencies. If so, we should remove the automatic update, which would be a slight inconvenience, but safer.

ChloePlanet commented 4 years ago

Yes the dependent packages should not be updated. Will fix that. In terms of support importing specified version, I could turn to it after the current ticket is done.

andrewemeryanz commented 4 years ago

Thanks @ChloePlanet. What is the behaviour of import versioning? Does arrai need a go.mod file if it's using module imports or does it fetch the latest if one can't be found? Where does it look for go.mod?

ChloePlanet commented 4 years ago

arrai is using the same dependency management strategy as sysl which is based on go modules (go mod). It checks the modules listed in go.mod first and go get it if it's not downloaded yet.

So for this issue, did you raise it because arrai packages automatically update the package and you want to disable it, or just want to import an old version of a package?

andrewemeryanz commented 4 years ago

Had a chat with @ChloePlanet. Answering some questions here.

So for this issue, did you raise it because arrai packages automatically update the package and you want to disable it, or just want to import an old version of a package?

I want to import the version listed in the go.mod file (and I don't want the go.mod file to be changed as a result of execution).

Does arrai need a go.mod file if it's using module imports or does it fetch the latest if one can't be found?

It needs a go.mod file and will error out if one isn't found.

Where does it look for go.mod?

In the current working directory.

ChloePlanet commented 4 years ago

The automatic update is removed by #544.

andrewemeryanz commented 4 years ago

@ChloePlanet I'm still seeing the behaviour where the version in the go.mod file is updated to the latest version when using arrai v0.112.0.