Commit graph

433 commits

Author SHA1 Message Date
Komal 7f226c1cb6
Fix serializing bug if output contains 'items' property (#6705) 2021-04-05 20:36:56 -07:00
Komal 5254e3f01d
[python/sdk] - Fix serialization bug if output contains 'items' property (#6701) 2021-04-05 12:39:56 -07:00
Pat Gavlin 55ecf7a81e
Run SDK lint jobs (#6674)
Just what it says on the tin. Fixes #6628.
2021-04-01 11:23:47 -07:00
Komal 55a0c1fc8e
[automation/go,nodejs,python] - Don't roundtrip project settings if file already exists. (#6669) 2021-03-31 11:00:11 -07:00
Komal 7671e85440
[automation/go,nodejs,python] - Respect existing project settings (#6655) 2021-03-31 07:51:11 -07:00
Komal 7d10e8c5be
Fix mypy errors (#6656) 2021-03-30 19:11:13 -07:00
Komal 35321159fc
[sdk/python] - Await all async tasks (#6606) 2021-03-30 10:56:17 -07:00
Pat Gavlin 7c5ec6815e
Make data sources catchable in Python (#6504)
The current logic lets unhandled errors in the RPC invocation
unahandled in the async loop, which crashes the process due to
the way we await completion of RPCs before exiting the process
in Python. Instead of doing that, we can just marshal them back
to the synchronous awaiter as part of the calling convention,
and have that awaiter (which is called by the invoke methods)
re-raise the exception. This should fix pulumi/pulumi#3611.
2021-03-29 12:07:43 -07:00
Komal e5223492c7
[automation/python] - Fix passing of extra environment variables (#6639) 2021-03-29 11:48:17 -07:00
Justin Van Patten 872d9cb849
[sdk/python] Fix mypy errors (#6627) 2021-03-26 15:41:08 -07:00
Komal 60cc4be9d3
[automation/*] - Add min version test for prerelease (#6612) 2021-03-24 14:00:33 -07:00
Anton Tayanovskyy 4e5828a890
Avoid double-quailfying venv folder path (#6599)
* Avoid double-quailfying venv folder path

* Replace `path` with `filepath`

* Add a Python integration test to cover venv auto-creation

* Merged

* Fix spelling

Co-authored-by: Justin Van Patten <jvp@justinvp.com>

* Make AbsPath and RelPath test variants

* Fix issue on Windows backslash paths

* Debug windows test failure: more logging and aggressive YAML escaping

* Use filepath.IsAbs instead of path.IsAbs

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-03-24 15:51:46 -04:00
Levi Blackstone 7f42d42b2b
[automation/python] Fix Settings file save (#6605)
The Project and Stack save routines were erroneously
dumping the Python objects rather than the __dict__
property, which resulted in some extra annotations
in the resulting YAML files. Some parsers don't handle
these annotations correctly, and consider the resulting
YAML file to be invalid.
2021-03-23 19:26:34 -06:00
Komal 5e5c6ffb50
[automation/nodejs,go,python] - Expose pulumiVersion as string (#6604) 2021-03-23 15:09:50 -07:00
Komal b187ce18c2
[automation/python] - Implement min version checking (#6589) 2021-03-23 08:35:11 -07:00
Anton Tayanovskyy 22f332e094
Fix docstring on node log.error and other SDK equivalents (#6573)
* Fix docstring of log.error across SDKs to explain non-termination

* Accept PR feedback, briefer docstrings.
2021-03-18 13:57:10 -04:00
Paul Stack 1d3c9edb6c
Ensure that make brew works as expected rather than passing empty version (#6566)
Fixes:#6565

As part of #6460, the logic for determing the version of the build was
moved to be a dependency on pulumictl.

Unfortunately, the homebrew installs use the "make dist" command to
build + install Pulumi to the user maching and as that would have a
dependency on pulumictl and it not existing on the user machine, it
would pass an empty version to the ldflag

This then manifested to the user as:

```
▶ pulumi version
warning: A new version of Pulumi is available. To upgrade from version '0.0.0' to '2.22.0', run
   $ brew upgrade pulumi
or visit https://pulumi.com/docs/reference/install/ for manual instructions and release notes.
```

We are able to mitigate this behaviour by bringing back the get-version
script and using that script as part of the make brew installation

We can see that the versions are the same between the 2 different
installation techniques

```
make dist <------- uses pulumict
DIST:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=2.24.0-alpha.1616029310+787eb70a" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
DIST:
BUILD:
```

```
make brew <----- uses the legacy script
▶ make brew
BREW:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=v2.24.0-alpha.1616029310+g787eb70a2" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
BREW:
```

A full post mortem will be carried out to ensure we mitigate these
types of errors going forward and that we are able to better test
these types of situations
2021-03-18 02:07:02 +00:00
Ville Penttinen 66f5d50a50
[automation/dotnet,nodejs,python] Specify exec-kind for refresh & destroy (#6530)
dotnet, nodejs and python automation APIs did not specify exec-kind for
refresh or destroy operations. This is now added following the same
logic from the go automation API.
2021-03-16 14:24:32 -07:00
Paul Stack c48ba37fcf
Migrate the version calculation to use pulumictl (#6460) 2021-03-10 19:03:29 +00:00
Meno Abels fad0393288
[sdk/python] mypy was not found (#6478) 2021-03-09 15:02:27 -08:00
Justin Van Patten 0b1414dc6d
[sdk/python] Fix mocks issue when passing a resource more than once (#6479)
This change avoids `RuntimeError: There is no current event loop in thread '<thread_name>'` errors when passing a resource as an input multiple times when using mocks.

The problem is that when using mocks, we deserialize the gRPC inputs before passing them to the user's mock methods. Deserializing inputs doesn't typically require an event loop, however, during deserialization of resource references, we end up creating some instances of `Future`, which does require an event loop to be present for the current thread. If this is done multiple times for a resource, it's possible that `deserialize_properties` will be called on an asyncio thread that doesn't yet have an event loop, resulting in the error being raised.

The error does not occur when only passing the resource reference once because typically the thread (e.g. `asyncio_0`) used in that case will have already had an event loop created for it due to the use of the internal `_syncawait` when _serializing_ the source resource's properties, which ensures an event loop is set for the thread.

The fix is to ensure an event loop is created for the thread in the mocks implementation before calling `deserialize_properties`.
2021-03-09 13:48:24 -08:00
Paul Stack 20e84dfe9e
Upgrading Go to 1.16.x (#6470) 2021-03-09 20:05:23 +00:00
Komal 48bc267445
[automation/python] - Add missing options to preview and up (#6450) 2021-03-02 10:53:39 -08:00
Komal 4a59900920
Enable python automation API tests on Windows (#6424) 2021-02-24 17:28:23 -08:00
Komal 24e07ab507
[automation/python] - Use TemporaryFile and seek() (#6421) 2021-02-24 17:21:24 -08:00
Mike Chen 256e8284d0
[automation] - Add diff to up and preview in automation API (#6413)
Co-authored-by: Mike Chen <mikechen@ip-192-168-1-8.ec2.internal>
2021-02-23 17:38:28 -08:00
Komal 8b665f7131
[automation] - Remove summary from PreviewResult (#6405) 2021-02-23 17:07:16 -08:00
Komal 5f4e687a1d
[automation] - Consume config set-all and rm-all commands (#6388) 2021-02-19 22:59:18 -08:00
Komal ca5ab18f6d
[sdk/python] - Allow Output.all with no inputs (#6381) 2021-02-18 10:11:13 -08:00
Komal a6b6437b49
[Automation] Fix python nested config parsing (#6349) 2021-02-17 10:16:35 -08:00
Komal b6f548a599
[sdk/python] - Define __all__ for better autocomplete. (#6351) 2021-02-17 09:09:10 -08:00
Justin Van Patten f111a53337
Look for python binary first on Windows (#6317)
We previously looked for `python3` and fallback to `python` on all systems. However, our Windows CI images include a `python3.exe` symlink to `python.exe` which does not work with `venv`. So on Windows, just look for `python` first, falling back to `python3`. (The default python.org Windows installation only includes `python.exe`).
2021-02-11 11:34:07 -08:00
Komal 1a9050eaa6
[sdk/python] - Allow kwargs in Output.all() to create a dict (#6269) 2021-02-11 08:52:46 -07:00
Evan Boyle 8e58f5d682
Add pagination to pulumi stack history (#6292)
replaces the unreleased `--limit` flag with `--page` and `--page-size` to support full pagination
2021-02-09 16:20:01 -08:00
Evan Boyle eefc104c2b
Add --limit flag to pulumi stack history and consume from automation api (#6257)
Adds a `--limit` flag to `pulumi stack history. This allows limiting to the last few entries rather than fetching the entirety of a stack's update history (which can be quite slow for stacks with lots of updates). Example: `pulumi stack history --limit 1` fetches the last history entry only. 

`stack.up` and related operations in the Automation API have been updated to consume this change, drastically reducing overhead.
2021-02-08 10:49:57 -08:00
Komal f374b8a953
[python/sdk] - Correctly handle outputs with properties named "values" (#6264)
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2021-02-05 17:16:13 -07:00
Komal 3a3b96de72
[sdk/python] - Gracefully handle monitor shutdown (#6249) 2021-02-04 20:28:39 -07:00
Justin Van Patten 2779de38ea
[sdk/python] from_input: Unwrap nested outputs in input types (#6221)
`Output.from_input` deeply unwraps nested output values in dicts and lists, but doesn't currently do that for the more recently added "input types" (i.e. args classes). This leads to errors when using args classes with output values with `Provider` resources, which uses `Output.from_input` on each input property and then serializes the value to JSON in an `apply`. This changes fixes `Output.from_input` to recurse into values within args classes to properly unwrap any nested outputs.
2021-01-29 15:44:00 -08:00
Komal 216fd2bed5
Fix the rendering of ResourceOptions.merge (#6206) 2021-01-26 15:44:12 -07:00
Komal 0f06e03931
Docstring fixups (#6194) 2021-01-25 12:22:17 -07:00
Komal 51521bbe73
Improve automation-api docs (#6178) 2021-01-22 15:12:41 -07:00
Vivek Lakshmanan 68b655bba6 Test fixes for other languages due to change in schema. 2021-01-20 11:29:01 -08:00
Paul Stack 1cff1a4bcf
[sdk/python] Adding pulumi.unsecret and pulumi.is_secret (#6111) 2021-01-14 20:37:05 +00:00
Komal dd66d8d2ab
Remove annotations import (#6109) 2021-01-14 12:36:11 -08:00
Komal 89b1d0d2c7
[automation-api/python] - Support recovery workflow (#6037) 2021-01-12 19:27:21 -08:00
Komal 059402483b
[Automation API] Python Implementation (#5979)
Co-authored-by: evanboyle <evan@pulumi.com>
2021-01-12 16:55:59 -08:00
Komal ae7d95eb87
[sdk/python] - Don't log if debug and no engine (#6067) 2021-01-07 15:23:23 -08:00
Komal d0676c19a3
Fix virtual env path (#5992) 2020-12-21 17:46:56 -08:00
Pat Gavlin 268e50d00e
Add Python resource ref unit tests. (#5982)
- Improve the existing coverage to use real resources and mocks
- Add tests for deserialization as well as serialization
- Add tests that serialize custom resources during preview

Contributes to #5943.
2020-12-18 23:02:48 -08:00
Pat Gavlin 8e278ca9d3
Improve Python serialization test harness. (#5977)
- Reset the runtime prior to each test
- Use the SDK's `test` decorator instead of `async_test`
- Rename a couple classes to avoid warnings from pytest
2020-12-17 14:45:18 -08:00
Justin Van Patten afd5ad6a97
[sdk/python] Implement getResource in the mock monitor (#5919) 2020-12-10 15:23:00 -08:00
Levi Blackstone 4d48ee0517
Enable resource reference feature by default (#5905)
* Enable resource reference feature by default

Unless the PULUMI_DISABLE_RESOURCE_REFERENCES flag
is explicitly set to a truthy value, the resource reference feature is now
enabled by default.

* Set AcceptResources in the language SDKs

This can be disabled by setting the `PULUMI_DISABLE_RESOURCE_REFERENCES` environment variable to a truthy value.

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2020-12-10 11:21:05 -07:00
Vivek Lakshmanan 3ec7dbeded Fix windows build 2020-12-07 15:58:30 -08:00
Vivek Lakshmanan 3ea87776a0 Add copyright notice 2020-12-07 14:17:45 -08:00
Vivek Lakshmanan ed0d427958 Add a python shim script to work around https://github.com/golang/go/issues/42919 2020-12-07 14:17:45 -08:00
Vivek Lakshmanan 0aa4ba4d44 Check for python among execution aliases on Windows 2020-12-07 14:17:38 -08:00
Vivek Lakshmanan 3377978a1d Use os.Lstat instead of os.Stat 2020-12-06 22:49:25 -08:00
Justin Van Patten 5ab051cd97
Implement GetRequiredPlugins for Python (#5787)
Implement GetRequiredPlugins for Python, which determines the plugins
required by the program.

Also, if the `virtualenv` runtime option is set, and the specified
virtual directory is missing or empty, automatically create it and
install dependencies into it.
2020-12-03 19:22:16 -08:00
Justin Van Patten edc79325fe
Add support for getResource to Node.js SDK (#5837)
And update Node's resource ref deserialization to match Python.

Also, fixed a bug in Python resource ref deserialization that I noticed.
2020-12-01 10:58:15 -08:00
Komal 48f43906f4
[sdk/python] - Support enums (#5615)
Co-authored-by: Pat Gavlin <pat@pulumi.com>
2020-11-24 19:15:11 -06:00
Pat Gavlin ef6da5709d
Update Python resource ref deserialization. (#5805)
There are two significant changes in this commit: one to the way
resource packages/modules are stored and retrieved, and one to resource
ref deserialization in the face of missing resource packages/modules.

Resource packages and modules no longer require an exact version match
during deserialization. Instead, the newest compatible version of the
package or module is selected. If no version was specified, the newest
version of the package or module will be chosen. As a special case, a
package or module that has no version will always be treated as the best
version for that package or module.

If a resource package or module is not found when attempting to
deserialize a resource reference, the SDK no longer emits an error, and
instead deserializes the reference as its URN or ID (if present). This
accommodates providers that have not yet been updated to include the
appropriate factory registrations.
2020-11-23 15:37:44 -08:00
Pat Gavlin 807b09d6a6
Fix a few issues with resource references. (#5804)
- Differentiate between resource references that have no ID (i.e. because
  the referenced resource is not a CustomResource) and resource references
  that have IDs that are not known. This is necessary for proper
  backwards-compatible serialization of resource references.
- Fix the key that stores a resource reference's package version in the
  .NET, NodeJS, and Python SDKs.
- Ensure that the resource monitor's marshalling/unmarshalling  of inputs
  and outputs to/from calls to `Construct` retain resource references as
  appropriate.
- Fix serialization behavior for resources -> resource references in the
  Go SDK: if a resource's ID is unknown, it should still be serialized
  as a resource reference, albeit a reference with an unknown ID.
2020-11-23 11:15:10 -08:00
Pat Gavlin 20f7720869
Add support for getResource to the Python SDK. (#5694)
Just what it says on the tin.

The SDK code generator will be updated to use the new `urn`
resource option inside of each module's implementation of
`ResourceModule.construct`.

Part of #2430.

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2020-11-20 13:13:23 -08:00
Justin Van Patten 4c88e215ce
Respect PULUMI_PYTHON_CMD in scripts (#5782)
If `PULUMI_PYTHON_CMD` is set, use it instead of running `python` directly.
2020-11-18 19:08:41 -08:00
Vivek Lakshmanan 55e86bf078
Update sdk/python/Makefile
Co-authored-by: Komal <komal@pulumi.com>
2020-11-18 09:21:41 -08:00
Vivek Lakshmanan 0d6f9fdcbf Switch to pytest since it captures stdout/stderr and only prints on failure 2020-11-17 23:09:18 -08:00
Vivek Lakshmanan 98bc43d6d6 Disable verbose logging for python tests 2020-11-17 23:09:18 -08:00
Pat Gavlin 1e0c9efdd7
Respect provider config secretness. (#5742)
Just what it says on the tin. This is implemented by changing the
`GetPackageConfig` method of `ConfigSource` to return a `PropertyMap`
and ensuring that any secret config is represented by a `Secret`.
2020-11-12 12:18:12 -08:00
Komal e3725a6e40
Support python 3.9 on windows (#5739) 2020-11-11 14:07:59 -08:00
Pat Gavlin f6b687ea03
Fix feature support checks in the Python SDK. (#5702) 2020-11-06 19:53:24 +00:00
Paul Stack d43f8bd311
Fix the go sum files to ensure non dirty tree (#5683) 2020-11-04 20:04:03 +00:00
Pat Gavlin 44376738f6
Add resource modules. (#5645)
This is necessary due to the way we've factored the libraries imported
by users into modules. The primary alternative is to ensure that each
child module imports the root module for a package and registers itself
with that package where necessary to prevent circular dependencies. This
simplifies the core SDKs slightly at the cost of greater complications
in the generated SDKs; the approach taken by these changes seems like a
more maintainable option.

Contributes to #2430.

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2020-11-04 10:24:41 -08:00
Komal f1f6a126bc
Support python 3.9 (#5669)
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
Co-authored-by: stack72 <public@paulstack.co.uk>
2020-11-03 16:28:45 -08:00
Pat Gavlin 3d2e31289a
Add support for serialized resource references. (#5041)
Resources are serialized as their URN, ID, and package version. Each
Pulumi package is expected to register itself with the SDK. The package
will be invoked to construct appropriate instances of rehydrated
resources. Packages are distinguished by their name and their version.

This is the foundation of cross-process resources.

Related to #2430.

Co-authored-by: Mikhail Shilkov <github@mikhail.io>
Co-authored-by: Luke Hoban <luke@pulumi.com>
Co-authored-by: Levi Blackstone <levi@pulumi.com>
2020-10-27 10:12:12 -07:00
Justin Van Patten ceec3eac0f
[sdk/python] Fix ResourceOptions annotations and doc strings (#5559) 2020-10-13 05:18:15 -07:00
Pat Gavlin 249140242e
Add support for provider-side preview. (#5443)
These changes add support for provider-side previews of create and
update operations, which allows resource providers to supply output
property values for resources that are being created or updated during a
preview.

If a plugin supports provider-side preview, its create/update methods
will be invoked during previews with the `preview` property set to true.
It is the responsibility of the provider to fill in any output
properties that are known before returning. It is a best practice for
providers to only fill in property values that are guaranteed to be
identical if the preview were instead an update (i.e. only those output
properties whose values can be conclusively determined without
actually performing the create/update operation should be populated).
Providers that support previews must accept unknown values in their
create and update methods.

If a plugin does not support provider-side preview, the inputs to a
create or update operation will be propagated to the outputs as they are
today.

Fixes #4992.
2020-10-09 13:13:55 -07:00
Lee Briggs 442d367b0b
fix perms on exec binary (#5524) 2020-10-08 13:32:53 -07:00
Justin Van Patten 97c006b5ce
[sdk/python] Fix secret regression (#5496)
A recent change to output deserialization resulted in secrets being returned unwrapped. This change addresses the regression, ensuring any unwrapped secret values are rewrapped before being returned.
2020-10-01 14:57:51 -07:00
Justin Van Patten 9bcf02e7ed
Support remote components in Python (#5375) 2020-09-30 14:09:20 -07:00
Lee Briggs 95bc138b41
add master branch workflow (#5386) 2020-09-21 16:20:05 -07:00
Justin Van Patten 5794a3f482
[sdk/python] Cast numbers intended to be integers to int (#5419)
We recently made a change to the Python codegen to emit `int` type annotations, instead of `float`, for properties that are typed as `schema.IntType`.

But the number values that come back from protobuf structs are always floats (like JSON), so we need to cast the values intended to be integers to `int`.
2020-09-19 21:09:53 -07:00
Justin Van Patten 46c7c327dd
Install plugin dependencies (#5353)
When installing a plugin, if it contains a `PulumiPlugin.yaml` file with a `runtime` value of `nodejs` or `python`, install dependencies for the plugin.

For Node.js, `npm install` is run (or `yarn install` if `PULUMI_PREFER_YARN` is set).

For Python, a virtual environment is created and deps installed into it.
2020-09-14 13:54:26 -07:00
Justin Van Patten 1ddc09f561
[sdk/python] Add pulumi.runtime.to_json utility (#5307)
Non-string provider inputs must be projected as JSON formatted strings. The current codegen simply calls `json.dumps` for such properties, but this does not work for the new input types, which aren't JSON serializable.

This commit adds a new `pulumi.runtime.to_json` utility function to the core SDK, which is capable of serializing both raw dicts and input types as JSON. The codegen will be updated to make use of this new function rather than `json.dumps`.
2020-09-09 12:08:45 -07:00
Justin Van Patten d0ba9fbdcd
[sdk/python] Add support for Sequence (#5282)
We currently emit array types as `List[T]` for Python, but `List[T]` is invariant, which causes type checkers like mypy to produce errors when values like `["foo", "bar"]` are passed as args typed as `List[pulumi.Input[str]]` (since `Input[str]` is an alias for `Union[T, Awaitable[T], Output[T]]`. To address this, we should move to using [`Sequence[T]`](https://docs.python.org/3/library/typing.html#typing.Sequence) which is covariant, and does not have this problem.

We actually already do this for `Dict` vs. `Mapping`, emitting map types as `Mapping[str, T]` rather than `Dict[str, T]` because `Mapping[str, T]` is covariant for the value. This change makes us consistent for array types.

These are the SDK changes necessary to support `Sequence[T]`.
2020-09-08 22:22:35 -07:00
Pat Gavlin 2585b86aa4
Initial support for remote component construction. (#5280)
These changes add initial support for the construction of remote
components. For now, this support is limited to the NodeJS SDK;
follow-up changes will implement support for the other SDKs.

Remote components are component resources that are constructed and
managed by plugins rather than by Pulumi programs. In this sense, they
are a bit like cloud resources, and are supported by the same
distribution and plugin loading mechanisms and described by the same
schema system.

The construction of a remote component is initiated by a
`RegisterResourceRequest` with the new `remote` field set to `true`.
When the resource monitor receives such a request, it loads the plugin
that implements the component resource and calls the `Construct`
method added to the resource provider interface as part of these
changes. This method accepts the information necessary to construct the
component and its children: the component's name, type, resource
options, inputs, and input dependencies. It is responsible for
dispatching to the appropriate component factory to create the
component, then returning its URN, resolved output properties, and
output property dependencies. The dependency information is necessary to
support features such as delete-before-replace, which rely on precise
dependency information for custom resources.

These changes also add initial support for more conveniently
implementing resource providers in NodeJS. The interface used to
implement such a provider is similar to the dynamic provider interface
(and may be unified with that interface in the future).

An example of a NodeJS program constructing a remote component resource
also implemented in NodeJS can be found in
`tests/construct_component/nodejs`.

This is the core of #2430.
2020-09-07 19:33:55 -07:00
Justin Van Patten 69fbd70330
Python: Ignore internal properties when unmarshaling (#5251) 2020-08-28 18:26:16 -07:00
Justin Van Patten 16d226d667
Avoid raising unexpected type errors with Any (#5238)
Avoid raising an `AssertionError` due to unexpected types when a type is annotated as `Any`.
2020-08-27 12:19:46 -07:00
Justin Van Patten cd9fae599d
Python SDK changes to support input/output classes (#5033)
Python SDK changes to support strongly-typed input/output "dataclasses".
2020-08-19 01:15:56 -07:00
Luke Hoban 5066ae3227
Fix support for CheckFailures in Python Dynamic Providers (#5139)
Fixes #5138.
2020-08-10 09:28:25 -07:00
Justin Van Patten b364296521
Python: Improved error message when virtualenv doesn't exist (#5069) 2020-07-28 13:28:14 -07:00
Justin Van Patten ce4badd488
Update pip/setuptools/wheel in virtual environment (#5042)
Update pip, setuptools, and wheel in the virtual environment before installing dependencies as recommended by the Python documentation. This should help avoid failures when only source distributions are available for a package and pip attempts to build a wheel locally.
2020-07-23 13:33:09 -07:00
Komal f364311064
Remove known_types decorators (#4980) 2020-07-13 12:27:00 -07:00
Komal bdc86e002a
Change how submodules are imported to work with Intellisense (#4948) 2020-07-08 18:34:59 -07:00
Komal ed752bc384
[codegen/python] Don't use __all__ (#4873) 2020-06-24 11:41:03 -07:00
Justin Van Patten 6bad3a3620
Exclude grpcio v1.30.0, which breaks Pulumi Python programs (#4883) 2020-06-24 08:11:05 -07:00
Pat Gavlin 3e6e28af36
Fix lint errors. (#4856)
These errors appear when using golangci-lint 1.27.0.
2020-06-18 14:17:11 -07:00
Justin Van Patten 9b0169be35
Fix pylint(no-member) when accessing resource.id (#4813)
Pylint currently reports `E1101: Instance of 'Bucket' has no 'id' member (no-member)` on lines in Pulumi Python programs like:

```python
pulumi.export('bucket_name', bucket.id)
```

Here's a description of this message from http://pylint-messages.wikidot.com/messages:e1101:

> Used when an object (variable, function, …) is accessed for a non-existent member.
>
> False positives: This message may report object members that are created dynamically, but exist at the time they are accessed.

This appears to be a false positive case: `id` isn't set in the constructor (it's set later in `register_resource`) and Pylint isn't able to figure this out statically. `urn` has the same problem. (Oddly, Pylint doesn't complain when accessing other resource output properties).

This change refactors `register_resource` so that `id` and `urn` can be assigned in the resource's constructor, so that Pylint can see it being assigned. The change also does the same with `read_resource`.
2020-06-12 12:41:56 -07:00
Justin Van Patten b77ec919d4
Install and use dependencies automatically for new Python projects (#4775)
Automatically create a virtual environment and install dependencies in it with `pulumi new` and `pulumi policy new` for Python templates.

This will save a new `virtualenv` runtime option in `Pulumi.yaml` (`PulumiPolicy.yaml` for policy packs):

```yaml
runtime:
  name: python
  options:
    virtualenv: venv
```

`virtualenv` is the path to a virtual environment that Pulumi will use when running `python` commands.

Existing projects are unaffected and can opt-in to using this by setting `virtualenv`, otherwise, they'll continue to work as-is.
2020-06-09 16:42:53 -07:00
Luke Hoban 678a5a6d3e
Export the CustomTimeouts class (#4747)
This class was available in the pulumi.resource module, but was not exported from the core `pulumi` module as intended for all public APIs at this level.
2020-06-03 15:36:44 -07:00
Paul Stack 45e1917a30
Upgrade to Go 1.14.x (#4697) 2020-05-28 12:01:33 +01:00
Justin Van Patten 6b0a845cc1
Support publishing Python policy packs (#4644)
Adds support for publishing Python policy packs to the service, and downloading/using such policy packs when applied to stacks in an organization.
2020-05-22 15:01:15 -07:00
Justin Van Patten af3d4b890d
Allow pulumi.export calls from unit tests (#4670)
The previous attempt to allow this didn't actually allow it, so this is
take two. As part of the previous attempt, I thought after tweaking the
test I had observed the test failing, and then succeeding after making
the product changes, but I must have been mistaken.

It turns out that our existing mocks tests weren't running at all
because of a missing `__init__.py` file. Once the missing `__init__.py`
is added, the tests run, but other tests ("test mode" tests) fail
because the code that creates the mocks and resources will run during
test discovery, and setting the mocks modifies global state.

To address the test issue, I've moved the mocks tests into their own
`test_with_mocks` package that can be run separately from other tests.

And addressed the original issue, by creating a root Stack resource if
one isn't already present when the mocks are set.
2020-05-20 09:54:40 -07:00
Lee Briggs 8c314ec39a
Add brew make targets to sdk makefiles 2020-05-13 20:42:01 -07:00
solidDoWant b7fb3bae22
Fixed ResourceOption deepcopy bug in stack_reference.py (#4553) 2020-05-08 12:01:59 -07:00
Pat Gavlin 9b1b9cca24
Makefile: properly encode dependencies (#4541)
This allows for the use of `make -j`, which speeds up a full build
dramatically at the cost of rather incomprehensible logs.
2020-05-04 14:26:52 -07:00
Justin Van Patten 16926504c1
Allow pulumi.export calls from unit tests (#4518)
This change allows importing modules with calls to `pulumi.export` in unit tests. Previously, you'd have to structure the Python program in a way that avoids the `pulumi.export` from being called from unit tests.
2020-04-29 10:03:20 -07:00
Komal c7866108e1
Merge branch 'master' into komalali/increase-grpc-message-size 2020-04-24 17:54:32 -07:00
Luke Hoban cfa57914a1
[sdk/python] Improve ResourceOptions.merge type (#4484)
* [sdk/python] Improve `ResoruceOptions.merge` type

The implementation correctly handles `None` inputs, so the type should allow these as well.

* Add CHANGELOG
2020-04-24 17:45:11 -07:00
komal 28d69e963e add tests for node and python 2020-04-23 11:16:36 -07:00
Komal Ali 9cf635ad5a pr changes 2020-04-23 11:16:36 -07:00
Komal Ali de41fecfdc fix python server options 2020-04-23 11:16:36 -07:00
Komal Ali 64f3c4a02a update sdks with new max message size 2020-04-23 11:16:36 -07:00
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls (#3750)

* Switch away from native grpc impl. (#3728)

* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)

* Only retry as long as we get unavailable back.  Anything else continues. (#3769)

* Handle all errors for now. (#3781)


* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes (#4288)

Adjust C# generation

* Replace IDeployment with a sealed class (#4318)

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty (#4320)

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen (#4379)
2020-04-14 09:30:25 +01:00
Mikhail Shilkov 6d32d575e0
Enable features in mock monitor (#4272) 2020-04-03 08:33:40 +02:00
Mikhail Shilkov 0bce094dc1
Fix python mock's call (#4274)
Fix python mock's call
2020-04-03 07:28:52 +02:00
Justin Van Patten dd104a00a7
Propagate secretness correctly in Python apply (#4273)
* Propagate secretness correctly in Python `apply`

* Improve `apply` test coverage

* Update CHANGELOG.md
2020-04-02 13:01:29 -07:00
Justin Van Patten e6be38e285
PaC: Add initial config support for policy packs (#4233)
The initial config represents any config that was specified programmatically to the Policy Pack, for Policy Packs that support programmatic configuration like AWSGuard.
2020-03-30 12:52:05 -07:00
Matthieu Berthomé 7c75d4fe5b
ephemeral kwargs for log methods (#4197)
Co-authored-by: rienafairefr <rienafairefr@gmail.com>
2020-03-26 14:23:43 -07:00
Luke Hoban 215f5af505
Clarify documentation on Output.from_input (#4178) 2020-03-25 15:28:22 -07:00
evanboyle 5e1f597ea9 make distinction between python VERSION and PYPIVERSION for install vs release 2020-03-19 17:02:10 -07:00
evanboyle ec686bbaf6 Merge branch 'master' of https://github.com/pulumi/pulumi into evan/gomod 2020-03-18 17:57:58 -07:00
evanboyle 48250176a1 Revert "move sdk/python/cmd/pulumi-language-python -> pkg/cmd/pulumi-language-python"
This reverts commit e2ee46fb23.
2020-03-18 17:11:56 -07:00
Justin Van Patten 24e804bbe8
Support for running Python policy packs (#4057)
These changes enable running policy packs written in Python.
2020-03-18 16:15:57 -07:00
evanboyle 30df499838 move pkg/version -> sdk/go/common/version 2020-03-18 15:25:25 -07:00
evanboyle 6552df7139 fix python sdk Makefile, use common pkg/version.go 2020-03-18 12:33:18 -07:00
evanboyle e2ee46fb23 move sdk/python/cmd/pulumi-language-python -> pkg/cmd/pulumi-language-python 2020-03-18 10:19:22 -07:00
Luke Hoban fdd9a57ff8
Implement GetSchema in dynamic providers (#4083)
It's not entirely clear why gRPC doesn't already report these cleanly as unimplemented, but for now we'll explicitly implement them to avoid any spurious warnings.

Fixes #4028.
2020-03-15 15:36:08 -07:00
Luke Hoban 9da774e180
Fix Python mocks (#4074)
The original version of this code caused inconsistencies in the event
loop associated with a given thread. These changes elimintate the event
loop shenanigans the mocks were trying to play by updating _sync_await
to create an event loop if none exists in the current thread.

It's possible that this will cause problems if the tests run on a
different thread than the original program, as the tests are likely to
end up waiting on outputs created by the program, which is not supported
in Python.

Also adds test coverage of the mocking/testing support in Python.
2020-03-12 21:09:47 -07:00
Mikhail Shilkov 8f1534c895
Mention mocks in the missing project error (#4041) 2020-03-09 16:23:49 +01:00
Justin Van Patten 80f6c61310
Initial support for configuring policies (#4015) 2020-03-08 14:11:55 -07:00
Charly Román 560f1f130e Python SDK fix type annotations for Output.all and Output.concat 2020-03-03 22:00:37 -06:00
James Nugent 60eeff3265
Merge pull request #3990 from pulumi/jen20/main-dockerfile-for-proto
Update gRPC library used in Go SDKs and regenerate code with latest tools
2020-02-29 12:46:46 +00:00
Pat Gavlin 682dced40b
Mock resource monitor (#3738)
These changes add support for mocking the resource monitor to the NodeJS
and Python SDKs. The proposed mock interface is a simplified version of
the standard resource monitor that allows an end-user to replace the
usual implementations of ReadResource/RegisterResource and Invoke with
their own. This can be used in unit tests to allow for precise control
of resource outputs and invoke results.
2020-02-28 17:22:50 -08:00
James Nugent a1b55192dd Regenerate protocol buffers code 2020-02-28 11:53:47 +00:00
Pat Gavlin ccde31b713
Add support for extracting schemas from providers. (#3984)
These changes add a new method to the resource provider gRPC interface,
`GetSchema`, that allows consumers of these providers to extract
JSON-serialized schema information for the provider's types, resources,
and functions.
2020-02-27 16:10:47 -08:00
Levi Blackstone 0931c0d419
Fix missing module import on Windows platform (#3983)
#3895 added a module import that apparently doesn't
exist on Windows. Check the platform before importing,
and skip this import for Windows.
2020-02-26 16:08:49 -07:00
Lee Zen 33b232adc4
Fix a regression for CustomTimeouts in Python SDK (#3964)
* Fix a regression for CustomTimeouts in Python SDK
* Accept dict as well as CustomTimeouts object
2020-02-22 19:32:06 -08:00
Lee Zen 54d344f7c1
Serialize CustomTimeouts in Python SDK (#3920)
* Translate CustomTimeouts properly for RPC serialization
* Include integration test for custom timeouts
2020-02-13 10:40:56 -08:00
Levi Blackstone 7efb88de3e
Allow oversize protocol buffers (#3895)
Set an option to increase the memory limit on protobuf
parsing so that we can handle larger gRPC payloads.

Co-authored-by: Evan Boyle <EvanBoyle@users.noreply.github.com>
2020-02-10 15:30:42 -07:00
Justin Van Patten 3bf9067bac
Expose options, parent, deps, and provider config to policies (#3862) 2020-02-07 16:11:34 -08:00
Pat Gavlin 4a201a7dfd
Do not busy wait in Python. (#3892)
Instead, keep a stack of outstanding RPCs and await each in turn. This
allows the main loop to block instead of spin.

Fixes #3759.
2020-02-07 12:10:59 -08:00
Luke Hoban 5bf490228a
Use \n for provider protocol even on Windows (#3855)
The provider plugin protocol is to write a port number followed by `\n`.  We must guarantee we do that even on Windows, so must avoid Python `print` statements which implicitly rewrite newlines to platform specific character sequences.

Fixes #3807.
2020-02-06 11:34:05 -08:00
Evan Boyle 106154f1fc
fix python sdk stack ref regression (#3798) 2020-01-24 09:36:47 -08:00
James Forcier bf84a3482b Add py.typed to Python package for PEP 561 compliance (#3704)
PEP 561 specifies that packages which contain either inline type hints
or type stubs should indicate their support for type hints via
including a file named `py.typed` in the root of the package. Since
Pulumi already includes inline type hints, adding `py.typed` to the
Python SDK simply allows these hints to be used by mypy.
2020-01-17 15:01:36 -08:00
Evan Boyle 972fc44dd7
Enable mypy (#3758) 2020-01-17 14:45:08 -08:00
clstokes 0a3191905c Fixed 'transacational' misspelling. 2020-01-13 10:45:07 -08:00
Luke Hoban 95daaa8cec Fix broken test 2019-12-21 06:51:42 -08:00
Luke Hoban 265acaefe5
Fallback to looking for python when launching Python language host (#3692)
Fixes #3398.
2019-12-20 17:09:00 -08:00
CyrusNajmabadi f4fc00ad0e
Output.apply should lift resources from inner Outputs to the top level output. (#3663) 2019-12-17 14:11:45 -08:00
Justin Van Patten 6c84b008d8
Send resource URN and name to analyzer (#3554)
More information we want to make available to policy packs.
2019-11-21 21:01:15 +00:00